From 9e84707f937ba14a51cfca4e13e633af9cd67356 Mon Sep 17 00:00:00 2001 From: Armin Date: Thu, 13 Aug 2026 16:37:56 +0200 Subject: [PATCH] Fix filter type dropdown emptying when selecting LP 48dB The APVTS parameterChanged callback delivers the parameter's denormalised value, which for an AudioParameterChoice is the choice index, not a normalised 0..1 value. The handler was multiplying it by (numItems - 1), so LP 48dB (index 8) produced itemId 65 and cleared the box. Map the received index straight to itemId (index + 1). --- Source/PluginEditor.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 {