# Plugin Parameter Values Reset on Bypass

**URL:** <https://forum.juce.com/t/plugin-parameter-values-reset-on-bypass/21027>\
**Category:** General JUCE discussion\
**Created:** [February 18, 2017, 5:01pm UTC](https://forum.juce.com/t/plugin-parameter-values-reset-on-bypass/21027 "2017-02-18T17:01:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ncthom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ncthom/32/3721_2.png) [@ncthom](https://forum.juce.com/u/ncthom)\
**Post date:** [February 18, 2017, 5:01pm UTC](https://forum.juce.com/t/plugin-parameter-values-reset-on-bypass/21027/1 "2017-02-18T17:01:52Z")

</div>

Hey all,

I’ve come across a strange behavior with my plugin that I can’t really figure out: when I add my plugin to a given mixer track/effects slot, I can configure the parameters and make the effect sound the way I want to, then I can enable bypass in the host (tested in FL Studio and Renoise) and see the expected behavior, but then when I disable bypass in the host, my plugin resumes processing with the default parameter values, even though the GUI reflects the values I had previously set. As soon as I nudge a slider in my GUI the internal value snaps up to what the GUI is showing, but this means that enable/disable of the bypass in the host resets the internal state of my plugin to the default parameter settings, which is obviously undesirable.

Has anyone seen this? Did I miss some step of implementing the AudioProcessor interface?

Thank you!

---

<div class="post-metadata">

**Author:** ![ncthom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ncthom/32/3721_2.png) [@ncthom](https://forum.juce.com/u/ncthom)\
**Post date:** [February 18, 2017, 11:17pm UTC](https://forum.juce.com/t/plugin-parameter-values-reset-on-bypass/21027/2 "2017-02-18T23:17:55Z")

</div>

Ah ok, this was me being silly. I didn’t realize `prepareToPlay` was called when disabling host bypass (as in, re-enabling plugin processing).

I’ve updated my `prepareToPlay` method as follows:

```
if (m_lastKnownSampleRate == 0.0)
    for (int i = 0; i < m_dsps.size(); ++i)
        m_dsps.getUnchecked(i)->init(sampleRate); // init resets my internal parameters
else
    for (int i = 0; i < m_dsps.size(); ++i)
        m_dsps.getUnchecked(i)->instanceConstants(sampleRate); // instanceConstants does not

m_lastKnownSampleRate = sampleRate;

```

where `m_lastKnownSampleRate` is a member variable assigned to `0.0` when the class is instantiated.

Nevermind me 🙂
