Skip to content

Commit

Permalink
#1101 When doing auto-load, always unload/fallback if FX loses focus
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Aug 15, 2024
1 parent d07dbef commit ed4dbd5
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 23 deletions.
24 changes: 1 addition & 23 deletions main/src/application/unit_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
142 changes: 142 additions & 0 deletions resources/main-presets/factory/faders-eq.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
]
}

0 comments on commit ed4dbd5

Please sign in to comment.