Getting BPM and Beats

I spent hours trying to figure out how to get BPM and Beats from the host. I looked at the JuceDemoPlugin but I really don't understand how to port that into my plugin.

I just need to get BPM and Beats in my plug-in processBlock, what can I do? I understand that I have to use AudioPlayHead::CurrentPositionInfo but how?

Thanks in advance.

The BPM is given in CurrentPositionInfo::bpm (?)

I used this in PluginProcessor.h

  AudioPlayHead::CurrentPositionInfo playHead;

and in PluginProcessor.cpp (inside processBlock)


and I keep getting 0.

I'm using Logic as DAW.

get a look at the AudioPlayHead documentation.

you got to do something like that  :

AudioPlayHead playHead;
AudioPlayHead::CurrentPositionInfo currentPositionInfo;
playHead.getCurrentPosition (currentPositionInfo);






I'm trying to understand but I'm still a newbie with C++.

I tried as you said but I got this error on the first line

Field type 'juce::AudioPlayHead' is an abstract class.


Could you explain step by step what should I do? Thanks.

oh, yep. ok, so in your class that inherits from AudioProcessor :

- in the .h :

    AudioPlayHead* playHead;
    AudioPlayHead::CurrentPositionInfo currentPositionInfo;

and in .c, in your processBlock method :

playHead = this->getPlayHead();
playHead->getCurrentPosition (currentPositionInfo);
just after you can look at currentPositionInfo.bpm


Great! Thanks a lot!