This time I need to know, how I could get the waveform data from FMOD. I get the spectrum from FSOUND_DSP_GetSpectrum, but for some visuals I need also the waveform.
So have anyone the code or an idea for getting the waveform data?
Simply create a DSP module and get data from it. To synchronize DSP buffers with current output you can:
1) set up FMOD with a little buffer, or
2) use internal buffers to store data.
I prefer the second method because it can be applied to both small and large buffers.
Here is an example:
If you set up FMOD with a 250 ms buffer, FMOD will create (250/25)*2 buffers because 250 is the size of buffer, 25 ms are the packets that FMOD uses and *2 means double-buffering.
Now you have are sure that FMOD uses 20 buffers. Now take a variabile that will be incremented on every buffer filling (this should be done in the DSP module), so you’ll have the variable counting from 0 to 19. The buffer pointed from the variable is the last buffer filled, while the current output is at the (variable+(buffers-1)) % buffers. In numerical form:
(variable+19) % 20
Where variable increments of 1 each buffer filling.
I hope I was clear enough! Excuse my bad english!
Hm, then I have not seen it. But I’ve found it yet in the sample directory, you’re right 😉 I didn’t find it, because I’m using Delphi and hasn’t looked enough at the c code of the examples. So I will see, what I could use from that sample…
The size of the buffer?
You can calculate it simply doing (samplingratebuffersize)/1000.
In a numerical form, for example:
Then round it to the next multiple of 4 and you got it!
Look that this is the number of samples. To get the number of bytes you have to multiply by 4 bacause of stereo and 16 bit (2 channels * 2 bytes each = 4 bytes per sample!)
Please login first to submit.