
Since the DAW already contains BPM information, you should use the JUCE API to retrieve it.
void EulerDelayAudioProcessor::updateBpm(double& outBpm) noexcept
{
juce::AudioPlayHead* playhead = getPlayHead();
if(playhead==nullptr)
{
return;
}
auto positioninfo = playhead->getPosition();
if(!positioninfo)
{
return;
}
auto bpmFromDAW = positioninfo->getBpm();
if(bpmFromDAW)
{
outBpm = *bpmFromDAW;
}
}
getPlayHead()
AudioPlayHead::PositionInfo
getBpm()
std::optional ?
std::optional is a type that may or may not contain a value, and can be checked similarly to a pointer.
Since it holds an actual value inside, you can access it using *optional.
Because the return type can be complex, using auto makes the code simpler and more readable.