2 Parameters 1 Knob With a Switch and Soft Takeover mode?

now i want to expand on this a little bit :))

i’m trying to figure out a way to have a [train] node flash a led when moving the knob back to the saved position of the parameter to indicate distance before it will latch on to the param again if that makes sense.

lets say saved value is 0.2 and the knob is at 0.8 when switching back. we need to travel -0.6 with the knob to get bck to the saved value and latch on. when it is furthest away the [train] should be at it’s slowest. as the knob is turned towards 0.2 it gets faster when it is really close the led should flash fast enough to almost not notice that its flashing.

any smart math heads or maybe @alo.bu has a thought about how to go about this? it seems doable with the code you wrote to use the outputs for something like this.

some things to consider, a change in any of the knobs(considering we are have multiple knbos that have 2 parameters) should be detected and then show the flashing led to indicate the distance. if we have multiple knobs with the dual function on it all switched by the same switch the led needs to reflect the values of the right knob.

The value of knob - param records how far you are from regaining control of the parameter (smaller means closer). The train object needs to be given period of oscillation in samples, so smaller numbers give faster LED pulses. All you have to do is feed bignum * abs(knob - param) to train, where bignum is the period of the slowest pulsing the light can make – maybe 24000, so that if the knob is at 1 and the parameter at 0, the light pulses twice a second.

oo wow didn’t expect a reaction that quick, that’s it yea gonna play around with that and finding a way to only show the blinking leds when turning a knob and also the right train values for specific knobs. In my module there are 4 knobs that each are gonna have a 2nd value. So I have 4 code boxes with your code to do just that:)

How would one go about building on this code so it could also work as with a three way toggle switch instead of a two way? The current two way implementation works great on my end, I’m just not super adept with using the codebox, so any additional help would be greatly appreciated!

actually i did do some work on that to be able to expand the amount of params on one knob. try this one.

https://www.dropbox.com/scl/fi/xwgdlvf8xmkzpi75u0o2a/modeswitch4.maxpat?rlkey=cs9frskyx9kbh2hyqq7a1evoo&dl=0

srry still don’t know how to add a block of code here.

Thanks for sending that over! I really appreciate it.
Would there be a way to use the ModeSwitch parameter in a way where I can choose between the modes in no specific order, as opposed to it stepping through 0-3 then wrapping?

So after a few hours of experimenting I was finally able to get a modded version working where you can select between modes in no particular order.

// ------------------------------------------------------------
// HISTORY OBJECTS (Single Knob)
// ------------------------------------------------------------
History kn1_param1(0.0);
History kn1_param2(0.0);
History kn1_param3(0.0);
History kn1_controlling(0);
History prev_mode(0);

// ------------------------------------------------------------
// SHARED INPUTS
// ------------------------------------------------------------
Param reset (min=0, max=1);
Param modeSelect (min=0, max=2);  // Direct mode selection (0, 1, or 2)
Param randomTrig (min=0, max=1);
Param knob1 (min=0, max=1);

// ------------------------------------------------------------
// DEFAULTS & SLIDE TIME
// ------------------------------------------------------------
default1   = 0.0;
default2   = 0.0;
default3   = 0.0;
slide_time = 0;

// ------------------------------------------------------------
// HANDLE MODE CHANGE DETECTION
// ------------------------------------------------------------
current_mode = int(modeSelect);
mode_changed = (current_mode != prev_mode);

if (mode_changed) {
    kn1_controlling = 0;  // force re-pickup when mode changes
    prev_mode = current_mode;
}

// ------------------------------------------------------------
// RANDOMIZATION LOGIC
// ------------------------------------------------------------
if (delta(randomTrig) > 0) {
    if (current_mode == 0) {
        kn1_param1 = (noise() * 0.5) + 0.5;
    } else if (current_mode == 1) {
        kn1_param2 = (noise() * 0.5) + 0.5;
    } else { // current_mode == 2
        kn1_param3 = (noise() * 0.5) + 0.5;
    }
}

// ------------------------------------------------------------
// RESET LOGIC
// ------------------------------------------------------------
if (reset > 0) {
    kn1_param1 = slide(default1, slide_time, slide_time);
    kn1_param2 = slide(default2, slide_time, slide_time);
    kn1_param3 = slide(default3, slide_time, slide_time);
}

// ------------------------------------------------------------
// ACTIVE/PICKUP LOGIC
// modeSelect = 0 -> param1, 1 -> param2, 2 -> param3
// ------------------------------------------------------------
if (kn1_controlling > 0) {
    // Already controlling: write current param directly
    if (current_mode == 0) {
        kn1_param1 = knob1; 
    } else if (current_mode == 1) {
        kn1_param2 = knob1;
    } else { // current_mode == 2
        kn1_param3 = knob1;
    }
} else {
    // Not controlling yet: check pickup threshold
    current_value = 0;  // Corrected line without 'float' keyword
    
    if (current_mode == 0) {
        current_value = kn1_param1;
    } else if (current_mode == 1) {
        current_value = kn1_param2;
    } else { // current_mode == 2
        current_value = kn1_param3;
    }
    
    if (abs(knob1 - current_value) <= 0.02) {
        kn1_controlling = 1;
    }
}

// ------------------------------------------------------------
// OUTPUTS
// ------------------------------------------------------------
out1 = kn1_param1;
out2 = kn1_param2;
out3 = kn1_param3;