I have developed a simple VST plugin. 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()andresume()when transport stops and starts, respectively. In those calls, you can then ask the plugin for its playback state by callinggetTimeInfo()(which is declared in audioeffectx.h). You can pass thekVstTransportChangedandkVstTransportPlayingflags 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.