helgoboss / helgobox

Helgobox: ReaLearn & Playtime
https://www.helgoboss.org/projects/helgobox
GNU General Public License v3.0
210 stars 20 forks source link

Make "Make relative" compatible with non-feedback trigger-only targets #644

Open helgoboss opened 2 years ago

helgoboss commented 2 years ago

Example: "Project: Invoke REAPER action" (action "Move edit cursor forward/back one measure")

Use case: Use a fader to move forward/backward in relative way.

See here for context: https://forum.cockos.com/showpost.php?p=2591069&postcount=2420

helgoboss commented 2 years ago

Here with:

{
    kind = "MainCompartment",
    value = {
        mappings = {
            {
                id = "hVhs8aqlyhOs07K89g5W1",
                name = "Bar -",
                source = {
                    kind = "MidiControlChangeValue",
                    channel = 0,
                    controller_number = 48,
                    fourteen_bit = false,
                },
                glue = {
                    absolute_mode = "MakeRelative",
                    step_size_interval = {0.01, 0.05},
                    encoder_filter = "DecrementOnly",
                },
                target = {
                    kind = "ReaperAction",
                    command = 41043,
                    invocation = "Relative",
                },
            },
            {
                id = "Xb1T0RL0-dLOwkxmgDAGG",
                name = "Bar +",
                source = {
                    kind = "MidiControlChangeValue",
                    channel = 0,
                    controller_number = 48,
                    fourteen_bit = false,
                },
                glue = {
                    absolute_mode = "MakeRelative",
                    step_size_interval = {0.01, 0.05},
                    encoder_filter = "IncrementOnly",
                },
                target = {
                    kind = "ReaperAction",
                    command = 41042,
                    invocation = "Relative",
                },
            },
        },
    },
}

With the REAPER action target set to "Relative", the issue might be related to how the "Project: Invoke REAPER action" target reacts to the new type of "continuous increments" introduced by "Make relative" ... maybe not at all? I need to have a look. The target control log says "Hit target with value -0.007874015748031482 during normal control" ... and nothing happens.

Update: This makes sense and is correct behavior. The action target quantizes the continuous increment to a discrete increment (+1 or -1). But this particular target doesn't react to relative control, so nothing happens.

helgoboss commented 2 years ago

Alternative setup with "Trigger":

{
    kind = "MainCompartment",
    value = {
        mappings = {
            {
                id = "hVhs8aqlyhOs07K89g5W1",
                name = "Bar -",
                source = {
                    kind = "MidiControlChangeValue",
                    channel = 0,
                    controller_number = 48,
                    fourteen_bit = false,
                },
                glue = {
                    absolute_mode = "MakeRelative",
                    step_size_interval = {0.01, 0.05},
                    encoder_filter = "DecrementOnly",
                },
                target = {
                    kind = "ReaperAction",
                    command = 41043,
                    invocation = "Trigger",
                },
            },
            {
                id = "Xb1T0RL0-dLOwkxmgDAGG",
                name = "Bar +",
                source = {
                    kind = "MidiControlChangeValue",
                    channel = 0,
                    controller_number = 48,
                    fourteen_bit = false,
                },
                glue = {
                    absolute_mode = "MakeRelative",
                    step_size_interval = {0.01, 0.05},
                    encoder_filter = "IncrementOnly",
                },
                target = {
                    kind = "ReaperAction",
                    command = 41042,
                    invocation = "Trigger",
                },
            },
        },
    },
}

With the REAPER action target set to "Trigger" or "Absolute", it works in the beginning and then not anymore. The log says "Leave target untouched with value 0 during normal control".

The issue could be that the target doesn't return the current value ... which makes sense because normal actions (not on/off actions) don't have values. ReaLearn simply gives up at the moment because without having access to the current value, it can't make an educated decision about the next value. However, it might be nice to be less strict in this case in general: It could simply fire "100%" (or target max) in such a case. It would make relative control usable at leat for trigger-like targets!

On the other hand, we have those fake action values ... and they might be the reason because they are fake. In that case, either we need to have the option to prevent fake values (mmh, nobody will understand that) or a "Retrigger" checkbox similar to the parameter target ... probably better.

Update: So the latter guess was right. The fake values are the issue. This lets the glue section make wrong assumptions. Actually, the glue section already handles the case "retriggerable target can't return a current value" correctly. But we return a value, the fake value. Solution: Simply don't return fake values if invocation type is not "Absolute".

helgoboss commented 2 years ago

Controlling the bar in a relative way using the mod wheel works with that change, but not very reliably when seeking back. It could be because of the nature of the action, not sure. Need to test further.