I’m a bit confused as to how to use the AudioPlayHead. What component is ultimately responsible for filling in the AudioPlayHead::CurrentPositionInfo? In particular, who updates the sample position (VSTTimeInfo::samplePos)?
I’ve traced the plug-in host with the demo plugin through VSTPluginInstance::processBlock and it calls AudioPlayHead::getCurrentPosition which after a couple of callbacks gets to VSTPluginInstance::handleCallback. The invocation chain ends in this method’s audioMasterGetTime case: it returns vstHostTime, an instance of VSTTimeInfo, owned by the VSTPluginInstance.
Now vstHostTime is updated during VSTPluginInstance::processBlock which, if it has one, updates its own AudioPlayHead and then fills in various fields in vstHostTime from AudioPlayHead::CurrentPositionInfo. Alas, VSTPluginInstance::getPlayHead returns 0.
The consequence of VSTPluginInstance not having an AudioPlayHead is that ppqPosition and related fields don’t get filled in. Only the nanoSeconds field is updated (from the Windows multimedia clock).
Finally, the original AudioPlayHead that gets passed in to the filter is the instance of the VSTWrapper class that gets created when the filter is loaded. Thus there is a different AudioPlayHead for each filter loaded by the host.
My questions (among others):
Why is VSTPluginInstance::playHead mentioned in the 3rd paragraph null?
Who updates VSTTimeInfo::samplePos?
How do you synchronize the multiple instances of AudioPlayHead.
Should a more accurate clock (like the high performance timer) be used to update VSTTimeInfo::nanoSeconds?
My guess is that the answers involve the audioMasterCallback which I thought would be a callback to the host. But this callback just goes back to the VSTPluginInstance.
Another piece of the puzzle is that some component needs to act as a transport and implement a play function from which a zero point for the sample position can be established. The logical place would be the filter graph since it touches all the loaded plugins.
Any help in clearing up the confusion will be greatly appreciated.