I try to inherit the audio player from the tutorialhttps://docs.juce.com/master/tutorial_looping_audio_sample_buffer.html
, and adding the extra rhythm detection methods to output the audio beats. Is it possible to implement the “AudioPlayHead::CurrentPositionInfo” in this AudioAppComponent?
According to the restriction in the function of “getplayhead()”, it must be involved in the “processBlock()”.
so I have built the AudioProcessor class, then try to evoke the “processBlock()” method in the function of “getNextAudioBlock()” in the AudioAppComponent class.
though, the result of “getplayhead()” eventually got the nullptr.
Is this due to no initialize method in the processor? or should I use the original audiodevecieManger to bond the new AudioProcessorPlayer?
**Eg_AudioAppComponent code:**
Eg_AudioProcessor m_processor;
void getNextAudioBlock (const juce::AudioSourceChannelInfo& bufferToFill) override
{
m_processor.processBlock(*currentAudioSampleBuffer, m_midi_buffer);
}
**Eg_AudioProcessor code:**
void Eg_AudioProcessor ::processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
buffer.clear();
AudioPlayHead* playHead = getPlayHead();
AudioPlayHead::CurrentPositionInfo currentPositionInfo;
if (playHead != nullptr)
{
playHead->getCurrentPosition(currentPositionInfo);
}
auto bpm = currentPositionInfo.bpm;
juce::Logger::getCurrentLogger()->writeToLog("bpm:\t" + (String)bpm);
}
