Combining button actions in MDP2

See on MDP2 Q&A

Situation – we want to mimic hardware that has four track buttons, and a pair of start / stop buttons.  You can press a track button, and then choose either start or stop.  How can we create this behavior in MDP2?

A brute force approach would make eight controls, four start buttons and four stop buttons.  But we prefer to mimic the hardware behavior.

There are some limited ways to combine two control values in MDP2.  Most of these involve using the second control as a “channel” setter.  Such a solution is possible here, but we would still need some StreamByter code to clean it up, so in this case the brute force method is easier.

Solution:  Use StreamByter to combine the two button values and send the desired messages.

We will use “synthetic” SysEx messages for the buttons.  

Make four momentary buttons, Tracks 1-4, type SysEx, message 58 0x V (x = 1 to 4 to match the button), one byte V, no checksum, Midi 0 off, 1 on.

Make the play / stop buttons, momentary, type SysEx, message 59 0x V (x = 0 for stop, 1 for play), Midi 0 off, 1 on.

In the example, we send a CC 01 (Bx 01) on the track MIDI channel (assumed 1-4), with value of 0 for stop and 127 for play.  Replace the SND Bx xx xx with the desired MIDI message.

This logic expects the Track button to be pressed first and held while the action button is pressed.  The logic could be inverted if desired, storing the action button state, then seeing if a track button was pressed.  If you press any button alone, there is no output.

See Config/Connections/Output Rules for StreamByter Code

# Combine Button Actions, Red Heron Music, 22-05-26
# Track  F0 58 0x vv F7, x = track number, vv = 0, 1 (button depressed)
# Action F0 59 0y vv F7, y = action, 0 stop, 1 play, vv = 0, 1 (button depressed)
# _____M0 M1 M2 M3 M4

# I1 – I4 store state of Track buttons
# Replace the SND Bx xx xx instances with your desired MIDI message

# Check for Track Button Press

IF M0 == F0 58 # Detected Track Button Press, store button status (off, on)
    IF M2 == 01
        ASS I1 = M3
    END
    IF M2 == 02
        ASS I2 = M3
    END
    IF M2 == 03
        ASS I3 = M3
    END
    IF M2 == 04
        ASS I4 = M3
    END
    F0 = XX +B # Block the outbound synthetic SysEx
END

# Check for Action Button Press

IF M0 == F0 59 # Detected Action Button Press, execute action
    IF M2 == 00 01 # Stop Button Active
        IF I1 == 01
            SND B0 01 00
        END
        IF I2 == 01
            SND B1 01 00
        END
        IF I3 == 01
            SND B2 01 00
        END
        IF I4 == 01
            SND B3 01 00
        END
    END
    IF M2 == 01 01 # Play Button Active
        IF i1 == 01
            SND B0 01 7F
        END
        IF I2 == 01
            SND B1 01 7F
        END
        IF I3 == 01
            SND B2 01 7F
        END
        IF I4 == 01
            SND B3 01 7F
        END
    END
    F0 = XX +B # Block the outbound synthetic SysEx
END

Advertisement