From 0d3451f889578d4f37bd3a8e8b2f77bba881c440 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Tue, 24 Jan 2023 10:23:41 -0500 Subject: [PATCH] Optionally blanket ignore midi program change Since most of the time it won't do what you want if it does arrive make it an opt out. Keep the behavior unchanged though to 1.1 so we don't break people who had engineeredf around the deficiencies Closes #6803 --- src/common/SurgeSynthesizer.cpp | 6 ++++++ src/common/UserDefaults.cpp | 4 ++++ src/common/UserDefaults.h | 2 ++ src/surge-xt/gui/SurgeGUIEditor.cpp | 10 ++++++++++ 4 files changed, 22 insertions(+) diff --git a/src/common/SurgeSynthesizer.cpp b/src/common/SurgeSynthesizer.cpp index 8f54915bb7f..ae7bde9ec9e 100644 --- a/src/common/SurgeSynthesizer.cpp +++ b/src/common/SurgeSynthesizer.cpp @@ -1839,6 +1839,12 @@ void SurgeSynthesizer::polyAftertouch(char channel, int key, int value) void SurgeSynthesizer::programChange(char channel, int value) { + auto ignorePC = Surge::Storage::getUserDefaultValue( + &(storage), Surge::Storage::IgnoreMIDIProgramChange, false); + + if (ignorePC) + return; + PCH = value; // load_patch((CC0<<7) + PCH); patchid_queue = (CC0 << 7) + PCH; diff --git a/src/common/UserDefaults.cpp b/src/common/UserDefaults.cpp index f3e9d658e3a..af0481ee1c4 100644 --- a/src/common/UserDefaults.cpp +++ b/src/common/UserDefaults.cpp @@ -282,6 +282,10 @@ std::string defaultKeyToString(DefaultKey k) r = "focusModEditorAfterAddModulationFrom"; break; + case IgnoreMIDIProgramChange: + r = "ignoreMidiProgramChange"; + break; + case nKeys: break; } diff --git a/src/common/UserDefaults.h b/src/common/UserDefaults.h index 6025e12c2a9..a9ad306016c 100644 --- a/src/common/UserDefaults.h +++ b/src/common/UserDefaults.h @@ -127,6 +127,8 @@ enum DefaultKey FXUnitAssumeFixedBlock, FXUnitDefaultZoom, + IgnoreMIDIProgramChange, + nKeys }; diff --git a/src/surge-xt/gui/SurgeGUIEditor.cpp b/src/surge-xt/gui/SurgeGUIEditor.cpp index 4a9222ab49d..fc97a64673f 100644 --- a/src/surge-xt/gui/SurgeGUIEditor.cpp +++ b/src/surge-xt/gui/SurgeGUIEditor.cpp @@ -4641,6 +4641,16 @@ juce::PopupMenu SurgeGUIEditor::makeMidiMenu(const juce::Point &where) [this, p] { this->synth->storage.loadMidiMappingByName(p.first); }); } + midiSubMenu.addSeparator(); + bool igMID = Surge::Storage::getUserDefaultValue( + &(this->synth->storage), Surge::Storage::IgnoreMIDIProgramChange, false); + + midiSubMenu.addItem( + Surge::GUI::toOSCase("Ignore MIDI Program Change Messages"), true, igMID, [this, igMID]() { + Surge::Storage::updateUserDefaultValue(&(this->synth->storage), + Surge::Storage::IgnoreMIDIProgramChange, !igMID); + }); + return midiSubMenu; }