We’re now trying to start building our JUCE 6 plugins against JUCE 7, but we ran into one issue. Basically, calling getCurrentPosition() on the playhead crashes the plugin immediately. Here’s the code that works perfectly when build with JUCE 6:
I am of course aware that this particular AudioPlayHead implementation is now deprecated, but anyway I wasn’t expecting a deprecated function to immediately crash. Other deprecated functions continue work well, after all. The plugin crashes with no DSP in it, just this code. If I comment out “playhead->getCurrentPosition(playheadInfo)”, it works perfectly, albeit with no transport sync.
Any help would be much appreciated!
playhead definitely non-null?
Indeed, it is actually null I wonder why? Did I miss something that is now required in order to set up the playhead? In JUCE 6, we would have this in the private section of the main class:
And then this in prepareToPlay():
playhead = getPlayHead();
Afterwards I can access the current playhead info struct just fine. And this has been working perfectly for us… but again, am I indeed missing some additional steps to get this going with JUCE 7? Appreciate your help.
The docs for
You can ONLY call this from your processBlock() method!
So I suspect that’s the problem.
Okay thanks for the advice! I did move getPlayHead() into the processBlock() call, and the actual playhead pointer is now not returning nullptr. And I can get the BPM, so at least this part is now sorted.
However… now I have an even more weird problem: playheadInfo.isPlaying is always false. I have the exact same plugin I can build with JUCE 6 and JUCE 7: with JUCE 6 playheadInfo.isPlaying is true when the DAW is playing, but with JUCE 7 playheadInfo.isPlaying is always false. Again, exact same source project, only getting it built against either JUCE 6 or 7. Any advice?
It is the same for me. I figured out that isPlaying, isLooping and isRecording are not set in getCurrentPosition:
bool getCurrentPosition (CurrentPositionInfo& result)
if (const auto pos = getPosition())
result.isPlaying = pos->getIsPlaying(); // This line is missing
result.isLooping = pos->getIsLooping(); // This line is missing
result.isRecording = pos->getIsRecording(); // This line is missing
Sorry about that, should be fixed now: