Can sample rate change?

We noticed that when loading a saved session, our parameters update the DSP code, and then at some point prepareToPlay() is called (again). This particular plugin resets some filters when this happens, which causes some data related to the parameters to be reset. What is the correct way to handle that?

I thought, well why not just skip resetting the sample rate and its related filters if the sample rate doesn’t change? That does indeed fix this particular issue with this plugin, but I wonder if it’s the correct thing to do, and if it is sufficient for all cases.

For example, if the sample rate were to change (somehow?), then we’d be in the same boat, with the parameter-related filters being reset to their defaults.

If that is something that might actually happen, then what it looks like I’d need to do is, any time the sample rate has changed, I’d need to re-generate the filters based on the current parameter settings. Is that standard practice? I don’t recall ever having to do that in a plugin before (but maybe I should have?).

Looks like I answered my own question. In Studio One, after instantiating a plugin, I can go to Song Setup and change the sample rate for the song there, which leads to prepareToPlay() being called. So I need to review any plugins that generate data based on sample rate, and make sure they re-generate their values correctly, not simply reset them to defaults.