I am developing a delay-based plugin effect that utilizes a circular buffer (https://en.wikipedia.org/wiki/Circular_buffer) data structure; basically input is saved into an MyPlugin::AudioProcessor member array as it arrives and can be called up later to construct a delayed signal.
One issue I am having is that, if I turn the plugin “off” in the DAW (bypass it by host), and then later turn the plugin back on, all of the old stuff is still loaded into the circular buffer. I’d like to start over with a fresh buffer if the plugin is ever bypassed, but i’m not sure how to go about doing this.
I tried overwriting the processBlockBypassed() function to clear the circular buffer, but it seems that the host does not call this function when bypassing the plugin. I also tried having the buffer cleared on prepareToPlay(), but it seems that this is only called when the plugin is loaded the first time.
I suppose I can include my own bypass switch and encourage users to use this instead of turning the plugin off through the host, but would like to work around this if possible for better functionality.
Any ideas or workarounds? I am relatively inexperienced in c++ and this is my first JUCE program, so I apologize if I am polluting the forum with a trivial question. I appreciate the help in advance!