How can VST audio plugin detect stream interrupts from VST host?
I have developed a simple VST 开发者_如何学Goplugin. The plugin has an internal buffer with audio samples which should be cleared if audio stream gets interrupted.
Now if I use this plugin in some media player (like Foobar with VST wrapper plugin) and I use the seek bar to skip to some position in the song or I switch to a new song, I still hear tail of previous audio.
Is there any VST callback or something that gets called to notify plugin about such stream interrupts?
There isn't exactly a notification hook, but it is pretty easy to see if playback has started or stopped. The host should call your plugin's suspend()
and resume()
when transport stops and starts, respectively. In those calls, you can then ask the plugin for its playback state by calling getTimeInfo()
(which is declared in audioeffectx.h). You can pass the kVstTransportChanged
and kVstTransportPlaying
flags to have your plugin react accordingly to transport changes.
However, some hosts might be naughty and not suspend/resume when simply changing the playback position but not transport state. I'm not sure how CPU costly it is to query the time info during process, but you can try doing so there in order to see if the host is jumping around in the arrangement.
精彩评论