RTAS and ppqPosition

Hello !

I am currently working on the RTAS version of a plugin.
this plugin uses AudioPlayHead::getCurrentPosition to get ppqPosition for sequencing.
this works fine with most of hosts, but not with Pro Tools (in this case, 8.1 but other versions produce the same symptom).

the sequence is kind of sliced, like some sounds were missing
although pretty wierd, notes seem to be in the right tempo.

From what I’ve observed (very difficult to debug), the retrieved ppqPosition may remain unchanged from one call to another to the main process function.

Does anyone know about this issue ?

After few investigations,
the positions is properly updated once on two
I actually get twice the same position, the third is right (fourth, same as third, … etc).

Could it perhaps be because PT is using more than one thread to call your plugin, and you’re mistaking two parallel callbacks for two sequential callbacks?

I have checked callback thread thanks to Thread::getCurrentThreadId() and always got the same value.
A single thread is used.

Hmm. I don’t know then! I’m pretty sure my code’s correct - when you ask for the ppq, it asks PT, and that’s the answer that comes back… If it’s wrong, I can’t think of anything we could do from the plugin end that would help.

I found the solution on digidesign developper site. It is a known issue bug in Pro Tools (see https://developer.digidesign.com/index.php?L1=5&L2=13&L3=19&LC=/?p=1038 you need to have a digidesign developper account). The workaround to get the correct tick is given in the blog and is the following.

        if(midiTransport != 0)
            midiTransport->GetCurrentTempo (&bpm);
            midiTransport->IsTransportPlaying (&isPlaying);
            midiTransport->GetCurrentMeter (&num, &denom);
			// This code determines the tick position of the start of the
			// current sub-buffer. Note that loop position is not considered.

			if (isPlaying)
				// GetCurrentRTASSampleLocation() retrieves the sample location
				// of the current sub-buffer when Pro Tools is in playback or -1
				// when Pro Tools is not in playback.
				Cmn_Int64 currentRTASSampleLocation;
				// GetCustomTickPosition() retrieves the tick position of any
				// sample. In this case, we want the tick position of the sample at
				// the beginning of the current sub-buffer.
				midiTransport->GetCustomTickPosition(& ticks, currentRTASSampleLocation);
				// GetCurrentTDMSampleLocation() retrieves the current DAE
				// playhead location regardless of whether or not Pro Tools
				// is in playback.
				Cmn_Int64 currentTDMSampleLocation;
				// GetCustomTickPosition() converts a sample location into its
				// corresponding tick position.
				Cmn_Int64 customTickPosition;
				// If Pro Tools is not in playback, use the tick position returned by
				// GetCustomTickPosition().
				ticks = customTickPosition;

I tested it on my plug in and it works perfectly.
Jules, is it possible to add it in Juce code?


Cheers Kevin, I’ll take a look at that!

…presumably it could be simplifed to this…?

[code] if (midiTransport != 0)
midiTransport->GetCurrentTempo (&bpm);
midiTransport->IsTransportPlaying (&isPlaying);
midiTransport->GetCurrentMeter (&num, &denom);

        Cmn_Int64 sampleLocation;
        if (isPlaying)
            midiTransport->GetCurrentRTASSampleLocation (&sampleLocation);
            midiTransport->GetCurrentTDMSampleLocation (&sampleLocation);

        midiTransport->GetCustomTickPosition (&ticks, sampleLocation);


Cheers, I’ll check that in shortly…

LOL, Necrobug. Anyways, this is still a thing with AAX and JUCE 5.4.5. Observed ppqPosition being off sometimes on PT2019, MacOS, 96KHz, 256s buffersize.

Quick fix:
in juce_AAX_Wrapper.cpp, replace the relevant line in getCurrentPosition(…) with

        int64_t ticks = 0;
        if (info.isPlaying)
            check (transport.GetCustomTickPosition(&ticks, info.timeInSamples));
            check (transport.GetCurrentTickPosition (&ticks));

Now my DAW-synced LFOs don’t “scratch” anymore :slight_smile:

Thanks for reporting.

1 Like