Ppq position and latency compensation

Hi everbody,

I’m currently facing a problem which I expect to be trivially to solve but I can’t find any information or clues (which is a bit weird because it’s so basic).

I’m syncing the playback of MIDI sequences to the ppqPosition of the AudioPlayHead::CurrentPositionInfo supplied by the juce::AudioProcessor in the process callback.

However I realized that if I add a plugin with latency compensation to the track of my plugin (which is an instrument plugin without any latency) the timing gets off - probably because the host thinks the entire track needs to be shifted and the ppqPosition supplied by the position info object does not reflect the actual position anymore (which is weird because I would expect that the ppqPosition will be updated accordingly).

How are people addressing this problem? AFAIK there is no way to query the DAW for the latency of the entire track but there has to be a way to achieve sample-accurate synchronization regardless of what other plugins are on the track, right?

this sounds like a bug in the DAW. Because all signals (audio, MIDI, parameters updates) into a plugin should be referencing the same timeline. i.e. if latency compensation is active, it should be applied equally to all the input signal types. If you have to query the DAW to correct the latency, then the DAW is not doing its job.
Have you tried other DAWs?

I checked REAPER and Logic but since both are showing this issue and REAPER is a rather well-behaving DAW, I don’t think it’s a DAW specific issue.

REAPER reports a ppqPosition of 0.0 when I start playback at the start, but then compensates the latency of the other plugin (I just made a dummy plugin with 4096 samples of latency). I would expect it to report the ppq position of -4096 samples so that it will align with the zero time marker after it gets through he other plugin.

It doesn’t necessarily work like that. The DAW can apply latency to the output signals to balance them all at mix points. So the output audio is delayed but all plugins see the same timeline time.

1 Like

Hi Dave thanks for chiming in. So that means there’s nothing I can do to make sure that another plugin doesn’t mess up the timing of my sequencer? I can hardly imagine that this is the case.

How do you handle that in the Tracktion Engine?

In SynthEdit’s latency compensation, The DAW applies latency to the output signals to balance them all at mix points, but it applies the same latency to MIDI and to the ppqPosition. This allows plugins that don’t have latency to ignore any latency which is introduced elsewhere in the chain.

Yeah we do the same thing. The details are here if anyone is interested: https://github.com/Tracktion/tracktion_engine/blob/develop/modules/tracktion_engine/playback/graph/tracktion_PluginNode.cpp

Basically your plugin shouldn’t have to know about anything else in the playback graph. The DAW should deal with all of that. I’m with @JeffMcClintock , if that’s not the case, sounds like a bug in the DAW.

3 Likes