Merge pull request #44 from yokemura/refactor/getBpm

Fixed:  getCurrentPosition is deprecated
This commit is contained in:
Takeshi Yokemura 2024-01-14 22:46:43 +09:00 committed by GitHub
commit d1b4654e2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -241,15 +241,10 @@ void Magical8bitPlug2AudioProcessor::setupVoice()
double Magical8bitPlug2AudioProcessor::getCurrentBPM() double Magical8bitPlug2AudioProcessor::getCurrentBPM()
{ {
auto ph = getPlayHead(); double bpm { 120 }; // default fallback when host does not provide info
if (ph == NULL) if (auto bpmFromHost = *getPlayHead()->getPosition()->getBpm())
{ bpm = bpmFromHost;
return 120.0; return bpm;
}
juce::AudioPlayHead::CurrentPositionInfo result;
ph->getCurrentPosition(result);
return result.bpm > 0 ? result.bpm : 120.0;
} }
//============================================================================== //==============================================================================