Getting BPM and Beats


#1

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.


#2

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


#3

I used this in PluginProcessor.h

  AudioPlayHead::CurrentPositionInfo playHead;

and in PluginProcessor.cpp (inside processBlock)

DBG(String(playHead.bpm));

and I keep getting 0.

I'm using Logic as DAW.


#4

get a look at the AudioPlayHead documentation.

you got to do something like that  :


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

 

 

 

 

 


#5

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.


#6

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

- in the .h :

private:
    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
    
 


#7

Great! Thanks a lot!