Maybe this has been answered before but could anyone explain exactly what I need to do if I want to draw a complete waveform of a sound.
I want to draw the graphical representation of the waveform, like you see in
many wave-editors. To do this you must go through the sound once completely.
I tried doing this with getWaveData, starting at position 0 and steeping up 1 sample at a time, the problem is getWaveData only returns values when the sound is playing. Is it possible to get the wavedata when the sound is not playing, just by stepping through every single sample manually?
Thanks in advance.
Nevermind I found it out myself.
For all other users:
Example a Stereo (2 channel) 44100hz 16bit PCM
– 44100 samples for 1 second of sound
– 16 bits per sample
– 4 bytes per sample
– 2 bytes for left channel data
– 2 bytes for right channel data
the bytes are little-endian
sample 0 left channel value = byte + (byte * 256)
this value is a signed value (the first bit indicates positive/negative value)
lets take 1 sample as an example:
[code:1r52pzje]byte0 byte1 byte2 byte3
126 229 031 098
[ left ] [ right ]
Hope this is helpful to someone.
If you’re going to be working with small audio files, then ignore my suggestion. If you’re going to be working with large audio files opened in stream mode, then ignore Brett’s suggestion.
Last time I checked, the lock method can’t be used with streams.
Please login first to submit.