mirror of
https://codeberg.org/armin/chromaflock.git
synced 2026-09-01 04:10:47 +02:00
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).
This commit is contained in:
parent
9adb0244e9
commit
9e84707f93
1 changed files with 11 additions and 3 deletions
|
|
@ -218,6 +218,10 @@ private:
|
||||||
// so the dropdown can be displayed in an order that differs from the
|
// 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
|
// parameter's index order (e.g. LP 48dB listed under LP 24dB). This keeps
|
||||||
// stored parameter indices meaningful while only reordering the menu.
|
// 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,
|
class IndexedComboBoxAttachment : public juce::AudioProcessorValueTreeState::Listener,
|
||||||
private juce::ComboBox::Listener {
|
private juce::ComboBox::Listener {
|
||||||
public:
|
public:
|
||||||
|
|
@ -238,8 +242,12 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void parameterChanged (const juce::String& parameterID, float newValue) override {
|
void parameterChanged (const juce::String& parameterID, float newValue) override {
|
||||||
if (parameterID == paramId)
|
if (parameterID != paramId)
|
||||||
combo.setSelectedId (1 + juce::roundToInt (newValue * (combo.getNumItems() - 1)),
|
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);
|
juce::dontSendNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue