How to do "pass-through" knobs on synth with presets?


Well-known member
Just wondering if anyone has any tips on programming "pass through" knobs?

After a preset is loaded, the knob position no longer represents the loaded value. pass-through knob behavior means that when the user turns the knob, it isn't updated until it "passes through" the loaded value and then the knob becomes live.

Sounds pretty simple, but it's baking my noodle thinking about how this might get programmed.
Something like this?
float getval(int channel) { return 0.5f;}

class Knob
    enum {below,above,track} state;
    int channel;
    float physicalValue;
    float returnedValue;
    Knob(int ch) : state(track) { channel = ch; }
    void loadPreset(float value)
        returnedValue = value;
        if (value < physicalValue)
            state = below;
        else if (value > physicalValue)
            state = above;
    float getValue(void)
        physicalValue = getval(channel); // get actual knob position
            case below: // preset value was < knob
                if (physicalValue <= returnedValue)
                    state = track;
            case above: // preset value was > knob
                if (physicalValue >= returnedValue)
                    state = track;
        if (track == state)
            returnedValue = physicalValue;
        return returnedValue;        

Knob knob1(A0);
Knob slider1(A3);
Change the getval(channel) to access your physical hardware. When you load a preset, load its values to your controls, e.g. knob1.loadPreset(0.75); Turning the knob shouldn't affect the result of knob1.getvalue() until it physically passes 0.75 in whichever direction that is.

DISCLAIMER: I've written code like this, but not tested this actual class! Even if debugged, there are lots of improvements you could make, like abstracting the source of the physical control to analogue, MIDI etc.

EDITED: initialise state to track
Last edited: