I could really use some pointers on getting the ppq position of where the host transport really starts from.
When I set the Cubase playhead to being from the second 16th note at 1.1.2.0 and press play the ppq position given by positionInfo->getPpqPosition() starts with negative values, incrementing many times as the ProcessBlock is called before it reaches the actual ppq position that the Cubase playhead starts from (1.125).
I check to make sure that positionInfo->getIsPlaying() is true before calling positionInfo->getPpqPosition() so itâs not that Iâm taking the values whilst the playhead is stopped.
So how are we supposed to calculate the position of the DAWs playhead if getPpqPosition() cannot be trusted?
i think the reason for that is that cubase plays a bit of empty audio before hitting the point where the user sets the playhead in order to make sure all the plugins already started warming up their processes if needed so that you can hear the point of interest with the same punch it would have while running freely. if starting from the first bar that means some ms of negative ppq. from experience i can tell that some plugins canât deal with that well which is why i personally got into the habit of not starting a project from bar 1, but you can also just make sure that it works well in your plugins for those who like to live dangerously
Yeah, I think youâre right - Cubase does seem to add some kind of delay/pre-roll of itâs own but, at least from my perspective, that renders the ppqPosition values pretty much useless!
At least it canât be trusted to give you what itâs name and description claims :smiley
Anyway, I figure the samples in the buffer should be accurate - so counting them and calculating the real ppq position from those should be more reliable than the other way round like I was doing. I think it should actually be less expensive too calculate it too.
Uggh! Iâm pulling my hair out here - how do people get heir plugins to sync properly and consistently to Cubase!?
I thought I would be able to use positionInfo.timeInSamples rather than positionInfo.ppqPosition since the ppqPosition Cubase reports is not correct at start-up; but no - even the reported time in samples is wrong!
I move the Cubase transport forwards to 1.1.2.0 (one 16th note from zero) and in a buffer where positionInfo.isPlaying is true I get these valuesâŠ
All of these should be non-zero. This makes it impossible to reliably be in sync and trigger notes correctly. Either I would have to accept that notes are scheduled at positions before the playhead begins, or I have to accept that I canât sync until the first bar has elapsed. But I know that plugins exist that do sync correctly so what am I missing? Please help!
A. PPQ got limited resolution to begin with.
B. Whatâs the exact value youâre seeing with the negative ppq?
C. Most reliable position from my experience is seconds. Even samples ends up sometimes being rounded the wrong way so you get a sample offset.
D. Keep in mind that ppq is limited with changing tempo and/or time signatures. Youâll need extra information to calculate position for those. (Unless you store your notes in PPQ)
Yeah, PPQ is not as fine grained as samples but I didnât expect it to be completely off and so unreliable to the point that it reports negative values when the playhead is ahead of the zero start position.
An example of the negative value when starting the playhead a 16th note ahead of zero:
PPQ Position: -0.123900
No pre-roll or anything like that enabled. Itâs simply wrong.
So, I was planning to ignore the PPQ reported and calculate it myself based upon the bpm, samplerate, and either timeInSample or timeInSeconds but since both of these are also wrongly reported there doesnât seem to be any reliable way to know âwhereâ the transport started from.
Right now, the only option I can think of is to delay processing until I see that the reported values have stabilized across a buffer or two. The irritating thing is that I know that plugins exist that are able to sync correctly from the playposition; it just eludes me how they are doing it.
Essentially sample counting can keep you at correct speed, but it cannot tell you the correct musical phase if the host gives bad initial info.
A negative PPQ is fine, the DAW is totally allowed to start playing from before the 0 position. Cubase has a bunch of features that could make that happen (bar offset, ASIO guard, prerollâŠ)
My plugins sync fine with Cubase without doing anything special (except handling negative PPQ) so itâs hard to tell exactly what the problem is.
If you want to create some minimal example showing the problem, it might be more useful to take a look.
Iâll try to explain. I am triggering notes at note divisions; letâs say every quarter-note.
If I move the Cubase transport ahead so that it begins at 1.1.2.0 (the second 16th note) and start playing from there, then I donât want a note to be scheduled at 1.1.1.0 before the playhead start position.
This does happen because Cubase is not reporting the real start position and instead reports that the PPQ position is some place before 1.1.2.0.
So itâs not just negative PPQ that is the problem but PPQâs before the transport start point.
So how can my plugin figure out âwhereâ the playhead started from?
Iâm not seeing those issues here, my sequencer plays in exact timing starting from anywhere in the Cubase transport, even if the user starts to play from an un-quantized position like the middle of the first bar, etc.
I think youâll need to create some minimal reproducible example - I suspect the problem might be in how you interpret the PPQ values, and not the actual PPQ values sent by Cubase.
You can make some minimal reproducible example and put it on GitHub for everyone to see, Ideally do that as something âcleanâ as possible and with as less project-specific complications as you can.
For example if you can just build something simple that generates quarter notes MIDI notes or some white noise, and shows the problem in a clear way.
Otherwise if you want me to really work on your project you can pay my hourly fee.
Hereâs an example that just produces a note every beat.
To reproduce just start the Cubase transport at 1.1.2.0 and press record - you will see the note get placed at 1.1.1.0 - not every single time but often.
Oh and youâll need a midi track that receives the input from the plug - but of course you would know that!
Much appreciated for the help and yes, if I need more help then I would be happy to pay your no doubt extortionate hourly fee!
It all works fine here. I think the problem youâre experiencing is that Cubase has a feature called âRetrospective MIDI Recordingâ which means it actually calls the plugin for a little while before starting the record. So if you hit record from 1.1.2 it might actually start from 0.
hmm, Iâm pretty sure I found that feature - I was checking all the menus to see if there was anything that could make a difference. I turned that off and it still happens.
Are you sure you canât reproduce it?
Start the transport from 1.1.2.0. Hit record and you donât see a note captured at 1.1.1.0?
Do I need to restart Cubase after changing that feature? Maybe that could be it as I donât think I did that
I think you misunderstand - I can see it creating the clip retroactively. Itâs a âfeatureâ not a bug - there used to be a way to turn it off but as of Cubase 12/Mac I canât find a way to turn it off.
What I see Cubase does is that it creates a clip retroactively and actually starts the record from 1.1.1.0 even if your transport was after that. Itâs meant to prevent you from missing notes.
Ok, so that means that Cubase is sending positional info that starts before the actual start point in the UI - hence there is no way a plugin can really account for that.
Yes, it calls the plugin from an earlier position. In the past you used to be able to go to preferences->Record->MIDI and turn it off, but that checkbox seems to be gone. Maybe thereâs a hidden way to turn it off.
Having that said from the pluginâs perspective this is all correct - Cubase actually calls you to start from an earlier position, and you can see in the resulting clip that it positioned the notes correctly at the start of the bar.
I have written my code to detect when a loop happens and we wrap back around. Once I know that my start PPQ postion in the buffer is less or equal to the loop start PPQ and that the previous start position of the last buffer is more or equal to the loop end PPQ I can schedule a note.
What is actually happening is that sometimes two notes end up in the same bar! Itâs as though Cubase is misplacing one of the notes to end up in the previous bar.
Here are my logs showing the 5 notes. The result in Cubase is 4 takes, the first 3 are perfect and the last has 2 notes - one ok and one super long (no note off)
Note-off triggered after 22080 samples, offset: 30
The difference between the buffer count is very regular at 1,378 so I know itâs not the triggering logic being triggered twice in the same cycle. I have no idea what is happening. @eyalamir@jules Any tips?
Unfortunately, this to me has way too much product-specific info for me to solve in a forum like that. It just sounds to me like your logic/math is somehow not correct, I donât think Cubase is doing anything wrong when looping.