Getting BPM and Time Sig before process block

I know this is a long shot, but is there any way to fetch the bpm and time signature before the host has called the process block?
My plugin displays bpm and time signature information which in some hosts don’t get updated unless you hit play, i would like it to display the right bpm when the plugin loads without having the user press play.
Anyone have any idea?

I haven’t tried it, but perhaps AudioPlayHead::getCurrentPosition() could help you find this information? :slightly_smiling_face:

Edit: it’s not available in the constructor, but the following code works in prepareToPlay() (and elsewhere)…

AudioPlayHead::CurrentPositionInfo info;

No, you definitely shouldn’t rely on that being correct, or even working without crashing, it’ll depend entirely on the host. I can imagine that in some of them they may not expect the position call to happen from the same thread they use to call prepareToPlay, so unexpected things could happen.

The only safe place to call getCurrentPosition is in the process callback, I’m afraid.

Aww, apologies then for the false positive. Sad times.

Well, it could be the case that all hosts do handle this perfectly - I just wouldn’t want anyone to assume that’s the case, because there’s definitely no guarantee!

1 Like

I get garbage at prepare to play :frowning:
Is there any way to force a single process callback on launch?

How would that be possible? Think about it: hosts may create a plugin before it even knows what the sample rate, buffer size, tempo, etc are going to be.

With plugins you’ve got to take the attitude that you have very little control over what gets called, and just make your code robust enough to handle whatever gets thrown at it.

1 Like

i knew it would be a long shot, but was hoping someone had a trick up his sleve