Parameter being created more than once without my consent

So, I was debugging something else in my new fancy dp synth (that is what I am calling it for now mostly because I like the way the letters look), and I ran into a weird situation. Embarrassingly, I am stumped despite this likely being very simple to resolve.

Creating the following parameter (what I thought to be) once in the main processor class of this plugin apparently is creating this > 1 time. Or so the jassert in the AudioProcessor class would have one believe…

static const String pMethod ("pMethod");
jassert(paramNotCreatedYet(pMethod)==true);  // checks with getParameter()==nullptr
params.createAndAddParameter(pMethod, "pMethod", TRANS("Gen Mthd"),
                             NormalisableRange<float> (0.0f, 1.0f, 1.0f), 0.0,
                             nullptr, nullptr,
                             false, true, false,
                             AudioProcessorParameter::genericParameter);

Running in DEBUG mode, the result is shown below.

I could just ignore it as not using DEBUG, the plug does work, but that somehow seems the wrong move. Any thoughts that may point me in the right direction?

Can you share the whole Processor constructor please?
Also, you didn’t accidentally declare your state as static?

Good luck

Sure, thank you Daniel…though there is not much more.

DpSynthAudioProcessor::DpSynthAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
 : AudioProcessor (BusesProperties()
                 #if ! JucePlugin_IsMidiEffect
                  #if ! JucePlugin_IsSynth
                   .withInput  ("Input",  AudioChannelSet::stereo(), true)
                  #endif
                   .withOutput ("Output", AudioChannelSet::stereo(), true)
                 #endif
                   )
#endif
, undoManager(3000, 30), params(*this, &undoManager) {

static const String pMethod ("pMethod");
jassert(paramNotCreatedYet(pMethod) == true);
params.createAndAddParameter(pMethod, "pMethod", TRANS("Gen Mthd"),
                             NormalisableRange<float> (0.0f, 1.0f, 1.0f), 0.0,
                             nullptr, nullptr,
                             false, true, false,
                             AudioProcessorParameter::genericParameter);

initialiseSynth();
params.state = ValueTree(String("ValueTreeState"));
params.undoManager->clearUndoHistory();
params.undoManager->redo();
setLastUIWidth(920);
setLastUIHeight(648);
}

Uhm, so what is the clearHistory and redo doing there?
Could the redo actually repeat the adding the parameter…?

Try what happens, if you get rid of it.
Also, you just created the undoManager, the history should be clear anyway.
That you are actually able to call redo at this point looks to me like something buggy though… but I didn’t investigate deeper…

Good luck

I don’t know why those were there…copy/paste from somewhere…then must have stopped thinking.

Anyway, I removed those and I am getting the same error. To make things more odd, I looked for “pMethod” everywhere else in the code and can not find it.

Edit: After cleaning the build files (by manually deletion), this problem went away. Thank you Daniel for pointing out something that probably would have caused problems in the future. :slight_smile: