Is there a particular reason why ppqLoopStart/End values are not filled at all by the AU wrapper? I had problems detecting the loop range in Logic Pro X, and I found out that these values are simply never set by the JUCE AU wrapper.
The information is, however, provided by the AU CallHostTransportState function. And in fact, if I simply put these values into the JUCE playhead, my code works fine.
So shouldn't the highlighted code below be added? (plus some error handling)
bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info) override
{
info.timeSigNumerator = 0;
info.timeSigDenominator = 0;
info.editOriginTime = 0;
info.ppqPositionOfLastBarStart = 0;
info.isRecording = false;
info.ppqLoopStart = 0;
info.ppqLoopEnd = 0;
switch (lastTimeStamp.mSMPTETime.mType)
{
case kSMPTETimeType24: info.frameRate = AudioPlayHead::fps24; break;
case kSMPTETimeType25: info.frameRate = AudioPlayHead::fps25; break;
case kSMPTETimeType30Drop: info.frameRate = AudioPlayHead::fps30drop; break;
case kSMPTETimeType30: info.frameRate = AudioPlayHead::fps30; break;
case kSMPTETimeType2997: info.frameRate = AudioPlayHead::fps2997; break;
case kSMPTETimeType2997Drop: info.frameRate = AudioPlayHead::fps2997drop; break;
//case kSMPTETimeType60:
//case kSMPTETimeType5994:
default: info.frameRate = AudioPlayHead::fpsUnknown; break;
}
if (CallHostBeatAndTempo (&info.ppqPosition, &info.bpm) != noErr)
{
info.ppqPosition = 0;
info.bpm = 0;
}
UInt32 outDeltaSampleOffsetToNextBeat;
double outCurrentMeasureDownBeat;
float num;
UInt32 den;
if (CallHostMusicalTimeLocation (&outDeltaSampleOffsetToNextBeat, &num, &den,
&outCurrentMeasureDownBeat) == noErr)
{
info.timeSigNumerator = (int) num;
info.timeSigDenominator = (int) den;
info.ppqPositionOfLastBarStart = outCurrentMeasureDownBeat;
}
double outCurrentSampleInTimeLine, outCycleStartBeat, outCycleEndBeat;
Boolean playing = false, looping = false, playchanged;
if (CallHostTransportState (&playing,
&playchanged,
&outCurrentSampleInTimeLine,
&looping,
&outCycleStartBeat,
&outCycleEndBeat) != noErr)
{
// If the host doesn't support this callback, then use the sample time from lastTimeStamp:
outCurrentSampleInTimeLine = lastTimeStamp.mSampleTime;
}
info.isPlaying = playing;
info.timeInSamples = (int64) (outCurrentSampleInTimeLine + 0.5);
info.timeInSeconds = info.timeInSamples / getSampleRate();
info.isLooping = looping;
info.ppqLoopStart = outCycleStartBeat; // ADDED
info.ppqLoopEnd = outCycleEndBeat; // ADDED
return true;
}
