Getting DAW time information

Hi there!

So i have so far made a few (basic) VST plugins in JUCE, but the project i’m working on now requires me to get information about the plugin hosts time clock. Ive been struggling with this for some time now with this. The goal is to be able to sync the end of the midiout-sound from my plugin with a certain point in the timeline of the DAW.

I know i should be able to get this information with the AudioPlayHead class. But i cant seem to get it to work (i dont really understand how this class is supposed to work), and at this point am a bit lost. Could anyone maybe explain this to me or does anyone have a simple example on how to get information from the plugin host?

Maybe its really obvious what im supposed to do, but i just dont see it.

Ive already checked out this topic: Synchronizing VST with DAW MIDI Clock

Thanks a lot!

In your processBlock method, something like :

AudioPlayHead* phead = getPlayHead();
if (phead != nullptr)
{
AudioPlayHead::CurrentPositionInfo playposinfo;
phead->getCurrentPosition(playposinfo);
// use info from playposinfo
}

Note that depending on the plugin format and host you are running in, the position info may or may not be useful. You will just have to test how it behaves in various hosts with the different plugin formats. In the worst case you might not even be able to get the playhead object itself. (So that’s why there is the null pointer check.)

Thats it! Thanks so much. My mistake was not putting it in the processBlock.