This is my first time using Juce and the RTAS SDK so bear with me…
Using Juce 2.0 and the RTAS wrapper getCurrentPosition() I find that the returned info.timeInSeconds is off by twice the HW Buffer Size.
By adding a member variable to the CurrentPositionInfo struct:
and by modifying getCurrentPosition() to:
[code]bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info)
{
// this method can only be called while the plugin is running
jassert (prepared);
Cmn_Float64 bpm = 120.0;
Cmn_Int32 num = 4, denom = 4;
Cmn_Int64 ticks = 0;
Cmn_Bool isPlaying = false;
// Moved sampleLocation for scope & check the value for mRTGlobals->mHWBufferSizeInSamples :
Cmn_Int64 sampleLocation;
const Cmn_UInt32 bufferSize = mRTGlobals->mHWBufferSizeInSamples;
if (midiTransport != 0)
{
midiTransport->GetCurrentTempo (&bpm);
midiTransport->IsTransportPlaying (&isPlaying);
midiTransport->GetCurrentMeter (&num, &denom);
// (The following is a work-around because GetCurrentTickPosition() doesn't work correctly).
if (isPlaying)
midiTransport->GetCurrentRTASSampleLocation (&sampleLocation);
else
midiTransport->GetCurrentTDMSampleLocation (&sampleLocation);
// Adjust the sampleLocation value by twice the HW buffer size
sampleLocation = sampleLocation + (bufferSize * 2);
midiTransport->GetCustomTickPosition (&ticks, sampleLocation);
}
info.bpm = bpm;
info.timeSigNumerator = num;
info.timeSigDenominator = denom;
info.isPlaying = isPlaying;
info.isRecording = false;
info.ppqPosition = ticks / 960000.0;
info.ppqPositionOfLastBarStart = 0; //xxx no idea how to get this correctly..
info.isLooping = false;
info.ppqLoopStart = 0;
info.ppqLoopEnd = 0;
info.currentSampleLocation = sampleLocation; // return this to check sample location in plugin
:
:
return true;
}[/code]
The returned value now is correct in Pro Tools 10.x (native)
Is this correct or am I missing something ?? Will this be different using TDM or HDX hardware?
Thanks,
Rail