Set AudioPlayHead position


#1

Is there a simple way to derive from AudioPlayHead that allows us to set the DAW’s playhead position, while still retaining the DAW’s ability to start/stop playback natively? Ideally, I would like to be able to call something like setPlaybackPosition once, and the playhead continues moving from that point automatically.

It seems like if I tell the AudioProcessor to use a custom AudioPlayHead, I have to fill out the CurrentPositionInfo myself, without the possibility to get the current playback position provided by the DAW and change it only if I need to. Is this assessment correct? Do I really need to take control of the entire Playhead, incrementing the current sample time etc. myself?


#2

I don’t think seeking in the host’s timeline is part of the standard plugin APIs (at least most of them), so it would not be supported by JUCE.


#3

Forgive me if I’m wrong, but to me it looks like the JUCE implementations for each format use getPlayHead()->getCurrentPosition() to modify the host parameters accordingly, at least for VST and AU plugins:


#4

Those are the implementations in JUCE for hosting those plugin formats, not the plugin client code. (Which allows JUCE AudioProcessors to run as VST, AU etc plugins.)

The plugin client codes are located at :

JUCE\modules\juce_audio_plugin_client

#5

Thanks for the clarification. Wouldn’t the code inside the hosting code imply that manipulating the host’s timeline position would be possible at least in VST and AU plugins?

Waves plugins (e.g. Waves Tune) pull this off using their “ReWire” technology. I’m not sure how that works, but it shows that it’s possible in one way or the other.

Edit: I just realized that ReWire is not a Waves technology. I got confused by them having a “Waves ReWire” utility plugin. I’ve researched this a bit, and according to Jules, getting it to work is a “PITA”, so I probably won’t bother with that for now.


#6

The vstHostTime struct that is manipulated in the JUCE VST2 plugin hosting code is the struct that is passed for the hosted VST2 plugin when the plugin requests for it. The time position info is never read back from the struct, so even if the plugin tried manipulating the data, nothing would happen in the JUCE hosting code. It is theoretically possible some other host could detect the position info was changed by the plugin and then seek on its timeline but I would not expect that to happen with any commonly known host. (If that actually was something that could be expected work, JUCE probably would have added support in the AudioPlayHead class.)


#7

That makes full sense. Thank you for your help!


#8

This is the best implementation I could find online of getting bpm without errors!


#9

Update: I’ve implemented setting the playhead position using the ReWire protocol. Yes, it was a PITA. No, I can’t recommend it to anyone unless they really really need it.