From f0a52618dc68fe0698e865fdb0d10617ffabf5c3 Mon Sep 17 00:00:00 2001 From: EvilDragon Date: Tue, 12 Apr 2022 23:07:13 +0200 Subject: [PATCH] Rename a few APIs (#6056) Closes #5569 --- doc/FX Lifecycle.md | 117 +++++++++--------- scripts/ipy/Demonstrate Surge in Python.ipynb | 6 +- src/common/SurgeSynthesizer.cpp | 20 +-- src/common/SurgeSynthesizer.h | 17 +-- src/common/SurgeSynthesizerIO.cpp | 4 +- src/surge-python/surgepy.cpp | 14 +-- src/surge-testrunner/UnitTestsFX.cpp | 22 ++-- src/surge-testrunner/UnitTestsLUA.cpp | 16 +-- src/surge-testrunner/UnitTestsMIDI.cpp | 2 +- src/surge-testrunner/UnitTestsMOD.cpp | 18 +-- src/surge-xt/SurgeSynthProcessor.cpp | 2 +- src/surge-xt/gui/SurgeGUIEditor.cpp | 10 +- src/surge-xt/gui/SurgeGUIEditor.h | 4 +- .../gui/SurgeGUIEditorValueCallbacks.cpp | 10 +- .../gui/overlays/ModulationEditor.cpp | 6 +- src/surge-xt/gui/overlays/TypeinParamEditor.h | 2 +- 16 files changed, 136 insertions(+), 134 deletions(-) diff --git a/doc/FX Lifecycle.md b/doc/FX Lifecycle.md index 91724e4dec6..481c6bb8cb4 100644 --- a/doc/FX Lifecycle.md +++ b/doc/FX Lifecycle.md @@ -1,43 +1,42 @@ -# FX Lifecycle +# Effects Lifecycle -This documents how FX are created, swapped, initialized, etc... as of -8e03ba0b54b09 or so. +This documents how effects are created, swapped, initialized, etc... as of commit `8e03ba0b54b09` or so. -There's lots of cases. Lets enumerate all of them +There's lots of cases. Let's enumerate all of them: ## Core data structures and Functions -* `spawn_effect` creates an instance of an Effect with the appropriate type bound to a storage and data +* `spawn_effect` creates an instance of an `Effect` with the appropriate type bound to a storage and data * `loadFx` compares the synth state with the runtime state and optionally reloads effects * the first argument `initp` if true means the new effect calls `init_default_values` and if false just forces all params within their default ranges - * the second `force_reload_all` makes all fx reload - * loadFX begins in all cases where a type switches setting all params to type 'none'. + * the second `force_reload_all` makes all effects reload + * `loadFx` begins in all cases where a type switches setting all params to type 'none'. * `loadFx` is called from three places - * synth::processThreadunsafeOperations if `load_fx_needed` is true with false/false - * synth::processControl if `load_fx_needed` with false/false - * synth::loadRaw in all cases with false/true (namely, force a full reload on patch load) - * If a reload of either form has changed, the `updateAfterReload()` virtual method is called on the FX -* `load_fx_needed` is a bool on SurgeSynth - * triggers a call to loadFx in processControlEV + * `synth::processAudioThreadOpsWhenAudioEngineUnavailable` if `load_fx_needed` is true with false/false + * `synth::processControl` if `load_fx_needed` with false/false + * `synth::loadRaw` in all cases with false/true (namely, force a full reload on patch load) + * If a reload of either form has changed, the `updateAfterReload()` virtual method is called on the effect +* `load_fx_needed` is a bool on `SurgeSynth` + * triggers a call to `loadFx` in `processControlEV` * set to true in the constructor of synth - * set to true on a setParameter01 of ct_fxtype (so automation path) - * set to false in loadFx - * set to true in SGE when you have a tag_fx_menu -* The patch has the `fx[n_fx]` array which holds the FXStorage pointers + * set to true on a `setParameter01` of `ct_fxtype` (so automation path) + * set to false in `loadFx` + * set to true in `SurgeGUIEeditor` when you have a `tag_fx_menu` +* The patch has the `fx[n_fx]` array which holds the `FXStorage` pointers * The synth has an `FXStorage *fxsync` which is malloced to `n_fx_slots * sizeof(FXStorage)`. This - object acts as an edit buffer for external editors who want to bulk update the type of objects. - * In the synth constructor it is set to the value of `patch.fx[i]` for each i - * In SurgeGUIEditor the fxsync is used as the storage which is edited by the CSnapshotMenu, not + object acts as an edit buffer for external editors which want to bulk update the type of objects. + * In the synth constructor it is set to the value of `patch.fx[i]` for each `i` + * In `SurgeGUIEditor` the `fxsync` is used as the storage which is edited by the `XMLConfiguredMenus`, not the patch buffer - * In `loadFX` - * if reloading an FX, copy from the sync to the patch. This defacto means "take the sync values as - they have been set by a UI" - * Similarly if fx_reload[s] is true, copy from the sync and syspend and init the FX + * In `loadFx` + * if reloading an effect, copy from the sync to the patch. This de facto means "take the sync values as + they have been set by the GUI" + * Similarly if `fx_reload[s]` is true, copy from the sync, thensuspend and initialize the effect * The slot `fx_reload[n_fx_slots]` - * This is set by SurgeGUIEditor primarily to force a reload of an FX in the event that the type has not changed + * This is set by `SurgeGUIEditor` primarily to force a reload of an effect in the event that the type has not changed -## Empty FX to Loaded FX, FX On +## Empty effect to loaded effect, effect enabled Spawn Effect is called twice @@ -60,62 +59,62 @@ Spawn Effect id=6 [ 6]: 6 Surge 0x0000000150640620 _ZN6AUBase9RenderBusERjRK14AudioTimeStampjj + 96 ``` -* CSnapshotMenu::loadSnapshot - * Load an FX and call `init_ctrltypes` and `init_default_values`. This sets up the params on the control to defaults - in the storage bound to the FX - * delete the FX - * Parse the XML and set the fxbuffer parameter values as described in the FX. This leaves the storage configured with - values and types but does not leave the synth with the FX setup - * raise a valueChanged so SurgeGuiEditor sets load_fx_needed to true. - * If audio_processing_active is false it also sets up the FX from the UI thread via the - call to synth->processThreadunsafeOperations() but we will ignroe that case in this document +* `XMLConfiguredMenus::loadSnapshot` + * Load an effect and call `init_ctrltypes` and `init_default_values`. This sets up the params on the control to defaults + in the storage bound to the effect + * delete the effect + * Parse the XML and set the `fxbuffer` parameter values as described in the effect. This leaves the storage configured with + values and types but does not leave the synth with the effect setup + * raise a `valueChanged` so `SurgeGUIEditor` sets `load_fx_needed` to true. + * If `audio_processing_active` is false it also sets up the effect from the UI thread via the + call to `synth->processAudioThreadOpsWhenAudioEngineUnavailable()`, but we will ignroe that case in this document from hereon out -* SurgeSynthesizer - * In the next `process()` and call to `processControl` `load_fx_needed` will be true - * so call `loadFx(false,false)` which will force FX where the type in the FX to be noticed as - changed and will spawn an fx +* `SurgeSynthesizer` + * In the next `process()` and call to `processControl`, `load_fx_needed` will be true + * so call `loadFx(false, false)` which will force effect where the type in the effect is to be noticed as + changed and will spawn an effect * but since `initp` is false, don't call `init_default_values` and instead continue to use the values - left lingering in the FX from the invocation in CSnapshotMenu. + left lingering in the effect from the invocation in `XMLConfiguredMenus`. -## Loaded FX to Off, FX On +## Loaded effect to disabled, effect enabled -* CSnapshotMenu calls loadSnapshot with type 0 and null XML (fine). -* This sets the valtype to 0 and then SGE gets the message +* `XMLConfiguredMenus` calls `loadSnapshot` with type 0 and null XML (fine). +* This sets `valtype` to 0 and then `SurgeGUIEditor` gets the message * Question: What sets the types to none everywhere? -## Empty FX to Loaded FX, FX Bypassed +## Empty effect to loaded effect, effect bypassed -## Active FX to New preset of Same Type, FX On +## Active effect to new preset of same type, effect on -* CSnapshotMenu +* `XMLConfiguredMenus` -## Active FX to New FX of Different Type, FX On +## Active effect to new effect of different type, effect on -## Active FX to New FX, FX Bypassed +## Active effect to new effect, effect bypassed Question: is bypass from CEG different than global bypass? -## Load a patch with FX Off +## Load a patch with effect off -## Load a patch with active FX +## Load a patch with active effect -## Load a User FX setting +## Load a User effect setting -* CFXMenu::loadUserPreset looks like loadSnapshot in that it creates a new FX on the sync buffer, applies the value - from the preset, and raises the event +* `FXMenu::loadUserPreset` looks like `loadSnapshot` in that it creates a new effect on the sync buffer, applies the value + from the preset, and raises an event * After that it's just like a same-type load -## Swap an FX +## Swap an effect -## An Airwindows FX is activated and changes type +## An Airwindows effect is activated and changes type -## An Airwindows FX is de-activated and changes type +## An Airwindows effect is deactivated and changes type -## A non-Airwindows FX becomes an Airwindows FX in activated state +## A non-Airwindows effect becomes an Airwindows effect in activated state -## A non-Airwindow FX becomes an Airwindows FX in deactivated state +## A non-Airwindow effect becomes an Airwindows effect in deactivated state -## The DAW Automation Path +## The DAW automation path The DAW automation path comes in through `synth::setParameter01` and handles the `ct_fxtype` to do the spawn-and-replace. See the comments there for more. \ No newline at end of file diff --git a/scripts/ipy/Demonstrate Surge in Python.ipynb b/scripts/ipy/Demonstrate Surge in Python.ipynb index e0167a44a8f..93448f9f0ca 100644 --- a/scripts/ipy/Demonstrate Surge in Python.ipynb +++ b/scripts/ipy/Demonstrate Surge in Python.ipynb @@ -475,7 +475,7 @@ "patches make extensive use of the modulation features. This python API allows you to\n", "query and set up modulation using the same API that the UI uses when in modulation armed mode.\n", "\n", - "The three key APIs we have are getModSource, setModulation and getModulation. So lets\n", + "The three key APIs we have are getModSource, setModDepth01 and getModDepth01. So lets\n", "make an ADSR with an LFO wiggle, and the constants have ms_ constants defined" ] }, @@ -521,12 +521,12 @@ "osc0lev = cg.getEntries()[0].getParams()[0]\n", "lfo1 = surge.getModSource(srgco.ms_lfo1)\n", "\n", - "surge.setModulation( osc0lev, lfo1, 0.1 )\n", + "surge.setModDepth01( osc0lev, lfo1, 0.1 )\n", "\n", "\n", "window = fourSecondsRMS( surge )\n", "plt.plot( window )\n", - "print( \"Modulation to osc0lev from lfo1 is: \", surge.getModulation( osc0lev, lfo1 ))" + "print( \"Modulation to osc0lev from lfo1 is: \", surge.getModDepth01( osc0lev, lfo1 ))" ] }, { diff --git a/src/common/SurgeSynthesizer.cpp b/src/common/SurgeSynthesizer.cpp index 59ca91084be..364a2aa1763 100644 --- a/src/common/SurgeSynthesizer.cpp +++ b/src/common/SurgeSynthesizer.cpp @@ -240,7 +240,7 @@ SurgeSynthesizer::SurgeSynthesizer(PluginLayer *parent, const std::string &suppl pid++; } if (patchid_queue >= 0) - processThreadunsafeOperations(true); // DANGER MODE IS ON + processAudioThreadOpsWhenAudioEngineUnavailable(true); // DANGER MODE IS ON patchid_queue = -1; } @@ -2350,8 +2350,10 @@ bool SurgeSynthesizer::setParameter01(long index, float value, bool external, bo int cge = p->ctrlgroup_entry; fxsync[cge].type.val.i = p->val.i; - p->val.i = oldval.i; // so funnily we want to set the value *back* so the loadFX - // picks up the change in fxsync + + // so funnily we want to set the value *back* so that loadFx picks up the change in + // fxsync + p->val.i = oldval.i; Effect *t_fx = spawn_effect(fxsync[cge].type.val.i, &storage, &fxsync[cge], 0); if (t_fx) { @@ -2577,7 +2579,7 @@ bool SurgeSynthesizer::loadFx(bool initp, bool force_reload_all) { for (auto &t : fxmodsync[s]) { - setModulation(storage.getPatch().fx[s].p[t.whichForReal].id, + setModDepth01(storage.getPatch().fx[s].p[t.whichForReal].id, (modsources)t.source_id, t.source_scene, t.source_index, t.depth); } @@ -3051,7 +3053,7 @@ bool SurgeSynthesizer::isModsourceUsed(modsources modsource) return modsourceused[modsource]; } -float SurgeSynthesizer::getModulation(long ptag, modsources modsource, int modsourceScene, +float SurgeSynthesizer::getModDepth01(long ptag, modsources modsource, int modsourceScene, int index) const { if (!isValidModulation(ptag, modsource)) @@ -3216,7 +3218,7 @@ void SurgeSynthesizer::clearModulation(long ptag, modsources modsource, int mods } } -bool SurgeSynthesizer::setModulation(long ptag, modsources modsource, int modsourceScene, int index, +bool SurgeSynthesizer::setModDepth01(long ptag, modsources modsource, int modsourceScene, int index, float val) { if (!isValidModulation(ptag, modsource)) @@ -3483,7 +3485,7 @@ void loadPatchInBackgroundThread(SurgeSynthesizer *sy) return; } -void SurgeSynthesizer::processThreadunsafeOperations(bool dangerMode) +void SurgeSynthesizer::processAudioThreadOpsWhenAudioEngineUnavailable(bool dangerMode) { if (!audio_processing_active || dangerMode) { @@ -4488,7 +4490,7 @@ void SurgeSynthesizer::reorderFx(int source, int target, FXReorderMode m) } auto depth = - getModulation(fxsync[source].p[whichForReal].id, (modsources)mv->at(i).source_id, + getModDepth01(fxsync[source].p[whichForReal].id, (modsources)mv->at(i).source_id, mv->at(i).source_scene, mv->at(i).source_index); fxmodsync[target].push_back({mv->at(i).source_id, mv->at(i).source_scene, mv->at(i).source_index, whichForReal, depth}); @@ -4510,7 +4512,7 @@ void SurgeSynthesizer::reorderFx(int source, int target, FXReorderMode m) } } - auto depth = getModulation(fxsync[target].p[whichForReal].id, + auto depth = getModDepth01(fxsync[target].p[whichForReal].id, (modsources)mv->at(i).source_id, mv->at(i).source_scene, mv->at(i).source_index); fxmodsync[source].push_back({mv->at(i).source_id, mv->at(i).source_scene, diff --git a/src/common/SurgeSynthesizer.h b/src/common/SurgeSynthesizer.h index 2fd80a8b957..53e0b26552b 100644 --- a/src/common/SurgeSynthesizer.h +++ b/src/common/SurgeSynthesizer.h @@ -95,13 +95,14 @@ class alignas(16) SurgeSynthesizer void resetStateFromTimeData(); void processControl(); /* - * processThreadunsafeOperations reloads a patch if the audio thread isn't running - * but if it is running lets the deferred queue handle it. But it has an option + * processAudioThreadOpsWhenAudioEngineUnavailable reloads a patch if the audio thread + * isn't running but if it is running lets the deferred queue handle it. But it has an option * which is *extremely dangerous* to force you to load in the current thread immediately. * If you use this option and dont' know what you are doing it will explode - basically * we only use it in the startup constructor path. */ - void processThreadunsafeOperations(bool doItEvenIfAudioIsRunningDANGER = false); + void + processAudioThreadOpsWhenAudioEngineUnavailable(bool doItEvenIfAudioIsRunningDANGER = false); bool loadFx(bool initp, bool force_reload_all); void enqueueFXOff(int whichFX); bool loadOscalgos(); @@ -279,22 +280,22 @@ class alignas(16) SurgeSynthesizer int index) const; /* - * setModulation etc take a modsource scene. This is only needed for global modulations + * setModDepth01 etc take a modsource scene. This is only needed for global modulations * since for in-scene modulations the parameter implicit in ptag has a scene. But for * LFOs modulating FX, we need to know which scene they originate from. See #2285 */ - bool setModulation(long ptag, modsources modsource, int modsourceScene, int index, float value); - float getModulation(long ptag, modsources modsource, int modsourceScene, int index) const; + bool setModDepth01(long ptag, modsources modsource, int modsourceScene, int index, float value); + float getModDepth01(long ptag, modsources modsource, int modsourceScene, int index) const; + float getModDepth(long ptag, modsources modsource, int modsourceScene, int index) const; void muteModulation(long ptag, modsources modsource, int modsourceScene, int index, bool mute); bool isModulationMuted(long ptag, modsources modsource, int modsourceScene, int index) const; - float getModDepth(long ptag, modsources modsource, int modsourceScene, int index) const; void clearModulation(long ptag, modsources modsource, int modsourceScene, int index, bool clearEvenIfInvalid = false); void clear_osc_modulation( int scene, int entry); // clear the modulation routings on the algorithm-specific sliders /* - * The modulation API (setModulation etc...) is called from all sorts of places + * The modulation API (setModDepth01 etc...) is called from all sorts of places * but mostly from the UI. This adds a listener which gets notified but this listener * should just post a message over to the UI thread and be quick in case there * are cases where the audio thread calls set/clear/mute modulation. diff --git a/src/common/SurgeSynthesizerIO.cpp b/src/common/SurgeSynthesizerIO.cpp index 13e89652330..546238cb043 100644 --- a/src/common/SurgeSynthesizerIO.cpp +++ b/src/common/SurgeSynthesizerIO.cpp @@ -129,7 +129,7 @@ void SurgeSynthesizer::jogPatch(bool increment, bool insideCategory) patchid_queue = storage.patchOrdering[order]; } - processThreadunsafeOperations(); + processAudioThreadOpsWhenAudioEngineUnavailable(); return; } @@ -169,7 +169,7 @@ void SurgeSynthesizer::jogCategory(bool increment) if (storage.patch_list[p].category == current_category_id) { patchid_queue = p; - processThreadunsafeOperations(); + processAudioThreadOpsWhenAudioEngineUnavailable(); return; } } diff --git a/src/surge-python/surgepy.cpp b/src/surge-python/surgepy.cpp index 27b7ec61363..bd26dce55f8 100644 --- a/src/surge-python/surgepy.cpp +++ b/src/surge-python/surgepy.cpp @@ -603,13 +603,13 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer void setModulationPy(const SurgePyNamedParam &to, SurgePyModSource const &from, float amt, int scene, int index) { - setModulation(to.getID().getSynthSideId(), (modsources)from.getModSource(), scene, index, + setModDepth01(to.getID().getSynthSideId(), (modsources)from.getModSource(), scene, index, amt); } float getModulationPy(const SurgePyNamedParam &to, const SurgePyModSource &from, int scene, int index) { - return getModulation(to.getID().getSynthSideId(), (modsources)from.getModSource(), scene, + return getModDepth01(to.getID().getSynthSideId(), (modsources)from.getModSource(), scene, index); } bool isValidModulationPy(const SurgePyNamedParam &to, const SurgePyModSource &from) @@ -745,7 +745,7 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer r.depth = gm.depth; r.source_scene = gm.source_scene; r.source_index = gm.source_index; - r.normalizedDepth = getModulation(gm.destination_id, (modsources)gm.source_id, + r.normalizedDepth = getModDepth01(gm.destination_id, (modsources)gm.source_id, gm.source_scene, gm.source_index); gmr.append(r); } @@ -768,7 +768,7 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer r.source_scene = gm.source_scene; r.source_index = gm.source_index; r.normalizedDepth = - getModulation(gm.destination_id + storage.getPatch().scene_start[sc], + getModDepth01(gm.destination_id + storage.getPatch().scene_start[sc], (modsources)gm.source_id, r.source_scene, r.source_index); sms.append(r); } @@ -786,7 +786,7 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer r.source_scene = gm.source_scene; r.source_index = gm.source_index; r.normalizedDepth = - getModulation(gm.destination_id + storage.getPatch().scene_start[sc], + getModDepth01(gm.destination_id + storage.getPatch().scene_start[sc], (modsources)gm.source_id, gm.source_scene, gm.source_index); smv.append(r); } @@ -916,11 +916,11 @@ PYBIND11_MODULE(surgepy, m) .def("getModSource", &SurgeSynthesizerWithPythonExtensions::getModSource, "Given a constant from surge.constants.ms_* provide a modulator object", py::arg("modId")) - .def("setModulation", &SurgeSynthesizerWithPythonExtensions::setModulationPy, + .def("setModDepth01", &SurgeSynthesizerWithPythonExtensions::setModulationPy, "Set a modulation to a given depth", py::arg("targetParameter"), py::arg("modulationSource"), py::arg("depth"), py::arg("scene") = 0, py::arg("index") = 0) - .def("getModulation", &SurgeSynthesizerWithPythonExtensions::getModulationPy, + .def("getModDepth01", &SurgeSynthesizerWithPythonExtensions::getModulationPy, "Get the modulation depth from a source to a parameter.", py::arg("targetParameter"), py::arg("modulationSource"), py::arg("scene") = 0, py::arg("index") = 0) .def("isValidModulation", &SurgeSynthesizerWithPythonExtensions::isValidModulationPy, diff --git a/src/surge-testrunner/UnitTestsFX.cpp b/src/surge-testrunner/UnitTestsFX.cpp index 69f825208a6..45d7d2cf44e 100644 --- a/src/surge-testrunner/UnitTestsFX.cpp +++ b/src/surge-testrunner/UnitTestsFX.cpp @@ -116,7 +116,7 @@ TEST_CASE("FX Move with Modulation", "[fx]") step(surge); setFX(surge, 0, fxt_combulator); - surge->setModulation(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); REQUIRE(surge->storage.getPatch().modulation_global.size() == 1); step(surge); @@ -136,9 +136,9 @@ TEST_CASE("FX Move with Modulation", "[fx]") setFX(surge, 0, fxt_combulator); setFX(surge, 4, fxt_chorus4); - surge->setModulation(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); - surge->setModulation(surge->storage.getPatch().fx[0].p[3].id, ms_slfo2, 0, 0, 0.2); - surge->setModulation(surge->storage.getPatch().fx[4].p[3].id, ms_slfo1, 0, 0, 0.3); + surge->setModDepth01(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[0].p[3].id, ms_slfo2, 0, 0, 0.2); + surge->setModDepth01(surge->storage.getPatch().fx[4].p[3].id, ms_slfo1, 0, 0, 0.3); REQUIRE(surge->storage.getPatch().modulation_global.size() == 3); step(surge); @@ -157,7 +157,7 @@ TEST_CASE("FX Move with Modulation", "[fx]") step(surge); setFX(surge, 0, fxt_combulator); - surge->setModulation(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); REQUIRE(surge->storage.getPatch().modulation_global.size() == 1); step(surge); @@ -177,8 +177,8 @@ TEST_CASE("FX Move with Modulation", "[fx]") setFX(surge, 0, fxt_combulator); setFX(surge, 1, fxt_chorus4); - surge->setModulation(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); - surge->setModulation(surge->storage.getPatch().fx[1].p[3].id, ms_slfo2, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[1].p[3].id, ms_slfo2, 0, 0, 0.1); step(surge); REQUIRE(surge->storage.getPatch().modulation_global.size() == 2); confirmDestinations(surge, {{0, 2}, {1, 3}}); @@ -198,8 +198,8 @@ TEST_CASE("FX Move with Modulation", "[fx]") setFX(surge, 0, fxt_combulator); setFX(surge, 1, fxt_chorus4); - surge->setModulation(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); - surge->setModulation(surge->storage.getPatch().fx[1].p[3].id, ms_slfo2, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[1].p[3].id, ms_slfo2, 0, 0, 0.1); step(surge); REQUIRE(surge->storage.getPatch().modulation_global.size() == 2); confirmDestinations(surge, {{0, 2}, {1, 3}}); @@ -219,8 +219,8 @@ TEST_CASE("FX Move with Modulation", "[fx]") setFX(surge, 0, fxt_combulator); setFX(surge, 1, fxt_chorus4); - surge->setModulation(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); - surge->setModulation(surge->storage.getPatch().fx[1].p[3].id, ms_slfo2, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[0].p[2].id, ms_slfo1, 0, 0, 0.1); + surge->setModDepth01(surge->storage.getPatch().fx[1].p[3].id, ms_slfo2, 0, 0, 0.1); step(surge); REQUIRE(surge->storage.getPatch().modulation_global.size() == 2); confirmDestinations(surge, {{0, 2}, {1, 3}}); diff --git a/src/surge-testrunner/UnitTestsLUA.cpp b/src/surge-testrunner/UnitTestsLUA.cpp index b19b025d925..f39203dde47 100644 --- a/src/surge-testrunner/UnitTestsLUA.cpp +++ b/src/surge-testrunner/UnitTestsLUA.cpp @@ -673,7 +673,7 @@ TEST_CASE("Simple Used Formula Modulator", "[formula]") auto surge = Surge::Test::surgeOnSine(); surge->storage.getPatch().scene[0].lfo[0].shape.val.i = lt_formula; auto pitchId = surge->storage.getPatch().scene[0].osc[0].pitch.id; - surge->setModulation(pitchId, ms_lfo1, 0, 0, 0.1); + surge->setModDepth01(pitchId, ms_lfo1, 0, 0, 0.1); surge->storage.getPatch().formulamods[0][0].setFormula(R"FN( function init(modstate) @@ -715,8 +715,8 @@ TEST_CASE("Voice Features and Flags", "[formula]") surge->storage.getPatch().scene[0].lfo[0].shape.val.i = lt_formula; surge->storage.getPatch().scene[0].lfo[6].shape.val.i = lt_formula; auto pitchId = surge->storage.getPatch().scene[0].osc[0].pitch.id; - surge->setModulation(pitchId, ms_lfo1, 0, 0, 0.1); - surge->setModulation(pitchId, ms_slfo1, 0, 0, 0.1); + surge->setModDepth01(pitchId, ms_lfo1, 0, 0, 0.1); + surge->setModDepth01(pitchId, ms_slfo1, 0, 0, 0.1); surge->storage.getPatch().formulamods[0][0].setFormula(R"FN( function init(modstate) @@ -762,8 +762,8 @@ end)FN"); surge->storage.getPatch().scene[0].lfo[6].shape.val.i = lt_formula; surge->storage.getPatch().scene[0].adsr[0].r.val.f = 2; auto pitchId = surge->storage.getPatch().scene[0].osc[0].pitch.id; - surge->setModulation(pitchId, ms_lfo1, 0, 0, 0.1); - surge->setModulation(pitchId, ms_slfo1, 0, 0, 0.1); + surge->setModDepth01(pitchId, ms_lfo1, 0, 0, 0.1); + surge->setModDepth01(pitchId, ms_slfo1, 0, 0, 0.1); surge->storage.getPatch().formulamods[0][0].setFormula(R"FN( function init(modstate) @@ -832,7 +832,7 @@ TEST_CASE("Macros Are Available", "[formula]") surge->storage.getPatch().scene[0].lfo[0].shape.val.i = lt_formula; surge->storage.getPatch().scene[0].adsr[0].r.val.f = 2; auto pitchId = surge->storage.getPatch().scene[0].osc[0].pitch.id; - surge->setModulation(pitchId, ms_lfo1, 0, 0, 0.1); + surge->setModDepth01(pitchId, ms_lfo1, 0, 0, 0.1); REQUIRE(1); } @@ -843,7 +843,7 @@ TEST_CASE("Nan Clampsr", "[formula]") auto surge = Surge::Test::surgeOnSine(); surge->storage.getPatch().scene[0].lfo[0].shape.val.i = lt_formula; auto pitchId = surge->storage.getPatch().scene[0].osc[0].pitch.id; - surge->setModulation(pitchId, ms_lfo1, 0, 0, 0.1); + surge->setModDepth01(pitchId, ms_lfo1, 0, 0, 0.1); surge->storage.getPatch().formulamods[0][0].setFormula(R"FN( function init(modstate) @@ -877,7 +877,7 @@ end)FN"); auto surge = Surge::Test::surgeOnSine(); surge->storage.getPatch().scene[0].lfo[0].shape.val.i = lt_formula; auto pitchId = surge->storage.getPatch().scene[0].osc[0].pitch.id; - surge->setModulation(pitchId, ms_lfo1, 0, 0, 0.1); + surge->setModDepth01(pitchId, ms_lfo1, 0, 0, 0.1); surge->storage.getPatch().formulamods[0][0].setFormula(R"FN( function init(modstate) diff --git a/src/surge-testrunner/UnitTestsMIDI.cpp b/src/surge-testrunner/UnitTestsMIDI.cpp index b4b37ab9a5a..082ac267ce4 100644 --- a/src/surge-testrunner/UnitTestsMIDI.cpp +++ b/src/surge-testrunner/UnitTestsMIDI.cpp @@ -1526,7 +1526,7 @@ TEST_CASE("Poly AT on Multiple Channels", "[midi]") REQUIRE(surge); auto pid = surge->storage.getPatch().scene[0].osc[0].pitch.id; - surge->setModulation(pid, ms_polyaftertouch, 0, 0, 0.1); + surge->setModDepth01(pid, ms_polyaftertouch, 0, 0, 0.1); surge->process(); surge->playNote(ch, 60, 120, 0); surge->process(); diff --git a/src/surge-testrunner/UnitTestsMOD.cpp b/src/surge-testrunner/UnitTestsMOD.cpp index decc449d631..39a3eb99df6 100644 --- a/src/surge-testrunner/UnitTestsMOD.cpp +++ b/src/surge-testrunner/UnitTestsMOD.cpp @@ -1057,11 +1057,11 @@ TEST_CASE("High Low Latest Note Modulator in All Modes", "[mod]") // Assign highest note keytrack to any parameter. Lets do this with highest latest and // lowest - surge->setModulation(surge->storage.getPatch().scene[0].osc[0].pitch.id, ms_highest_key, 0, + surge->setModDepth01(surge->storage.getPatch().scene[0].osc[0].pitch.id, ms_highest_key, 0, 0, 0.2); - surge->setModulation(surge->storage.getPatch().scene[0].osc[0].p[0].id, ms_latest_key, 0, 0, + surge->setModDepth01(surge->storage.getPatch().scene[0].osc[0].p[0].id, ms_latest_key, 0, 0, 0.2); - surge->setModulation(surge->storage.getPatch().scene[0].osc[0].p[1].id, ms_lowest_key, 0, 0, + surge->setModDepth01(surge->storage.getPatch().scene[0].osc[0].p[1].id, ms_lowest_key, 0, 0, 0.2); return surge; }; @@ -1239,18 +1239,18 @@ TEST_CASE("High Low Latest with splits", "[mod]") // Assign highest note keytrack to any parameter. Lets do this with highest latest and // lowest - surge->setModulation(surge->storage.getPatch().scene[0].osc[0].pitch.id, ms_highest_key, 0, + surge->setModDepth01(surge->storage.getPatch().scene[0].osc[0].pitch.id, ms_highest_key, 0, 0, 0.2); - surge->setModulation(surge->storage.getPatch().scene[0].osc[0].p[0].id, ms_latest_key, 0, 0, + surge->setModDepth01(surge->storage.getPatch().scene[0].osc[0].p[0].id, ms_latest_key, 0, 0, 0.2); - surge->setModulation(surge->storage.getPatch().scene[0].osc[0].p[1].id, ms_lowest_key, 0, 0, + surge->setModDepth01(surge->storage.getPatch().scene[0].osc[0].p[1].id, ms_lowest_key, 0, 0, 0.2); - surge->setModulation(surge->storage.getPatch().scene[1].osc[0].pitch.id, ms_highest_key, 0, + surge->setModDepth01(surge->storage.getPatch().scene[1].osc[0].pitch.id, ms_highest_key, 0, 0, 0.2); - surge->setModulation(surge->storage.getPatch().scene[1].osc[0].p[0].id, ms_latest_key, 0, 0, + surge->setModDepth01(surge->storage.getPatch().scene[1].osc[0].p[0].id, ms_latest_key, 0, 0, 0.2); - surge->setModulation(surge->storage.getPatch().scene[1].osc[0].p[1].id, ms_lowest_key, 0, 0, + surge->setModDepth01(surge->storage.getPatch().scene[1].osc[0].p[1].id, ms_lowest_key, 0, 0, 0.2); return surge; diff --git a/src/surge-xt/SurgeSynthProcessor.cpp b/src/surge-xt/SurgeSynthProcessor.cpp index 0a75c15caee..284e5bbe21b 100644 --- a/src/surge-xt/SurgeSynthProcessor.cpp +++ b/src/surge-xt/SurgeSynthProcessor.cpp @@ -459,7 +459,7 @@ void SurgeSynthProcessor::getStateInformation(juce::MemoryBlock &destData) void SurgeSynthProcessor::setStateInformation(const void *data, int sizeInBytes) { surge->enqueuePatchForLoad(data, sizeInBytes); - surge->processThreadunsafeOperations(); + surge->processAudioThreadOpsWhenAudioEngineUnavailable(); } void SurgeSynthProcessor::surgeParameterUpdated(const SurgeSynthesizer::ID &id, float f) diff --git a/src/surge-xt/gui/SurgeGUIEditor.cpp b/src/surge-xt/gui/SurgeGUIEditor.cpp index c6c12faf77b..7ca699ee9ac 100644 --- a/src/surge-xt/gui/SurgeGUIEditor.cpp +++ b/src/surge-xt/gui/SurgeGUIEditor.cpp @@ -1142,7 +1142,7 @@ void SurgeGUIEditor::refresh_mod() synth->isModDestUsed(i), synth->isActiveModulation(i, thisms, use_scene, modsource_index)); s->setIsModulationBipolar(synth->isBipolarModulation(thisms)); - s->setModValue(synth->getModulation(i, thisms, use_scene, modsource_index)); + s->setModValue(synth->getModDepth01(i, thisms, use_scene, modsource_index)); } else { @@ -2427,7 +2427,7 @@ void SurgeGUIEditor::setModulationFromUndo(int paramId, modsources ms, int scene { auto p = synth->storage.getPatch().param_ptr[paramId]; // FIXME scene and index - synth->setModulation(p->id, ms, scene, idx, val); + synth->setModDepth01(p->id, ms, scene, idx, val); synth->muteModulation(p->id, ms, scene, idx, muted); ensureParameterItemIsFocused(p); modsource = ms; @@ -2441,7 +2441,7 @@ void SurgeGUIEditor::pushModulationToUndoRedo(int paramId, modsources ms, int sc Surge::GUI::UndoManager::Target which) { undoManager()->pushModulationChange( - paramId, ms, scene, idx, synth->getModulation(paramId, ms, scene, idx), + paramId, ms, scene, idx, synth->getModDepth01(paramId, ms, scene, idx), synth->isModulationMuted(paramId, modsource, current_scene, modsource_index), which); } //------------------------------------------------------------------------------------------------ @@ -4486,7 +4486,7 @@ void SurgeGUIEditor::promptForUserValueEntry(Parameter *p, juce::Component *c, i } typeinParamEditor->setEditedParam(p); - typeinParamEditor->setModulation(p && ms > 0, (modsources)ms, modScene, modidx); + typeinParamEditor->setModDepth01(p && ms > 0, (modsources)ms, modScene, modidx); addAndMakeVisibleWithTracking(frame.get(), *typeinParamEditor); @@ -5290,7 +5290,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrisActiveModulation(p->id, modsource, current_scene, modsource_index)); if (synth->isValidModulation(p->id, modsource)) { - hs->setModValue(synth->getModulation(p->id, modsource, current_scene, modsource_index)); + hs->setModValue(synth->getModDepth01(p->id, modsource, current_scene, modsource_index)); hs->setIsModulationBipolar(synth->isBipolarModulation(modsource)); } diff --git a/src/surge-xt/gui/SurgeGUIEditor.h b/src/surge-xt/gui/SurgeGUIEditor.h index 4e5fcc99faf..4994a6ac1be 100644 --- a/src/surge-xt/gui/SurgeGUIEditor.h +++ b/src/surge-xt/gui/SurgeGUIEditor.h @@ -144,7 +144,7 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener, { synth->patchid_queue = t; // Looks scary but remember this only runs if audio thread is off - synth->processThreadunsafeOperations(); + synth->processAudioThreadOpsWhenAudioEngineUnavailable(); patchCountdown = 200; } } @@ -448,7 +448,7 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener, { strncpy(synth->patchid_file, file.c_str(), FILENAME_MAX); synth->has_patchid_file = true; - synth->processThreadunsafeOperations(); + synth->processAudioThreadOpsWhenAudioEngineUnavailable(); } void loadPatchWithDirtyCheck(bool increment, bool isCategory, bool insideCategory = false); diff --git a/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp b/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp index 0cd761ea649..443fe49ebea 100644 --- a/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp +++ b/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp @@ -2551,7 +2551,7 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c if (ctrms) { ctrms->setModValue( - synth->getModulation(p->id, thisms, use_scene, modsource_index)); + synth->getModDepth01(p->id, thisms, use_scene, modsource_index)); ctrms->setModulationState( synth->isModDestUsed(p->id), synth->isActiveModulation(p->id, thisms, use_scene, modsource_index)); @@ -3152,7 +3152,7 @@ void SurgeGUIEditor::valueChanged(Surge::GUI::IComponentTagValue *control) { synth->switch_toggled_queued = true; queue_refresh = true; - synth->processThreadunsafeOperations(); + synth->processAudioThreadOpsWhenAudioEngineUnavailable(); return; } break; @@ -3161,7 +3161,7 @@ void SurgeGUIEditor::valueChanged(Surge::GUI::IComponentTagValue *control) synth->load_fx_needed = true; // queue_refresh = true; synth->fx_reload[limit_range(current_fx, 0, n_fx_slots - 1)] = true; - synth->processThreadunsafeOperations(); + synth->processAudioThreadOpsWhenAudioEngineUnavailable(); if (fxMenu && fxMenu->selectedIdx >= 0) { @@ -3223,7 +3223,7 @@ void SurgeGUIEditor::valueChanged(Surge::GUI::IComponentTagValue *control) auto use_scene = 0; if (this->synth->isModulatorDistinctPerScene(thisms)) use_scene = current_scene; - synth->setModulation(ptag, thisms, use_scene, modsource_index, mv); + synth->setModDepth01(ptag, thisms, use_scene, modsource_index, mv); mci->setModulationState( synth->isModDestUsed(p->id), @@ -3511,7 +3511,7 @@ bool SurgeGUIEditor::setParameterModulationFromString(Parameter *p, modsources m } else { - synth->setModulation(p->id, ms, modsourceScene, modidx, mv); + synth->setModDepth01(p->id, ms, modsourceScene, modidx, mv); synth->refresh_editor = true; synth->storage.getPatch().isDirty = true; } diff --git a/src/surge-xt/gui/overlays/ModulationEditor.cpp b/src/surge-xt/gui/overlays/ModulationEditor.cpp index 7f893374611..96ed8b6a2ed 100644 --- a/src/surge-xt/gui/overlays/ModulationEditor.cpp +++ b/src/surge-xt/gui/overlays/ModulationEditor.cpp @@ -587,7 +587,7 @@ struct ModulationListContents : public juce::Component, public Surge::GUI::SkinC contents->editor->ed->pushModulationToUndoRedo( p->id, (modsources)datum.source_id, datum.source_scene, datum.source_index, Surge::GUI::UndoManager::UNDO); - synth->setModulation(datum.destination_id + datum.idBase, + synth->setModDepth01(datum.destination_id + datum.idBase, (modsources)datum.source_id, datum.source_scene, datum.source_index, nm01); @@ -776,7 +776,7 @@ struct ModulationListContents : public juce::Component, public Surge::GUI::SkinC int ptag = p->id; auto thisms = (modsources)d.source_id; - d.moddepth01 = synth->getModulation(ptag, thisms, d.source_scene, d.source_index); + d.moddepth01 = synth->getModDepth01(ptag, thisms, d.source_scene, d.source_index); d.isBipolar = synth->isBipolarModulation(thisms); d.isMuted = synth->isModulationMuted(ptag, thisms, d.source_scene, d.source_index); p->get_display_of_modulation_depth( @@ -1489,7 +1489,7 @@ void ModulationSideControls::doAdd() auto synth = editor->synth; editor->ed->pushModulationToUndoRedo(dest_id, add_ms, add_ms_sc, add_ms_idx, Surge::GUI::UndoManager::UNDO); - synth->setModulation(dest_id, add_ms, add_ms_sc, add_ms_idx, 0.01); + synth->setModDepth01(dest_id, add_ms, add_ms_sc, add_ms_idx, 0.01); addSourceW->setLabels({"Select Source"}); addTargetW->setLabels({"Select Target"}); addTargetW->setEnabled(false); diff --git a/src/surge-xt/gui/overlays/TypeinParamEditor.h b/src/surge-xt/gui/overlays/TypeinParamEditor.h index ea1cad25125..e828bcf5096 100644 --- a/src/surge-xt/gui/overlays/TypeinParamEditor.h +++ b/src/surge-xt/gui/overlays/TypeinParamEditor.h @@ -54,7 +54,7 @@ struct TypeinParamEditor : public juce::Component, bool isMod{false}; modsources ms{ms_original}; int modScene{-1}, modidx{0}; - void setModulation(bool isMod, modsources ms, int modScene, int modidx) + void setModDepth01(bool isMod, modsources ms, int modScene, int modidx) { this->isMod = isMod; this->ms = ms;