Question

I want to get sound level, so I can display it in my SDL application (the platform is Linux) when recording sound. How can I do that? I use FMOD API in my app, but for recording, I'm using SoX (forking and using exec() to set it up - probably this could be done better but I don't know how :( ). Should I use some function of SoX, FMOD API, or maybe directly access /dev/dsp to get sound data?

Was it helpful?

Solution

You can do recording in FMOD if you like. FMOD APIs such as System::recordStart and System::getRecordDriverInfo can be used. FMOD ships examples of recording which you can use as a basis for your solution.

Specifically for getting the sound level, if you wanted to do it as a runtime thing you could use Channel::getWaveData which will give you a snapshot of the current playing audio, for this you would need to play the recording data.

Or alternatively you could use Sound::lock / Sound::unlock to get access to the recording sound data if it isn't playing.

Once you have access to the sound data through either method you can read through the values to get sound level / peak information.

OTHER TIPS

No, at the very least you should use the "safe" ALSA API. But you should consider using something higher up such as Gstreamer or PulseAudio.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top