I’m working on a small c++ audio project and need the ability to display a waveform on a timeline. From what I understand I need to use Sound::lock and use the ptr1 and ptr2 to acess the wave data.
unsigned int offset,
unsigned int length,
void ** ptr1,
void ** ptr2,
unsigned int * len1,
unsigned int * len2
I’m a little confused as to what these will actually return. If I loop through from ptr1 to len1 what would the values i’m reading represent?
And also what is the second pointer for? Do I used ptr2 once I’ve read up to len1?
Any help would be appreciated,
- GregC asked 6 years ago
Lock will expose the raw encoded sound data. For a standard wav file that will be PCM16 which will be an array of shorts, for MP3 it will be compressed data. If you want to do offline decoding you can use Sound::readData and Sound::seekData.
For normal sounds opened as FMOD_CREATESAMPLE, they will be completely decompressed into memory and you should get all of the sound data in ptr1. For streams the sound is double buffered so ptr1 and ptr2 correspond to the front and back buffers of the sound.
Using FMOD_CREATESAMPLE does the ptr1 from Sound::lock() include header info too or is it purely from the start of the sound data?
Also once a sound has been created with FMOD_CREATESAMPLE and locked, will the memory returned be the same format regardless of filetype? Ie. Is somthing like an .mp3 stored differently or is it fully decompressed into pure wave data and be stored the same as a .wav would be?
Thanks for the help!
- GregC answered 6 years ago
Please login first to submit.