Hello!
I’m building the VST version of my looper app, and running up against a brick wall: in order to sync with external events, like incoming UI events or OSC messages, or Ableton Link synchronisation, I need access to the system time (host ticks) from the audio processor. Ableton Link, for instance, works in beats and in host ticks, so it’s the only way to perform sync. Incoming UI and OSC messages don’t have access to any other time base than the system time, so it’s the only way to sync with those too, unless I’m willing to accept only buffer-level timing accuracy (not really acceptable for a looper).
However, at least in Ableton Live, despite returning kNeedSystemTime in getProcessContextRequirements, the kSystemTimeValid flag is never set in the ProcessContext passed to the processor, and system time is always zero. Worse, although I haven’t tried it myself, in FL Studio, the system time is passed in, but it wraps around every 4.2ms because the 64-bit value’s being truncated to 32 bits!
I’ve experimented with generating my own estimate of the system time by fetching the current time initially (using mach_absolute_time, for instance, on macOS), and incrementing it by the frame size each call. However, this drifts quite badly, and just doesn’t appear workable. Similarly, just fetching the system time with mach_absolute_time/etc whenever I need it leads to jitter nastiness and general inaccuracy, because the time the code is running isn’t the same as the audio presentation time.
I can’t imagine my needs are particularly unique here, syncing with UI events/etc: what am I missing? How do I access the system time from the audio processor?
I see that 3.7.9 of the VST SDK introduces Vst::IComponentHandlerSystemTime (“API to query the system time from the controller.”); might this provide the solution? I notice it says “controller” rather than “host”, so I’m not sure how that helps.
I’m furiously crossing my fingers that I’m not going to have to go hounding all the DAW developers begging them to pass in the system time
At this point, my plan B is to basically create a separate audio engine running within the VST to provide the system timestamps, but that feels dreadful.
Many thanks in advance!
Michael