Skip to content

Commit

Permalink
Update juce plugin time related code for new APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Jul 15, 2022
1 parent f8d7d9a commit e48a222
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions source/backend/plugin/CarlaPluginJuce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class CarlaPluginJuce : public CarlaPlugin,

fMidiBuffer.ensureSize(2048);
fMidiBuffer.clear();
fPosInfo.resetToDefault();
}

~CarlaPluginJuce() override
Expand Down Expand Up @@ -1323,7 +1322,7 @@ class CarlaPluginJuce : public CarlaPlugin,

const EngineTimeInfo& timeInfo(pData->engine->getTimeInfo());

fPosInfo.isPlaying = timeInfo.playing;
fPosInfo.setIsPlaying(timeInfo.playing);

if (timeInfo.bbt.valid)
{
Expand All @@ -1334,16 +1333,17 @@ class CarlaPluginJuce : public CarlaPlugin,
const double ppqBeat = static_cast<double>(timeInfo.bbt.beat - 1);
const double ppqTick = timeInfo.bbt.tick / timeInfo.bbt.ticksPerBeat;

fPosInfo.bpm = timeInfo.bbt.beatsPerMinute;
fPosInfo.setBarCount(timeInfo.bbt.bar);
fPosInfo.setBpm(timeInfo.bbt.beatsPerMinute);

fPosInfo.timeSigNumerator = static_cast<int>(timeInfo.bbt.beatsPerBar);
fPosInfo.timeSigDenominator = static_cast<int>(timeInfo.bbt.beatType);
fPosInfo.setTimeSignature(TimeSignature{static_cast<int>(timeInfo.bbt.beatsPerBar+0.5f),
static_cast<int>(timeInfo.bbt.beatType+0.5f)});

fPosInfo.timeInSamples = static_cast<int64_t>(timeInfo.frame);
fPosInfo.timeInSeconds = static_cast<double>(fPosInfo.timeInSamples)/pData->engine->getSampleRate();
fPosInfo.setTimeInSamples(static_cast<int64_t>(timeInfo.frame));
fPosInfo.setTimeInSeconds(static_cast<double>(timeInfo.frame)/pData->engine->getSampleRate());

fPosInfo.ppqPosition = ppqBar + ppqBeat + ppqTick;
fPosInfo.ppqPositionOfLastBarStart = ppqBar;
fPosInfo.setPpqPosition(ppqBar + ppqBeat + ppqTick);
fPosInfo.setPpqPositionOfLastBarStart(ppqBar);
}

// --------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1597,10 +1597,7 @@ class CarlaPluginJuce : public CarlaPlugin,

juce::Optional<juce::AudioPlayHead::PositionInfo> getPosition() const override
{
/* TODO update to juce7 APIs
carla_copyStruct(result, fPosInfo);
*/
return {};
return fPosInfo;
}

// -------------------------------------------------------------------
Expand Down Expand Up @@ -1831,7 +1828,7 @@ class CarlaPluginJuce : public CarlaPlugin,

juce::AudioSampleBuffer fAudioBuffer;
juce::MidiBuffer fMidiBuffer;
CurrentPositionInfo fPosInfo;
PositionInfo fPosInfo;
juce::MemoryBlock fChunk;
juce::String fFormatName;

Expand Down

0 comments on commit e48a222

Please sign in to comment.