Somewhat similar to the "recording" example, I’m recording into a short looping buffer and playing that buffer at the same time with a looping sound. Depending on user action, I enable and disable recording/playback of recording multiple times throughout the lifetime of the application. The two most important things for me about this functionality are:

  1. Minimize the latency between record and playback out the speakers.
  2. Make the latency deterministic.

Using the function usleep() to induce some program sleep time between calls to recordStart() and playSound() on the record buffer does not produce deterministic latency in the FMOD output.

I’ve also tried setting the position of the playback buffer , like so:

do recordStart()
do playSound()
set sound playback time, via setPosition(), to buffer length minus XYZ milliseconds, so that it is behind the record position

Although this is better I have noticed that the latency can vary. This is most obvious when the play head gets just in front of the record head which results in sound buffer length latency, the worst possible scenario.

How can I improve this? Thanks for any info.

  • You must to post comments

Because sleep isn’t as reliable as you probably want, you could combine it with a getRecordPosition polling loop. So you start recording, then in a loop poll getRecordPosition and do a very small sleep. Loop until the position has reached your desired buffer length.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.