Re: How to show the wave of the audio file in my application when sound is playing?
Re: How to show the wave of the audio file in my application when sound is playing?
- Subject: Re: How to show the wave of the audio file in my application when sound is playing?
- From: Jens Alfke <email@hidden>
- Date: Wed, 25 Mar 2009 10:21:30 -0700
On Mar 24, 2009, at 11:32 PM, ldl0313036 wrote:
Now I want to show the wave of the audio in my application when it
is playing.
I built my own implementation of this. To avoid drowning in data I
created a low-resolution preview waveform by running the audio file
through an ExtAudioFile with the client format set to 8-bit mono at a
low bit-rate (about 1Khz), and saving the output as a byte array. This
lowers the footprint to about 1kbyte/sec. This is still sort of slow
to generate, so I store it to disk in a cache directory, tagged with
the mod date of the audio file.
Drawing this isn't difficult. You need to map samples in the byte-
array to pixel x coords onscreen, and interpolate. On the y axis,
amplitude doesn't map linearly to perceived volume level. I did some
research on this and tried a few algorithms based on exponentials
before settling on the simple
y = amplitude^3
which is what CoreAudio itself uses, apparently.
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden