I’m a new Fmod user and I need some help.
I’m working on a sound manager software like Audacity, and I need to draw two things :
[u:59g9uj75]1- The Sound Spectrum :[/u:59g9uj75] I did this one with the function GetSpectrum which returns me an array of 512 audio frequencies, then I can draw [url=http://uploads.siteduzero.com/files/85001_86000/85967.png:59g9uj75]that[/url:59g9uj75].
[u:59g9uj75]2- The Amplitude Spectrogram :[/u:59g9uj75] I’m trying to do this but I’m still looking for the amplitude of the sound. I didn’t find any function which can give me those informations. I want to draw something like [url=http://www.wilhelm-kurz-software.de/dynaplot/applicationnotes/spectrogram1.gif:59g9uj75]that[/url:59g9uj75] (at the top).
I hope that someone can help me.
- SmK asked 8 years ago
Thx for answer.
I’m using sound::lock() and I’ve got a void * to cast.
I tried to cast it in float and unsigned int but the result is… strange.
I’ve got 46.000.000 bits and I need like 8 hours to printf() all this values
So which cast do I have to use for the void * ?
- SmK answered 8 years ago
The format of the contents returned to you by the lock() function are in raw format. So, it may be 8, 16, 24, or 32-bit mono or stereo data.
Use Sound::getFormat() to determine which one it is.
For 8-bit data, use signed char as the format.
For 16-bit data, use signed short as the format.
For 32-bit data, use signed long as the format.
I’m not sure what you do for 24-bit data.
Mono will have one entry per sample. Stereo will be interleaved Left then Right samples.
Be sure to unlock your data after you’re finished with it.
Thx for answer.
I’ve got the raw data and I try to display that with QT, but the result is really strange :/
For example I’ve got like 3000 bytes with the value ‘0’ at the beginning of the mp3.
Is this the mp3 headers ?
Is the lock() function return the mp3 headers ?
I also guess that I can’t use the raw data directly, maybe I have to use some FFT algorithm on that before display it ?
And my last problem is that I want to convert or save on disk a sound with fmod, but I didn’t find any function to do that. Can I do that ?
- SmK answered 7 years ago
3000 bytes worth of 0’s would be 750 samples at 16-bit stereo (3000/4), which, at 44KHz, amounts to 17 milliseconds of silence, which isn’t wholely unreasonable for a music file.
Do the math the other way: at 44KHz 16-bit stereo, every second of audio data amounts to 176,400 bytes. (44,100 * 2 * 2)
For saving a sound to the disk, there’s a number of options. If you just want it in Wave format, have a look at FMOD_OUTPUTTYPE_WAVWRITER or FMOD_OUTPUTTYPE_WAVWRITER_NRT. That’s the easiest way. If you need more complicated stuff, you can try attaching a custom DSP to intercept the audio just after the final mix.
There’s a number of examples that demonstrate writing files to disk: offlinedecoding, output_mp3 (in the plugin_dev folder), recordtodisk, and ripnetstream all write wave data to the disk.
Hope that helps.
- Adiss answered 7 years ago
If you’re trying to do this offline, then I think what you’re looking for is Sound::lock(), which will let you look at the sample data over the sound. If you graph the contents of the sample data, you’ll get an amplitude graph like it sounds you want.
If you’re trying to do this at runtime (ie while the sound is playing), then have a look at Channel::getWaveData(), which will give you sample data of the currently playing audio.
Hope that helps!
Please login first to submit.