From 3c4c9fc3b4ea8ea8ce9ad96a3d01d110ad169df9 Mon Sep 17 00:00:00 2001 From: EvilDragon Date: Wed, 19 Jul 2023 15:57:56 +0200 Subject: [PATCH] Add Mute scene option in context menu of scene Volume parameter (#7102) * Add Mute scene option in context menu of scene Volume parameter --- src/common/Parameter.cpp | 1 + src/common/SurgePatch.cpp | 2 ++ src/common/SurgeStorage.h | 2 +- src/common/SurgeSynthesizer.cpp | 9 +++++++++ src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp | 14 +++++++++++--- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/common/Parameter.cpp b/src/common/Parameter.cpp index 4e806f812ce..9762dabc06b 100644 --- a/src/common/Parameter.cpp +++ b/src/common/Parameter.cpp @@ -339,6 +339,7 @@ bool Parameter::can_deactivate() const case ct_tape_speed: case ct_wstype: case ct_filtertype: + case ct_amplitude_clipper: return true; } return false; diff --git a/src/common/SurgePatch.cpp b/src/common/SurgePatch.cpp index c54c620c4d1..7d232f882ad 100644 --- a/src/common/SurgePatch.cpp +++ b/src/common/SurgePatch.cpp @@ -872,6 +872,7 @@ void SurgePatch::init_default_values() } scene[sc].volume.val.f = 0.890899f; + scene[sc].volume.deactivated = false; scene[sc].width.val.f = 1.f; // width scene[sc].mute_o2.val.b = true; @@ -2255,6 +2256,7 @@ void SurgePatch::load_xml(const void *data, int datasize, bool is_preset) { scene[sc].level_ring_12.deform_type = 0; scene[sc].level_ring_23.deform_type = 0; + scene[sc].volume.deactivated = false; } } diff --git a/src/common/SurgeStorage.h b/src/common/SurgeStorage.h index 8a6325fe101..8c02a9caef7 100644 --- a/src/common/SurgeStorage.h +++ b/src/common/SurgeStorage.h @@ -116,7 +116,7 @@ const int FIRoffsetI16 = FIRipolI16_N >> 1; // 19 -> 20 (XT 1.1 release) added voice envelope mode, but super late so don't break 19 // 20 -> 21 (XT 1.2 nightlies) added absolutable mode for Combulator Offset 1/2 (to match the behavior of Center parameter) // added oddsound_as_mts_main -// 21 -> 22 (XT 1.3 nighlies) added new ring modulator modes in the mixer, add bonsai distortion effect, changed MIDI mapping behavior +// 21 -> 22 (XT 1.3 nighlies) added new ring modulator modes in the mixer, add bonsai distortion effect, changed MIDI mapping behavior, deactivatable scenes // clang-format on const int ff_revision = 22; diff --git a/src/common/SurgeSynthesizer.cpp b/src/common/SurgeSynthesizer.cpp index 6194555cd63..6f25f8b4198 100644 --- a/src/common/SurgeSynthesizer.cpp +++ b/src/common/SurgeSynthesizer.cpp @@ -4452,6 +4452,7 @@ void SurgeSynthesizer::process() } iter = voices[s].begin(); + while (iter != voices[s].end()) { SurgeVoice *v = *iter; @@ -4459,7 +4460,15 @@ void SurgeSynthesizer::process() v->GetQFB(); // save filter state in voices after quad processing is done iter++; } + storage.modRoutingMutex.lock(); + + // mute scene + if (storage.getPatch().scene[s].volume.deactivated) + { + mech::clear_block(sceneout[s][0]); + mech::clear_block(sceneout[s][1]); + } } storage.modRoutingMutex.unlock(); diff --git a/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp b/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp index 7df19c360ee..1a3a78d8001 100644 --- a/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp +++ b/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp @@ -947,6 +947,7 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c } bool isGlobal = md < n_global_params; + // TODO: FIX SCENE ASSUMPTION bool isActiveScene = parameter->scene - 1 == activeScene; if ((isGlobal || isActiveScene || allScenes) && @@ -2591,15 +2592,22 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c bool isChecked = q->deactivated; - if (q->ctrltype == ct_envtime_linkable_delay) + switch (q->ctrltype) { + case ct_envtime_linkable_delay: txt = Surge::GUI::toOSCase("Link to Left Channel"); - } - else + break; + case ct_amplitude_clipper: + txt = Surge::GUI::toOSCase( + fmt::format("Mute Scene {:c}", 'A' + (p->scene - 1))); + break; + default: { isChecked = !isChecked; txt = Surge::GUI::toOSCase("Enabled"); } + break; + } contextMenu.addSeparator();