Question on audio callback algorithm

Hi,

Can I assume that when the audio callback my getNextAudioBlock(), the previous filled audio block is currently been played ?
I must make sure the previous audio block’s time range is valid.
This could be wrong, if and only if Juce would buffer x audio block before sending to the card, and changes x dynamically and silently.

Ah, I wish it was so simple. No, in fact the last buffer probably isn’t being played yet when you’re filling the next one, it depends on a million unknown factors in the soundcard.

But it doesn’t matter. What you need to look at is the latency value, which will tell you how long it takes between filling a buffer and it being played.

So, instead of remembering the last block time range, I can just do “audioClock = currentSampleTimestamp - audioIODevice.getOutputLatencyInSamples()/outputSampleRate” ?
If it’s the case, it’s even easier than having to store the previous time range and compute a “is-clock-close-to-previous-range-limit”.

Yes, that’s the idea.