Comments (7)
Appreciated :) Please free to re-open this or open another issue if there's something else I can help with in the library.
from dswaveformimage.
Hey @activcoding,
so the short answer is: currently this isn't something that's available as a SwiftUI view directly. It is generally somewhat possible with this WaveformImageDrawer method to draw an image from a an array of Float samples.
But unfortunately that's also not directly usable for you, since what you currently have is "random audio data", that would first need to be unpacked into an actual stream of samples. This is done internally using AVAssetReader
which does all the heavy lifting of the different audio encodings etc.
I've just done a quick & dirty SO search on how to get an AVAsset
from Data
and it seems the best way is to go through writing it to Disk.
That's what I'd have probably recommended in your case and that also seems to be the most direct way in general.
You mentioned you tried that but it didn't work. It definitely will work once the data has been written properly, as long as the audio data is something iOS can read out of the box. Generally speaking, once you wrote the data to disk and an AVPlayer
can play it back, WaveformImage
will be able to render it.
So long story short, I'd suggest your best way forward is to figure out why the writing to disk doesn't work. Is the format correct? Is the file maybe written with some important header information missing, so that AVFoundation
doesn't know what format it is?
from dswaveformimage.
Thank you @dmrschmidt, I'll try my best.
I very much appreciate your detailed answer, you are a true gem for this community.
from dswaveformimage.
Found the bug 🎉!
In one of the examples in the readME an m4a file is used:
@State var audioURL = Bundle.main.url(forResource: "example_sound", withExtension: "m4a")!
WaveformView(audioURL: audioURL)
Yesterday I always tried it with a m4a file, but the app keep crashing...
Today I just tried justing a mp3 file, it worked like magic.
from dswaveformimage.
Great to hear you’ve found the issue.
I’d be really curious to see what the issue with the file may have been. m4a should typically just work. Would it be possible for you to share the file that cause the crash here?
from dswaveformimage.
Sure.
The audio is from a pet project of me: AI-Voices with ElevenLabs
Here are two audio files, the m4a is not playable and the mp3 is:
But is seems the problem is on the server-side of ElevenLabs 🤦♂️, looks like they are sending broken m4a files...
from dswaveformimage.
Thanks for sharing! Just tried playing it and macOS definitely can't. Tried VLC and it played it. So I opened it in a hex editor, and checked the header bytes to see what format those say it is. Turns out its also just an mp3. If you rename it to mp3, that one also plays on macOS. VLC does a better job at trying to figure put what format files are in. AVFoundation seems to just look at the file ending. So that's that riddle solved :) Sounds like a bug on their end for sure then.
from dswaveformimage.
Related Issues (20)
- xcode 15 not support. Stored properties cannot be marked unavailable with '@available' HOT 1
- Striped style with gradient HOT 2
- Stored properties cannot be marked unavailable with '@available' HOT 3
- Stored properties cannot be marked unavailable with '@available' HOT 1
- Thread 1: EXC_BAD_ACCESS (code=2, address=0x2829857c4) HOT 1
- WaveForm Flickering HOT 2
- Extra argument position in call error in MacOS HOT 1
- I need to show loader till complete image generating from audio URL. HOT 2
- Update version in cocoapod HOT 2
- crash in iOS 17 HOT 10
- Error on macOS HOT 7
- WaveformLiveCanvas with live floats from AVAudioPCMBuffer.floatChannelData always indicating max volume, not showing silence HOT 7
- Can't Run Example HOT 3
- LTR Support HOT 1
- Getting crash While entering foreground from background HOT 23
- unable to create wave view with audio server url HOT 1
- Stored properties cannot be marked unavailable with '@available' HOT 4
- Android alternative HOT 1
- Support for stereo/multiple channels HOT 1
- Support for older versions of macOS HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dswaveformimage.