I’m developing an application in the style of SingStar having a song on the background and the users need to sing at the same time of the song.
There is a noticeable latency (between 150 to 200ms) between the song played by FMOD Ex and the recording, being the output delayed in respect to the input.
For the mic inputs I’m using RtAudio, which is supposed to have very low latency.
This latency seems to be also PC dependant, but it doesn’t vary too much… The songs are in the mp3 format but are decoded and loaded into memory before the playSound execution.

Is there any way to measure the latency between the playSound to the output start in my soundcard?

Thank you.

  • You must to post comments

You should test playback latency by placing a microphone near your keyboard and speaker. When you hit a key to play a sound, it will make a click noise, measure the distance in a sound editor between that noise and the sound coming out of the speaker.

There is an encoder and decoder latency for mp3. You might want to use a different format like ogg or celt for better latency, but if you notice a few tens of millisecond of silence from your mp3 data, just offset your playback using Channel::setPosition if you want. We do a little bit of this ourselves but it differs for different songs.

I would recommend setting the mixer rate to that of windows. Having different rates introduces a resampler which adds a block of latency. use System::getDriverCaps then System::setSoftwareFormat to set the rate to the same rate as the soundcard (instead of the default of 48khz that fmod mixes at).

Next , System::setDSPBufferSize is used to lower playback latency, but lowering this can lead to stuttering if you dont test it thoroughly on a lot of setups. The default is 41024, you could try 31024 without probably causing too many problems, but i probably wouldnt go much lower.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.