Producer-Consumer buffering between two audio devices

Hi community,

I just wonder how to cope with a Producer-Consumer Buffering between two audio devices, taking into account that they are not exactly synchronized. This is, one Audio Device would be slightly faster or slower than the other one.

It is clear that a Lock-Free Ring-Buffer can be inserted between them. But, how to tackle this long-term drifting. Is there any strategy consolidated?

Thank you in advance,

Gabriel

I don’t think there is anything specific in JUCE for this (would be great if there was) but you have to interpolate to adjust the playback rate. One strategy is to adjust the playback rate slightly depending on how much audio is in the ring buffer (play faster if there’s too much, play slower if the buffer is going to run out).

That’s right. The key is how to manage this slight slip. As the frequency samples that I consider is almost exactly the same I.E. 48000.0000 and 47999.999 it could mean that one sample will be redundant or one audio sample will be vacant on a long period of time. I drives to me to consider to get rid of it or interpolate it in each case.

Any alternative idea?

Gabriel