From 23e5b92de0c9a6d3f0a1426518fb9b662b0c1a79 Mon Sep 17 00:00:00 2001 From: EvilDragon Date: Sat, 22 Jan 2022 14:05:57 +0100 Subject: [PATCH] Add options for scene highpass slopes up to 48 dB/oct (#5762) Closes #1807 --- src/common/Parameter.cpp | 1 + src/common/SurgeStorage.h | 1 + src/common/SurgeSynthesizer.cpp | 32 ++++++++++++++----- src/common/SurgeSynthesizer.h | 5 ++- .../gui/SurgeGUIEditorValueCallbacks.cpp | 20 ++++++++++-- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/common/Parameter.cpp b/src/common/Parameter.cpp index ffa59a43b4a..e0301539738 100644 --- a/src/common/Parameter.cpp +++ b/src/common/Parameter.cpp @@ -361,6 +361,7 @@ bool Parameter::has_deformoptions() const { switch (ctrltype) { + case ct_freq_hpf: case ct_lfodeform: case ct_modern_trimix: case ct_alias_mask: diff --git a/src/common/SurgeStorage.h b/src/common/SurgeStorage.h index ce583d27917..db04cd48e66 100644 --- a/src/common/SurgeStorage.h +++ b/src/common/SurgeStorage.h @@ -167,6 +167,7 @@ enum deform_type type_1, type_2, type_3, + type_4, n_deform_types, }; diff --git a/src/common/SurgeSynthesizer.cpp b/src/common/SurgeSynthesizer.cpp index 7d6ce7b5398..1e764db1702 100644 --- a/src/common/SurgeSynthesizer.cpp +++ b/src/common/SurgeSynthesizer.cpp @@ -41,8 +41,11 @@ using namespace std; using CMSKey = ControllerModulationSourceVector<1>; // sigh see #4286 for failed first try SurgeSynthesizer::SurgeSynthesizer(PluginLayer *parent, const std::string &suppliedDataPath) - : storage(suppliedDataPath), hpA(&storage), hpB(&storage), _parent(parent), halfbandA(6, true), - halfbandB(6, true), halfbandIN(6, true) + : storage(suppliedDataPath), hpA{&storage, &storage, &storage, &storage}, hpB{&storage, + &storage, + &storage, + &storage}, + _parent(parent), halfbandA(6, true), halfbandB(6, true), halfbandIN(6, true) { switch_toggled_queued = false; audio_processing_active = false; @@ -2048,8 +2051,11 @@ void SurgeSynthesizer::allNotesOff() halfbandB.reset(); halfbandIN.reset(); - hpA.suspend(); - hpB.suspend(); + for (int i = 0; i < n_hpBQ; i++) + { + hpA[i].suspend(); + hpB[i].suspend(); + } for (int i = 0; i < n_fx_slots; i++) { @@ -3962,8 +3968,13 @@ void SurgeSynthesizer::process() auto freq = storage.getPatch().scenedata[0][storage.getPatch().scene[0].lowcut.param_id_in_scene].f; - hpA.coeff_HP(hpA.calc_omega(freq / 12.0), 0.4); // var 0.707 - hpA.process_block(sceneout[0][0], sceneout[0][1]); // TODO: quadify + auto slope = storage.getPatch().scene[0].lowcut.deform_type; + + for (int i = 0; i <= slope; i++) + { + hpA[i].coeff_HP(hpA[i].calc_omega(freq / 12.0), 0.4); // var 0.707 + hpA[i].process_block(sceneout[0][0], sceneout[0][1]); // TODO: quadify + } } if (storage.getPatch().scene[1].lowcut.deactivated == false) @@ -3971,8 +3982,13 @@ void SurgeSynthesizer::process() auto freq = storage.getPatch().scenedata[1][storage.getPatch().scene[1].lowcut.param_id_in_scene].f; - hpB.coeff_HP(hpB.calc_omega(freq / 12.0), 0.4); - hpB.process_block(sceneout[1][0], sceneout[1][1]); + auto slope = storage.getPatch().scene[1].lowcut.deform_type; + + for (int i = 0; i <= slope; i++) + { + hpB[i].coeff_HP(hpB[i].calc_omega(freq / 12.0), 0.4); // var 0.707 + hpB[i].process_block(sceneout[1][0], sceneout[1][1]); // TODO: quadify + } } for (int cls = 0; cls < n_scenes; ++cls) diff --git a/src/common/SurgeSynthesizer.h b/src/common/SurgeSynthesizer.h index 44c42b9bb67..3d9f2fdae98 100644 --- a/src/common/SurgeSynthesizer.h +++ b/src/common/SurgeSynthesizer.h @@ -381,7 +381,10 @@ class alignas(16) SurgeSynthesizer bool switch_toggled_queued, release_if_latched[n_scenes], release_anyway[n_scenes]; void setParameterSmoothed(long index, float value); - BiquadFilter hpA, hpB; // TODO: FIX SCENE ASSUMPTION (use std::array) + + static constexpr int n_hpBQ = 4; + + std::array hpA, hpB; // TODO: FIX SCENE ASSUMPTION (use std::array) bool fx_reload[n_fx_slots]; // if true, reload new effect parameters from fxsync FxStorage fxsync[n_fx_slots]; // used for synchronisation of parameter init diff --git a/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp b/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp index 303d5aaafcb..5afdb054174 100644 --- a/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp +++ b/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp @@ -1643,7 +1643,24 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c { switch (p->ctrltype) { + case ct_freq_hpf: + { + contextMenu.addSeparator(); + + contextMenu.addSectionHeader("SLOPE"); + for (int i = 0; i < synth->n_hpBQ; i++) + { + std::string title = fmt::format("{:d} dB/oct", 12 * (i + 1)); + + bool isChecked = p->deform_type == i; + + contextMenu.addItem(title, true, isChecked, + [this, p, i]() { p->deform_type = i; }); + } + + break; + } case ct_lfodeform: { auto q = modsource_editor[current_scene]; @@ -1658,8 +1675,7 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c for (int i = 0; i < lt_num_deforms[lfodata->shape.val.i]; i++) { - char title[32]; - sprintf(title, "Type %d", (i + 1)); + std::string title = fmt::format("Type {:d}", (i + 1)); bool isChecked = p->deform_type == i;