简体   繁体   English

VST音频插件如何检测来自VST主机的流中断?

[英]How can VST audio plugin detect stream interrupts from VST host?

I have developed a simple VST plugin. 我开发了一个简单的VST插件。 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. 现在,如果我在某些媒体播放器中使用此插件(例如带有VST包装器的Foobar插件),并且使用搜索栏跳到歌曲中的某个位置,或者切换到新歌曲,我仍然会听到以前音频的尾声。

Is there any VST callback or something that gets called to notify plugin about such stream interrupts? 是否有任何VST回调或被调用以通知插件有关此类流中断的内容?

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. 当传输停止和开始时,主机应分别调用插件的suspend()resume() In those calls, you can then ask the plugin for its playback state by calling getTimeInfo() (which is declared in audioeffectx.h). 在这些调用中,您可以通过调用getTimeInfo() (在audioeffectx.h中声明getTimeInfo()来询问插件的播放状态。 You can pass the kVstTransportChanged and kVstTransportPlaying flags to have your plugin react accordingly to transport changes. 您可以传递kVstTransportChangedkVstTransportPlaying标志,以使您的插件对传输更改做出相应的反应。

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. 我不确定查询过程中的时间信息会消耗多少CPU,但是您可以尝试在其中进行查询,以查看主机是否在安排中跳跃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM