mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
AudioUnits: In host + plugin sides, passed the loop start/end ppq positions via the playhead position info.
This commit is contained in:
parent
9d29fd4c9d
commit
0d3afee459
2 changed files with 41 additions and 43 deletions
|
|
@ -645,8 +645,6 @@ public:
|
|||
info.editOriginTime = 0;
|
||||
info.ppqPositionOfLastBarStart = 0;
|
||||
info.isRecording = false;
|
||||
info.ppqLoopStart = 0;
|
||||
info.ppqLoopEnd = 0;
|
||||
|
||||
switch (lastTimeStamp.mSMPTETime.mType)
|
||||
{
|
||||
|
|
@ -656,8 +654,6 @@ public:
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -680,7 +676,7 @@ public:
|
|||
info.ppqPositionOfLastBarStart = outCurrentMeasureDownBeat;
|
||||
}
|
||||
|
||||
double outCurrentSampleInTimeLine, outCycleStartBeat, outCycleEndBeat;
|
||||
double outCurrentSampleInTimeLine, outCycleStartBeat = 0, outCycleEndBeat = 0;
|
||||
Boolean playing = false, looping = false, playchanged;
|
||||
|
||||
if (CallHostTransportState (&playing,
|
||||
|
|
@ -698,6 +694,8 @@ public:
|
|||
info.timeInSamples = (int64) (outCurrentSampleInTimeLine + 0.5);
|
||||
info.timeInSeconds = info.timeInSamples / getSampleRate();
|
||||
info.isLooping = looping;
|
||||
info.ppqLoopStart = outCycleStartBeat;
|
||||
info.ppqLoopEnd = outCycleEndBeat;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1122,24 +1122,24 @@ private:
|
|||
OSStatus getMusicalTimeLocation (UInt32* outDeltaSampleOffsetToNextBeat, Float32* outTimeSig_Numerator,
|
||||
UInt32* outTimeSig_Denominator, Float64* outCurrentMeasureDownBeat) const
|
||||
{
|
||||
AudioPlayHead* const ph = getPlayHead();
|
||||
AudioPlayHead::CurrentPositionInfo result;
|
||||
if (AudioPlayHead* const ph = getPlayHead())
|
||||
{
|
||||
AudioPlayHead::CurrentPositionInfo result;
|
||||
|
||||
if (ph != nullptr && ph->getCurrentPosition (result))
|
||||
{
|
||||
setIfNotNull (outTimeSig_Numerator, (UInt32) result.timeSigNumerator);
|
||||
setIfNotNull (outTimeSig_Denominator, (UInt32) result.timeSigDenominator);
|
||||
setIfNotNull (outDeltaSampleOffsetToNextBeat, (UInt32) 0); //xxx
|
||||
setIfNotNull (outCurrentMeasureDownBeat, result.ppqPositionOfLastBarStart); //xxx wrong
|
||||
}
|
||||
else
|
||||
{
|
||||
setIfNotNull (outDeltaSampleOffsetToNextBeat, (UInt32) 0);
|
||||
setIfNotNull (outTimeSig_Numerator, (UInt32) 4);
|
||||
setIfNotNull (outTimeSig_Denominator, (UInt32) 4);
|
||||
setIfNotNull (outCurrentMeasureDownBeat, 0);
|
||||
if (ph->getCurrentPosition (result))
|
||||
{
|
||||
setIfNotNull (outDeltaSampleOffsetToNextBeat, (UInt32) 0); //xxx
|
||||
setIfNotNull (outTimeSig_Numerator, (UInt32) result.timeSigNumerator);
|
||||
setIfNotNull (outTimeSig_Denominator, (UInt32) result.timeSigDenominator);
|
||||
setIfNotNull (outCurrentMeasureDownBeat, result.ppqPositionOfLastBarStart); //xxx wrong
|
||||
return noErr;
|
||||
}
|
||||
}
|
||||
|
||||
setIfNotNull (outDeltaSampleOffsetToNextBeat, (UInt32) 0);
|
||||
setIfNotNull (outTimeSig_Numerator, (UInt32) 4);
|
||||
setIfNotNull (outTimeSig_Denominator, (UInt32) 4);
|
||||
setIfNotNull (outCurrentMeasureDownBeat, 0);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
|
@ -1147,34 +1147,34 @@ private:
|
|||
Float64* outCurrentSampleInTimeLine, Boolean* outIsCycling,
|
||||
Float64* outCycleStartBeat, Float64* outCycleEndBeat)
|
||||
{
|
||||
AudioPlayHead* const ph = getPlayHead();
|
||||
AudioPlayHead::CurrentPositionInfo result;
|
||||
|
||||
if (ph != nullptr && ph->getCurrentPosition (result))
|
||||
if (AudioPlayHead* const ph = getPlayHead())
|
||||
{
|
||||
setIfNotNull (outIsPlaying, result.isPlaying);
|
||||
AudioPlayHead::CurrentPositionInfo result;
|
||||
|
||||
if (outTransportStateChanged != nullptr)
|
||||
if (ph->getCurrentPosition (result))
|
||||
{
|
||||
*outTransportStateChanged = result.isPlaying != wasPlaying;
|
||||
wasPlaying = result.isPlaying;
|
||||
setIfNotNull (outIsPlaying, result.isPlaying);
|
||||
|
||||
if (outTransportStateChanged != nullptr)
|
||||
{
|
||||
*outTransportStateChanged = result.isPlaying != wasPlaying;
|
||||
wasPlaying = result.isPlaying;
|
||||
}
|
||||
|
||||
setIfNotNull (outCurrentSampleInTimeLine, result.timeInSamples);
|
||||
setIfNotNull (outIsCycling, result.isLooping);
|
||||
setIfNotNull (outCycleStartBeat, result.ppqLoopStart);
|
||||
setIfNotNull (outCycleEndBeat, result.ppqLoopEnd);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
setIfNotNull (outCurrentSampleInTimeLine, result.timeInSamples);
|
||||
setIfNotNull (outIsCycling, false);
|
||||
setIfNotNull (outCycleStartBeat, 0);
|
||||
setIfNotNull (outCycleEndBeat, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
setIfNotNull (outIsPlaying, false);
|
||||
setIfNotNull (outTransportStateChanged, false);
|
||||
setIfNotNull (outCurrentSampleInTimeLine, 0);
|
||||
setIfNotNull (outIsCycling, false);
|
||||
setIfNotNull (outCycleStartBeat, 0);
|
||||
setIfNotNull (outCycleEndBeat, 0);
|
||||
}
|
||||
|
||||
setIfNotNull (outIsPlaying, false);
|
||||
setIfNotNull (outTransportStateChanged, false);
|
||||
setIfNotNull (outCurrentSampleInTimeLine, 0);
|
||||
setIfNotNull (outIsCycling, false);
|
||||
setIfNotNull (outCycleStartBeat, 0.0);
|
||||
setIfNotNull (outCycleEndBeat, 0.0);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
|
@ -1188,7 +1188,7 @@ private:
|
|||
}
|
||||
|
||||
static OSStatus renderMidiOutputCallback (void* hostRef, const AudioTimeStamp*, UInt32 /*midiOutNum*/,
|
||||
const struct MIDIPacketList* pktlist)
|
||||
const MIDIPacketList* pktlist)
|
||||
{
|
||||
return static_cast<AudioUnitPluginInstance*> (hostRef)->renderMidiOutput (pktlist);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue