Playhead sync

I found the problem.

If I comment this:

       /* auto pitchShiftPlugin = edit->getPluginCache().createNewPlugin(tracktion::PitchShiftPlugin::xmlTypeName, {});
        if (pitchShiftPlugin != nullptr)
        {
            track->pluginList.insertPlugin(std::move(pitchShiftPlugin), 1, nullptr);
            pitchShiftPlugin->setEnabled(true);
        }*/

then the playhead works as expected!

Without the comment and setting pitchShiftPlugin->setEnabled(false); the playhead is not working again.

This is with pitchShift enabled on 8 tracks:

and this without:

Why if I use:

 if (auto epc = transport.getCurrentPlaybackContext())
 {
     return epc->getPosition().inSeconds();
 }

It works, why?

Any ideas?

PS: I have the same problem in WaveForm if I add PitchShiftPlugin

I’ll have to look in to this as it looks like the getAudibleTimelineTime() has been dropped from the UI at some point.

The problem is that some plugins introduce latency (pitch shifters quite a lot), so the audio they’re outputting is not time-aligned with the audio they’re inputting.

There’s a special Node, PlayHeadPositionNode which effectively keeps the transport position still for the total latency duration so the output should sync up with it.

But I’m deep in some other stuff right now so it will have to wait for a bit I’m afraid.

Yep, no problem.

Is funny that with transport.getCurrentPlaybackContext() I don’t have this problem.

It probably won’t stutter but it will be out of sync with the clips on the screen.

Understand.

This bus anyway is present also on waveform.

Should I open an issue in github?

Hi @dave96 , why this happen also if the plugin is disabled? Any change to have this fixed (if is fixable)?

In order to seamlessly bypass on/off between plugins with latency they’re still process as part of the audio graph.

You can remove this by returning true from EngineBehaviour::shouldBypassedPluginsBeRemovedFromPlaybackGraph() .

Thanks! But this will only fix when the plugin is bypassed. When is only the playhead will be always out of sync?

Sorry, I don’t understand the question. Can you explain why my previous suggestion doesn’t work when the plugin is disabled?

The point is more when is enabled. Is impossible to have a correct playhead?

Like I said, the Engine needs to be modified to use getAudibleTimelineTime.

How zoomed in are you as small latency amounts aren’t usually noticeable.

And how much latency is there in your graph?
This will largely be determined by what pitch shift algorithm you are using.

But try and think about the problem and why it occurs.

  • A pitch shift plugin can introduce as much as ~300ms latency
  • So when you press play, what are you hearing? Nothing. So ideally, we want to keep the playhead still. That’s what PlayHeadPositionNode and getAudibleTimelineTime are for
  • After the latency duration has elapsed, you want to move the playhead forwards one second per second
  • When you stop though, you’ll still hear ~300ms of the audio. So the other job that PlayHeadPositionNode and getAudibleTimelineTime do is just to keep the playhead at the position it was at when it stopped.

The first part of that should work, but like I said, I’ll have to look in to why the playhead is jumping to the end of the latency period when stopped. That is a (minor) bug atm.