1

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?

JustAMartin
  • 13,165
  • 18
  • 99
  • 183

1 Answers1

3

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.

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
  • It seems that foobar VST is "naughty" and calls resume() only when audio format changes but not when stream/song changes. But thanks for the time info idea, I'll try that. – JustAMartin Aug 04 '11 at 07:37
  • Come to think of it, I remember working on a big VST plugin before which asked for transport info in `process()`, so maybe it's not such a big deal. But I guess as a general rule, don't forward optimize... if that call is what you need to make your plugin work, implement it and then benchmark it afterwards. ;) – Nik Reiman Aug 04 '11 at 07:41
  • Ohh, getTimeInfo() returns NULL always, it seems this particular Foobar VST wrapper does not give anything useful. I hope some other hosts will be better. – JustAMartin Aug 04 '11 at 09:09
  • 1
    Hmm, that's probably because it's not a proper sequencer as such. But they definitely should provide at least rudimentary playback info. Maybe you can ask the community somehow and/or file a bug report with them? – Nik Reiman Aug 04 '11 at 09:41