diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 4620adc..e3b19c5 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -218,6 +218,10 @@ private: // so the dropdown can be displayed in an order that differs from the // parameter's index order (e.g. LP 48dB listed under LP 24dB). This keeps // stored parameter indices meaningful while only reordering the menu. + // + // Note the value-basis split: the constructor reads the NORMALISED value + // via getValue(), while parameterChanged() receives the DENORMALISED + // value (the choice index itself). Both end at itemId = index + 1. class IndexedComboBoxAttachment : public juce::AudioProcessorValueTreeState::Listener, private juce::ComboBox::Listener { public: @@ -238,9 +242,13 @@ private: } void parameterChanged (const juce::String& parameterID, float newValue) override { - if (parameterID == paramId) - combo.setSelectedId (1 + juce::roundToInt (newValue * (combo.getNumItems() - 1)), - juce::dontSendNotification); + if (parameterID != paramId) + return; + // The APVTS delivers the parameter's DENORMALISED value here, which + // for an AudioParameterChoice is the choice index (not a normalised + // 0..1 value), so map it straight to the itemId (index + 1). + combo.setSelectedId (1 + juce::roundToInt (newValue), + juce::dontSendNotification); } void comboBoxChanged (juce::ComboBox* cb) override {