Increasing getLatencySamples() introduces a long "tail" after playback is stopped

Hello, I am new to plugin development. I am making a TapeStop plugin which emulates the sound warping you would get if you were to switch off a reel-to-reel machine while it’s playing and let it spin down, and then start it again. In order to do so the plugin needs to “look into the future”, especially when the “tape” needs to start again.

As a way to achieve this I introduced a large internal FIFO (and the associated latency), and to get the the audio properly realigned by the DAW (Reaper) I set getLatencySamples() to return the length of my FIFO.

This works great, however now, when I stop the playback (by pressing “space” again) the audio in Reaper keeps playing for a duration equal to the length of the FIFO. Any idea how to avoid that? Perhaps I should recognize somehow that the playback stopped and actively mute the output in my plugin?

You can check the process context if the transport is playing or not.

That’s perfect, thanks for the on-point tip. By the way while we are here, how does getTailSamples() come into play in all this? When is it needed exactly and does it have anything to do with a plugin’s latency?

The tail is different than the latency. With the tail the plug-in informs the host that after certain amount of samples if the input is silence, the plug-in will produce silence too… for delay or reverb for example. The host could use this information for guarantying that no processed audio will be cut (the reverb tail) in an offline processing for example.