iPlug2 / iPlug2

C++ Audio Plug-in Framework for desktop, mobile and web
https://iplug2.github.io
Other
1.91k stars 285 forks source link

Faust-based AUv2 plug-in parameters are reset after clicking stop/play in DAW #582

Closed gorborukov closed 4 years ago

gorborukov commented 4 years ago

After adjusting the AUv2 plug-in parameters and stopping the DAW playhead, the plug-in parameters are reset to the default Faust dsp code values (this is noticeable if I start the playhead again, but visually the position of the knobs does not change). It is not very good that the user has to adjust the parameters each time again. This problem is not observed in VST3 plug-in (tested in Live 10), but is present in the AudioUnit v2 (Logic Pro X 10.5, macOS Catalina).

example from project with parameter control initialization:

... (const InstanceInfo& info)
: Plugin(info, MakeConfig(kNumParams, 1))
{
  GetParam(kDecay)->InitDouble("Decay", 0.8, 0.5, 1.0, 0.01, "ms"); 
#if IPLUG_DSP
  mFaustProcessor.SetMaxChannelCount(MaxNChannels(ERoute::kInput), MaxNChannels(ERoute::kOutput));
  mFaustProcessor.Init();
  mFaustProcessor.CompileCPP();
  mFaustProcessor.SetAutoRecompile(true);
#ifndef FAUST_COMPILED
  mFaustProcessor.SetCompileFunc([&](){
    OnParamReset(EParamSource::kRecompile);
  });
#endif
#endif

#if IPLUG_EDITOR
  mMakeGraphicsFunc = [&]() {
    ...
    pGraphics->AttachControl(new IBKnobControl(b.GetCentredInside(64).GetVShifted(169).GetHShifted(-144), knobBitmap, kDecay));
    ...
  };
#endif
}

I will be grateful for any help on storing parameters without resetting.

olilarkin commented 4 years ago

Why don't you try to fix the bug? We like PRs...

olilarkin commented 4 years ago

turns out this was quite an easy fix