From ed4dbd5ac4a35f91ca600e5542e795b57877fe48 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Thu, 15 Aug 2024 13:34:12 +0200 Subject: [PATCH] #1101 When doing auto-load, always unload/fallback if FX loses focus --- main/src/application/unit_model.rs | 24 +-- resources/main-presets/factory/faders-eq.json | 142 ++++++++++++++++++ 2 files changed, 143 insertions(+), 23 deletions(-) create mode 100644 resources/main-presets/factory/faders-eq.json diff --git a/main/src/application/unit_model.rs b/main/src/application/unit_model.rs index 5966c23a3..93ac8a694 100644 --- a/main/src/application/unit_model.rs +++ b/main/src/application/unit_model.rs @@ -2910,29 +2910,7 @@ impl DomainEventHandler for WeakUnitModel { let unit_fx = unit_fx.filter(|unit_fx| { if matches!(&unit_fx_descriptor.fx, VirtualFx::LastFocused) { // Unit FX refers to the last-focused FX. We need to make a few more checks. - if unit_fx.window_is_open() { - // Window of unit FX (= last focused relevant FX) still open - match Backbone::get().last_available_focused_fx() { - Some(last_focused) if &last_focused != unit_fx => { - // This means that the FX resolver has skipped the actually last-focused, because it - // was not relevant (= because it was our own ReaLearn instance). So we can assume - // that focus changed from `unit_fx` (e.g. ReaEq) to ReaLearn. In that case, - // we don't want to keep the preset intact, not unload! - // last_focused.window_has_focus() - unit_fx.window_has_focus() - } - _ => { - // This means that the FX resolver has returned the actually last-focused instance. - // It was relevant. So we can assume that it was not a focus change from `unit_fx` - // to ReaLearn. In that case, we only want to keep the preset intact if `unit_fx` - // is still focused. If not, we want to unload the preset! - unit_fx.window_has_focus() - } - } - } else { - // Window of last focused FX closed. Unload preset! - false - } + unit_fx.window_is_open() && unit_fx.window_has_focus() } else { // Unit FX is something else than the last-focused FX. Load linked preset! true diff --git a/resources/main-presets/factory/faders-eq.json b/resources/main-presets/factory/faders-eq.json new file mode 100644 index 000000000..ab5ad4839 --- /dev/null +++ b/resources/main-presets/factory/faders-eq.json @@ -0,0 +1,142 @@ +{ + "version": "2.16.1", + "name": "Faders => EQ", + "defaultGroup": {}, + "mappings": [ + { + "id": "_lMShbSD1lHcQrkCpspG9", + "name": "1", + "source": { + "category": "virtual", + "isRegistered": false, + "is14Bit": false, + "oscArgIndex": 0 + }, + "mode": { + "maxStepSize": 0.05, + "minStepFactor": 1, + "maxStepFactor": 5 + }, + "target": { + "fxAnchor": "instance", + "useSelectionGanging": false, + "useTrackGrouping": false, + "paramIndex": 1, + "seekBehavior": "Immediate", + "useProject": true, + "moveView": true, + "seekPlay": true, + "oscArgIndex": 0, + "mouseAction": { + "kind": "MoveTo", + "axis": "X" + }, + "takeMappingSnapshot": { + "kind": "LastLoaded" + } + } + }, + { + "id": "14hpEkwmFEZeCvd8ZmdYL", + "name": "2", + "source": { + "category": "virtual", + "isRegistered": false, + "is14Bit": false, + "oscArgIndex": 0, + "controlElementIndex": 1 + }, + "mode": { + "maxStepSize": 0.05, + "minStepFactor": 1, + "maxStepFactor": 5 + }, + "target": { + "fxAnchor": "instance", + "useSelectionGanging": false, + "useTrackGrouping": false, + "paramIndex": 4, + "seekBehavior": "Immediate", + "useProject": true, + "moveView": true, + "seekPlay": true, + "oscArgIndex": 0, + "mouseAction": { + "kind": "MoveTo", + "axis": "X" + }, + "takeMappingSnapshot": { + "kind": "LastLoaded" + } + } + }, + { + "id": "HEgDs8r-E7uA26NjRZjL2", + "name": "3", + "source": { + "category": "virtual", + "isRegistered": false, + "is14Bit": false, + "oscArgIndex": 0, + "controlElementIndex": 2 + }, + "mode": { + "maxStepSize": 0.05, + "minStepFactor": 1, + "maxStepFactor": 5 + }, + "target": { + "fxAnchor": "instance", + "useSelectionGanging": false, + "useTrackGrouping": false, + "paramIndex": 7, + "seekBehavior": "Immediate", + "useProject": true, + "moveView": true, + "seekPlay": true, + "oscArgIndex": 0, + "mouseAction": { + "kind": "MoveTo", + "axis": "X" + }, + "takeMappingSnapshot": { + "kind": "LastLoaded" + } + } + }, + { + "id": "mMRSjmcWSk6v4BECrlAjP", + "name": "4", + "source": { + "category": "virtual", + "isRegistered": false, + "is14Bit": false, + "oscArgIndex": 0, + "controlElementIndex": 3 + }, + "mode": { + "maxStepSize": 0.05, + "minStepFactor": 1, + "maxStepFactor": 5 + }, + "target": { + "fxAnchor": "instance", + "useSelectionGanging": false, + "useTrackGrouping": false, + "paramIndex": 10, + "seekBehavior": "Immediate", + "useProject": true, + "moveView": true, + "seekPlay": true, + "oscArgIndex": 0, + "mouseAction": { + "kind": "MoveTo", + "axis": "X" + }, + "takeMappingSnapshot": { + "kind": "LastLoaded" + } + } + } + ] +} \ No newline at end of file