Buffer Size + PPQ

I have a plug-in that calculates syncing based on ppq values, and it seems that when the buffer size is large, the flag doesn’t go off as expected.

Does anyone have any suggestions on how to mitigate this problem?

I think more information on the issue would be helpful. For example, what is ‘the flag’? And how does this flag ‘go off’?

Is the problem just that your current implementation does some calculations based on the PPQ read from the daw at the start of the callback, but does not calculate changes in position over the remaining buffer?

Yeah, I was just thinking about this a bit more…

The issue is inner block communication. A large buffer size implies a less frequent callback (in theory), so we’ll need to take a sample based approach - calculating a delta_ppq per sample.

Yep. Samples are your clock in the callback.

I was on a ride, and thinking about how to approach this problem.

There’s a bit of an existential issue.

So the callback will provide a ppq value - which is current - and we fill the buffer up - presumably from the current postion + buffer size.

(perhaps that’s a misunderstanding in logic. Is the ppq value == buffer.getNumSamples() - 1 or ppq == buffer.atStartIndex ?)

If it’s indicative of the start index, and we are not gaurenteed to know when the next callback will be, then we have to predict the interval (presumably ppq_current - ppq_previous [edge case if playhead loops or moves backwards])

I’ve not worked with DAW sync recently, as recently I have been doing mostly stand alone JUCE apps for preset editing/sample management for eurorack modules, and for prototyping UI and DSP for actual eurorack modules, but.. I would be surprised if the ppq value was not aligned with the start of the buffer, in the same way the midi event times are aligned with the start of the buffer. I don’t follow what you are saying about knowing when the next callback will be, in most ways the callback doesn’t matter, you know the position of the sample at the start of the buffer, and you can calculate the ppq per sample with bpm / (60.0 * sampleRate), so you can know the ppq position of each sample.

Rock 'n roll.

That’s correct - bpm / (60.0 * samplerate) - to sync the frequency.

What’s interesting here is if you have an oscillator running - and you want the phase of the oscillator to sync to the daw then you’ll also need to ensure the oscillator is started (or phase adjusted) to the down beat - or ppq value.

I’m going to close this thread out. The solution I considered is working. There are a few edge cases to consider (1) If the playhead moves backwards in time [like looping in a daw], and (2) if the down beat is somewhere in the middle of the audio buffer…the oscillator will need to be offset appropriately [seems obvious, but doing some qualitative testing I noticed something was off and realized that all values will need to be aligned…]

Tell next time…

1 Like