Skip to content

Commit

Permalink
#1287 Implement encoder acceleration for Softube Console 1 mk2 Native…
Browse files Browse the repository at this point in the history
… preset
  • Loading branch information
helgoboss committed Oct 29, 2024
1 parent 4033e0e commit 2504682
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type PresetMode = "native" | "midi-absolute" | "midi-relative"

export type PresetConfig = {
mode: PresetMode,

}

function module.create_compartment(config: PresetConfig): realearn.Compartment
Expand Down Expand Up @@ -37,6 +38,20 @@ function module.create_compartment(config: PresetConfig): realearn.Compartment

local realearn = require("realearn")

local sysex_to_relative_transformation = [[
y_type = 1;
y = prev_timestamp == 0 ? (
1
) : (
// Implement encoder acceleration based on timestamp diffs
diff_millis = (realearn_timestamp - prev_timestamp) * 1000;
added = 10 / diff_millis;
// realearn_dbg(added);
1 + added
);
prev_timestamp = realearn_timestamp;
]]

local abs_to_rel_transformation = [[
y_type = 1;
// If the last-sent feedback value is available, we use this one as reference (because the controller
Expand Down Expand Up @@ -160,7 +175,8 @@ count += 1;
character = "Button",
},
glue = realearn.Glue {
absolute_mode = "IncrementalButton",
control_transformation = sysex_to_relative_transformation,
step_factor_interval = {1, 100},
},
target = target,
}
Expand All @@ -173,7 +189,8 @@ count += 1;
character = "Button",
},
glue = {
absolute_mode = "IncrementalButton",
control_transformation = sysex_to_relative_transformation,
step_factor_interval = {1, 100},
reverse = true,
},
target = target,
Expand Down

0 comments on commit 2504682

Please sign in to comment.