# INPUTS:
#  I1: [Root]
#  I2: [Degree]
#  I3: [Gatelen]
#  I4: [Clock]
#  I8: [Reset]

# OUTPUTS:
#  O1: [Pitch 1]
#  O2: [CV 1]
#  O3: [Gate 1]
#  O4: [Clock]
#  O5: [Pitch 2]
#  O6: [CV 2]
#  O7: [Gate 2]
#  O8: [Reset]

# CONTROLLER 1:
#  P1.1: [Octave 1]
#  P1.2: [Octave 2]
#  P1.3: [Lucky Chance]
#  P1.4: [Lucky Amount]
#  B1.1: [Lucky]
#  B1.2: [LGates]

# CONTROLLER 2:
#  B2.1: [Pre 1]
#  B2.2: [Pre 2]
#  B2.3: [Pre 3]
#  B2.4: [Clear]
#  B2.5: [2/3 Oct]
#  B2.6: [Pingpong]
#  B2.7: [Reverse]
#  B2.8: [Shuffle]
#  B2.9: [A]
#  B2.10: [AAAB]
#  B2.11: [AABB]
#  B2.12: [AAB]
#  B2.13: [Comp]
#  B2.14: [Tuning]
#  B2.15: [Gates]
#  B2.16: [St/End] Doublelclick: clear start/end
#  B2.17: [Pitch]
#  B2.18: [Pitch R]
#  B2.19: [Gateprop]
#  B2.20: [Repeats]
#  B2.21: [Gatepat]
#  B2.22: [Ratch]
#  B2.23: [CV]
#  B2.24: [MENU]
#  B2.25: [Mute 1]
#  B2.26: [Mute 2]
#  B2.27: [Timing]
#  B2.28: [Stop]
#  B2.29: [Track 1]
#  B2.30: [Track 2]
#  B2.31: [Page1/2]
#  B2.32: [Start]

# CONTROLLER 3:
#  P3.1: [Clock]
#  P3.2: [Tranpose]
#  P3.3: [Root]
#  P3.4: [Degree] Ganz oben: Chromatisch

# CONTROLLER 4:
#  P4.1: [Gatelen] Shift all steps by that number
#  P4.2: [AutoRst] Autoreset sequencer after that number of steps
#  P4.3: [Pattern]
#  P4.4: [Clkdiv] Clockdivider

[p4b2]
[b32]
[m4]
[m4]

# -------------------------------------------------
# MIDI input
# -------------------------------------------------

[midiin]
    usb = 1
    clock = _MIDI_USB_CLOCK
    start = _MIDI_USB_IN_RESET

# This circuit detects an incoming MIDI clock via USB. If the clock signal is active at least once every two seconds,
# we give the MIDI clock precedence over the internal clock.
# Und hier
# kommt noch
# eineze Zeile
[clocktool]
    clock = _MIDI_USB_CLOCK # das ist die info
    gatelength = 2
    output = _MIDI_USB_CLOCK_PRESENT

# Get the incoming MIDI clock via TRS
[midiin]
    usb = 0
    clock = _MIDI_DIN_CLOCK
    start = _MIDI_DIN_IN_RESET

# we give the MIDI clock precedence over the internal clock.
[clocktool]
    clock = _MIDI_DIN_CLOCK
    gatelength = 2
    output = _MIDI_DIN_CLOCK_PRESENT

# -------------------------------------------------
# Clock
# -------------------------------------------------

# LFO for internal clock
# The pulse width is super short so that a clock reset will immediately take effect
[lfo]
    rate = _CLOCK_SPEED * 0.5
    sync = _RESET
    square = _INTERNAL_CLOCK
    pulsewidth = 0.02

# Create a number for the clock to use
[mixer]
    input1 = _MIDI_USB_CLOCK_PRESENT * 1
    input2 = _MIDI_DIN_CLOCK_PRESENT * 2
    output = _MIDI_CLOCK_SWITCH

# Select the clock to use. If both MID clocks are present, the clock switch is 3.
# In this case we use the USB MIDI clock.
[switch]
    input1 = _INTERNAL_CLOCK
    input2 = _MIDI_USB_CLOCK
    input3 = _MIDI_DIN_CLOCK
    input4 = _MIDI_USB_CLOCK
    offset = _MIDI_CLOCK_SWITCH
    output1 = N4

# Provide the clock at the cable _CLOCK. We could have used I4
# directly, but the patch is better readable that way.
[copy]
    input = I4
    output = _CLOCK_UNSWUNG

# Apply timing delays for eight clock periods which have been defined in the Tming menu
[timing]
    clock = _CLOCK_UNSWUNG
    reset = _RESET
    timing1 = _TIMING_1 * 0.3
    timing2 = _TIMING_2 * 0.3
    timing3 = _TIMING_3 * 0.3
    timing4 = _TIMING_4 * 0.3
    timing5 = _TIMING_5 * 0.3
    timing6 = _TIMING_6 * 0.3
    timing7 = _TIMING_7 * 0.3
    timing8 = _TIMING_8 * 0.3
    output = _CLOCK

[clocktool]
    clock = _CLOCK
    multiply = 2
    reset = _RESET
    output = _CLOCK_M2

[clocktool]
    clock = _CLOCK
    divide = 2
    reset = _RESET
    output = _CLOCK_D2

[clocktool]
    clock = _CLOCK
    divide = 4
    reset = _RESET
    output = _CLOCK_D4

[clocktool]
    clock = _CLOCK
    divide = 8
    reset = _RESET
    output = _CLOCK_D8

[clocktool]
    clock = _CLOCK
    divide = 16
    reset = _RESET
    output = _CLOCK_D16

[clocktool]
    clock = _CLOCK
    divide = 32
    reset = _RESET
    output = _CLOCK_D32

[copy]
    input = _CLOCK
    output = O4

# -------------------------------------------------
# Reset
# -------------------------------------------------

# Reset can be done via MIDI, via input I8 and by pressing the play button
[logic]
    input1 = _MIDI_USB_IN_RESET
    input2 = _MIDI_DIN_IN_RESET
    input3 = B2.32
    input4 = I8
    or = _RESET

# Provide a copy of the reset to output 8, so you can attach other modules and have them reset when our sequencer starts
[copy]
    input = _RESET
    output = O8

# -------------------------------------------------
# CV Inputs
# -------------------------------------------------

# Set the default gate length to 0.9 (90%)
[copy]
    input = 0.9
    output = N3

# Cut off negative CV inputs and never make the gate length below 1%
[compare]
    input = I3
    compare = 0.01
    ifless = 0.01
    else = I3
    output = _CV_GATELENGTH

# -------------------------------------------------
# Global fader menu (faders 1-4)
# -------------------------------------------------

# Little LFO for the LED animation of the fader menu
[lfo]
    hz = 1
    offset = 0.2
    level = 0.8
    triangle = _MENU_LED_BRIGHTNESS

# Fader 1: Speed of the master clock
[motorfader]
    fader = 1
    select = _MENU_ACTIVE
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.1
    output = _CLOCK_SPEED

# Fader 2: Global transposition
[motorfader]
    fader = 2
    notches = 13
    select = _MENU_ACTIVE
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.22
    output = _TRANSPOSITION

# Fader 3: Root note
[motorfader]
    fader = 3
    select = _MENU_ACTIVE
    notches = 13
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.36
    output = _MENU_ROOT

# Fader 4: Scale

# Selects the scale from the following list (1 is fader at bottom):

# 5: chromatic
# 4: phrygian minor
# 3: dorian minor
# 2: natural minor
# 1: major
[motorfader]
    fader = 4
    select = _MENU_ACTIVE
    notches = 5
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.49
    output = _DEGREE_OFFSET

# Maps the fader positions to the various scales
# You can use other scales as well (see the description of the input degree of motorfader
# for the numbers of the scales).

# The special number 12 is for switching to a chromatic scale
[switch]
    input1 = 1
    input2 = 7
    input3 = 6
    input4 = 9
    input5 = 12
    offset = _DEGREE_OFFSET
    output1 = _MENU_DEGREE

# The chromatic scale is not a scale of motoquencer. It is simulated by selecting any scale (12 = 0 in this case) and
# enabling the five none-scale notes with the selectfillX inputs.
[compare]
    input = _MENU_DEGREE
    compare = 12
    ifequal = 1
    else = 0
    output = _CHROMATIC_ENABLED

# -------------------------------------------------
# Timing menu
# -------------------------------------------------

# In the timing menu you can set a delay for each of eight period clock cycles. Do a swing by delaying cycles 2, 4, 6 and 8 by the same amount.
[faderbank]
    firstfader = 1
    select = _TIMING_ACTIVE
    ledcolor = 1.1
    output1 = _TIMING_1
    output2 = _TIMING_2
    output3 = _TIMING_3
    output4 = _TIMING_4
    output5 = _TIMING_5
    output6 = _TIMING_6
    output7 = _TIMING_7
    output8 = _TIMING_8
    ledvalue1 = _TIMING_1
    ledvalue2 = _TIMING_2
    ledvalue3 = _TIMING_3
    ledvalue4 = _TIMING_4
    ledvalue5 = _TIMING_5
    ledvalue6 = _TIMING_6
    ledvalue7 = _TIMING_7
    ledvalue8 = _TIMING_8

# -------------------------------------------------
# Fader menu track 1 (faders 5-8)
# -------------------------------------------------

# Fader 5: Gate length
[motorfader]
    fader = 5
    select = _MENU_ACTIVE * _TRACK_1_SELECTED
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.65
    output = _GATELEN_TRACK_1

# Fader 6: Auto reset
[motorfader]
    fader = 6
    notches = 17
    select = _MENU_ACTIVE * _TRACK_1_SELECTED
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.7
    output = _AUTORESET_TRACK_1

# Fader 7: Play pattern

# 0: go step by step to the sequence (normal)
# 1: two steps forward, one step backward
# 2: double step forward, one step backward
# 3: double step forward, double step backward, single step forward
# 4: double step forward, single step forward, double step backward, single step forward
# 5: random single step forward or backward
# 6: go forward by a small random number of steps
# 7: random jump to any allowed (other) note
[motorfader]
    fader = 7
    notches = 8
    select = _MENU_ACTIVE * _TRACK_1_SELECTED
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.85
    output = _PATTERN_TRACK_1

# Fader 8: Per track clock divider / multiplier

# 7: time / 32
# 6: time / 16
# 5: time / 8
# 4: quarter time
# 3: half time
# 2: normal clock
# 1: double time
[motorfader]
    fader = 8
    notches = 7
    select = _MENU_ACTIVE * _TRACK_1_SELECTED
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 1
    output = _TIMEDIV_NUM_TRACK_1

[switch]
    input1 = _CLOCK_M2
    input2 = _CLOCK
    input3 = _CLOCK_D2
    input4 = _CLOCK_D4
    input5 = _CLOCK_D8
    input6 = _CLOCK_D16
    input7 = _CLOCK_D32
    offset = _TIMEDIV_NUM_TRACK_1
    output1 = _CLOCK_TRACK_1

# -------------------------------------------------
# Fader menu track 2 (faders 5-8)
# -------------------------------------------------

# Fader 5: Gate length
[motorfader]
    fader = 5
    select = _MENU_ACTIVE * _TRACK_2_SELECTED
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.65
    output = _GATELEN_TRACK_2

# Fader 6: Auto reset
[motorfader]
    fader = 6
    notches = 17
    select = _MENU_ACTIVE * _TRACK_2_SELECTED
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.7
    output = _AUTORESET_TRACK_2

# Fader 7: Play pattern

# 0: go step by step to the sequence (normal)
# 1: two steps forward, one step backward
# 2: double step forward, one step backward
# 3: double step forward, double step backward, single step forward
# 4: double step forward, single step forward, double step backward, single step forward
# 5: random single step forward or backward
# 6: go forward by a small random number of steps
# 7: random jump to any allowed (other) note
[motorfader]
    fader = 7
    notches = 8
    select = _MENU_ACTIVE * _TRACK_2_SELECTED
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 0.85
    output = _PATTERN_TRACK_2

# Fader 8: Per track clock divider / multiplier

# 7: time / 32
# 6: time / 16
# 5: time / 8
# 4: quarter time
# 3: half time
# 2: normal clock
# 1: double time
[motorfader]
    fader = 8
    notches = 7
    select = _MENU_ACTIVE * _TRACK_2_SELECTED
    ledvalue = _MENU_LED_BRIGHTNESS
    ledcolor = 1
    output = _TIMEDIV_NUM_TRACK_2

[switch]
    input1 = _CLOCK_M2
    input2 = _CLOCK
    input3 = _CLOCK_D2
    input4 = _CLOCK_D4
    input5 = _CLOCK_D8
    input6 = _CLOCK_D16
    input7 = _CLOCK_D32
    offset = _TIMEDIV_NUM_TRACK_2
    output1 = _CLOCK_TRACK_2

# -------------------------------------------------
# Track 1
# -------------------------------------------------

# Select the preset 1, 2 or 3
[buttongroup]
    select = _TRACK_1_SELECTED
    button1 = B2.1
    button2 = B2.2
    button3 = B2.3
    value1 = 1
    value2 = 2
    value3 = 3
    led1 = L2.1
    led2 = L2.2
    led3 = L2.3
    output = _PRESET_TRACK_1

# Clear everything in the current preset (needs long press!)
[button]
    button = B2.4
    select = _TRACK_1_SELECTED
    states = 1
    led = L2.4
    longpress = _CLEAR_TRACK_1

# Change between a range of two octaves (off) and three octaves (on)
[button]
    select = _TRACK_1_SELECTED
    button = B2.5
    offvalue = 2V
    onvalue = 3V
    led = L2.5
    output = _CVRANGE_TRACK_1

# Ping pong mode
[button]
    select = _TRACK_1_SELECTED
    button = B2.6
    led = L2.6
    output = _PINGPONG_TRACK_1

# Reverse playing mode
[button]
    select = _TRACK_1_SELECTED
    button = B2.7
    led = L2.7
    output = _REVERSE_TRACK_1

# Randomly modifiy the order of the steps permanently (the lucky chance pot is taken into account here)
[button]
    button = B2.8
    select = _TRACK_1_SELECTED
    states = 1
    output = _SHUFFLE_TRACK_1

# Choose between several musical song forms.
[buttongroup]
    select = _TRACK_1_SELECTED
    button1 = B2.9
    button2 = B2.10
    button3 = B2.11
    button4 = B2.12
    value1 = 0
    value2 = 1
    value3 = 2
    value4 = 6
    led1 = L2.9
    led2 = L2.10
    led3 = L2.11
    led4 = L2.12
    output = _FORM_TRACK_1

# Select faders for track 1 if the menu is inactive and track 1 is selected
[logic]
    input1 = _MENU_INACTIVE
    input2 = _TRACK_1_SELECTED
    and = _SELECT_TRACK_1

# Mute button
[button]
    button = B2.25
    led = L2.25
    output = _MUTE_1

# Quantizer for the octave switch potentiometer
[quantizer]
    input = P1.1 * 5V
    steps = 1
    output = _OCTSWITCH_1

# A long press on the start/end button resets the start/end setting
# of the current track and sets start to 1 and end to 16
[button]
    button = B2.16
    select = _TRACK_1_SELECTED
    states = 1
    longpress = _CLEAR_SE_TRACK_1

# Sequencer for pitch and gate of track 1
[motoquencer]
    autoreset = _AUTORESET_TRACK_1
    buttonmode = _BUTTONMODE
    clear = _CLEAR_TRACK_1
    clearstartend = _CLEAR_SE_TRACK_1
    clock = _CLOCK_TRACK_1
    composemode = _COMPOSITION_MODE
    cvrange = _CVRANGE_TRACK_1
    degree = I2 / 120 + _MENU_DEGREE
    direction = _REVERSE_TRACK_1
    fadermode = _FADERMODE
    form = _FORM_TRACK_1
    gatelength = _CV_GATELENGTH * _GATELEN_TRACK_1 + 0.05
    linktonext = 1
    luckyamount = P1.4
    luckybuttons = B1.2
    luckychance = P1.3
    luckyfaders = B1.1
    luckyshuffle = _SHUFFLE_TRACK_1
    mute = _MUTE_1
    numfaders = 8
    numsteps = 16
    page = _PAGE
    pattern = _PATTERN_TRACK_1
    pingpong = _PINGPONG_TRACK_1
    preset = _PRESET_TRACK_1
    reset = _RESET
    root = I1 / 120 + _MENU_ROOT
    run = _RUNNING
    select = _SELECT_TRACK_1
    selectfill1 = _CHROMATIC_ENABLED
    selectfill2 = _CHROMATIC_ENABLED
    selectfill3 = _CHROMATIC_ENABLED
    selectfill4 = _CHROMATIC_ENABLED
    selectfill5 = _CHROMATIC_ENABLED
    select1 = 1
    select3 = 1
    select5 = 1
    select7 = 1
    select9 = 1
    select11 = 1
    select13 = 1
#   shiftsteps = _SHIFT_TRACK_1
    transpose = _TRANSPOSITION / 120
    tuningmode = _TUNING_MODE
    cv = _PITCH_TRACK_1
    gate = O3

# Add an additional CV track for modulation
# For the MIDI output that's used as velocity.
[motoquencer]
    cv = O2
    quantize = 0
    cvbase = 0
    cvrange = 8V
    preset = _PRESET_TRACK_1
    clear = _CLEAR_TRACK_1

# Copy the pitch to the output CV jack
[copy]
    input = _PITCH_TRACK_1 + _OCTSWITCH_1
    output = O1

# -------------------------------------------------
# Track 2
# -------------------------------------------------

# Select the preset 1, 2 or 3
[buttongroup]
    select = _TRACK_2_SELECTED
    button1 = B2.1
    button2 = B2.2
    button3 = B2.3
    value1 = 1
    value2 = 2
    value3 = 3
    led1 = L2.1
    led2 = L2.2
    led3 = L2.3
    output = _PRESET_TRACK_2

# Clear everything in the current preset (needs long press!)
[button]
    button = B2.4
    select = _TRACK_2_SELECTED
    states = 1
    led = L2.4
    longpress = _CLEAR_TRACK_2

# Change between a range of two octaves (off) and three octaves (on)
[button]
    select = _TRACK_2_SELECTED
    button = B2.5
    offvalue = 2V
    onvalue = 3V
    led = L2.5
    output = _CVRANGE_TRACK_2

# Ping pong mode
[button]
    select = _TRACK_2_SELECTED
    button = B2.6
    led = L2.6
    output = _PINGPONG_TRACK_2

# Reverse playing mode
[button]
    select = _TRACK_2_SELECTED
    button = B2.7
    led = L2.7
    output = _REVERSE_TRACK_2

# Randomly modifiy the order of the steps permanently (the lucky chance pot is taken into account here)
[button]
    button = B2.8
    select = _TRACK_2_SELECTED
    states = 1
    output = _SHUFFLE_TRACK_2

# Choose between several musical song forms.
[buttongroup]
    select = _TRACK_2_SELECTED
    button1 = B2.9
    button2 = B2.10
    button3 = B2.11
    button4 = B2.12
    value1 = 0
    value2 = 1
    value3 = 2
    value4 = 6
    led1 = L2.9
    led2 = L2.10
    led3 = L2.11
    led4 = L2.12
    output = _FORM_TRACK_2

# Select faders for track 1 if the menu is inactive and track 1 is selected
[logic]
    input1 = _MENU_INACTIVE
    input2 = _TRACK_2_SELECTED
    and = _SELECT_TRACK_2

# Mute button
[button]
    button = B2.26
    led = L2.26
    output = _MUTE_2

# Quantizer for the octave switch potentiometer
[quantizer]
    input = P1.2 * 5V
    steps = 1
    output = _OCTSWITCH_2

# A long press on the start/end button resets the start/end setting
# of the current track and sets start to 1 and end to 16
[button]
    button = B2.16
    select = _TRACK_2_SELECTED
    states = 1
    longpress = _CLEAR_SE_TRACK_2

# Sequencer for pitch and gate of track 1
[motoquencer]
    autoreset = _AUTORESET_TRACK_2
    buttonmode = _BUTTONMODE
    clear = _CLEAR_TRACK_2
    clearstartend = _CLEAR_SE_TRACK_2
    clock = _CLOCK_TRACK_2
    composemode = _COMPOSITION_MODE
    cvrange = _CVRANGE_TRACK_2
    degree = I2 / 120 + _MENU_DEGREE
    direction = _REVERSE_TRACK_2
    fadermode = _FADERMODE
    form = _FORM_TRACK_2
    gatelength = _CV_GATELENGTH * _GATELEN_TRACK_2 + 0.05
    linktonext = 1
    luckyamount = P1.4
    luckybuttons = B1.2
    luckychance = P1.3
    luckyfaders = B1.1
    luckyshuffle = _SHUFFLE_TRACK_2
    mute = _MUTE_2
    numfaders = 8
    numsteps = 16
    page = _PAGE
    pattern = _PATTERN_TRACK_2
    pingpong = _PINGPONG_TRACK_2
    preset = _PRESET_TRACK_2
    reset = _RESET
    root = I1 / 120 + _MENU_ROOT
    run = _RUNNING
    select = _SELECT_TRACK_2
    selectfill1 = _CHROMATIC_ENABLED
    selectfill2 = _CHROMATIC_ENABLED
    selectfill3 = _CHROMATIC_ENABLED
    selectfill4 = _CHROMATIC_ENABLED
    selectfill5 = _CHROMATIC_ENABLED
    select1 = 1
    select3 = 1
    select5 = 1
    select7 = 1
    select9 = 1
    select11 = 1
    select13 = 1
    transpose = _TRANSPOSITION / 120
    tuningmode = _TUNING_MODE
    cv = _PITCH_TRACK_2
    gate = O7

# Add an additional CV track for modulation
# For the MIDI output that's used as velocity.
[motoquencer]
    cv = O6
    quantize = 0
    cvbase = 0
    cvrange = 8V
    preset = _PRESET_TRACK_2
    clear = _CLEAR_TRACK_2

# Copy the pitch to the output CV jack
[copy]
    input = _PITCH_TRACK_2 + _OCTSWITCH_2
    output = O5

# -------------------------------------------------
# Buttons
# -------------------------------------------------

# Start and stop button form a group. The start button is also used as a reset signal (in some other circuit)
[buttongroup]
    button1 = B2.28
    button2 = B2.32
    led1 = L2.28
    led2 = L2.32
    output = _RUNNING

# In composition mode always the note is played where you move a fader
[button]
    button = B2.13
    led = L2.13
    output = _COMPOSITION_MODE

# In Tuning mode all tracks output a C
[button]
    button = B2.14
    led = L2.14
    output = _TUNING_MODE

# Switch the faders and buttons between track 1 and track 2
# One button would be enough but this is easier to understand.
[buttongroup]
    button1 = B2.29
    button2 = B2.30
    led1 = L2.29
    led2 = L2.30

# Provide the selection of track 1 in an internal cable
[copy]
    input = L2.29
    output = _TRACK_1_SELECTED

# Provide the selection of track 2 in an internal cable
[copy]
    input = L2.30
    output = _TRACK_2_SELECTED

# Switch between the first 8 steps and the second 8 steps of the sequence
[button]
    button = B2.31
    onvalue = 1
    offvalue = 0
    led = L2.31
    output = _PAGE

# Select the current mode of the motor faders. There are sevens modes for the curren track. And also a menu and a timing configuration
[buttongroup]
    button1 = B2.17
    button2 = B2.18
    button3 = B2.19
    button4 = B2.20
    button5 = B2.21
    button6 = B2.22
    button7 = B2.23
    button8 = B2.24
    button9 = B2.27
    value1 = 0
    value2 = 1
    value3 = 2
    value4 = 3
    value5 = 4
    value6 = 5
    value7 = 10
    value8 = 98
    value9 = 99
    led1 = L2.17
    led2 = L2.18
    led3 = L2.19
    led4 = L2.20
    led5 = L2.21
    led6 = L2.22
    led7 = L2.23
    led8 = L2.24
    output = _FADERMODE
    led9 = L2.27

# Make the status "menu active" available in a cable
[copy]
    input = L2.24
    output = _MENU_ACTIVE

# Make the status "timing menu active" available in a cable
[copy]
    input = L2.27
    output = _TIMING_ACTIVE

# Switch the button mode between gates and start/end
[buttongroup]
    button1 = B2.15
    button2 = B2.16
    value1 = 0
    value2 = 1
    led1 = L2.15
    led2 = L2.16
    output = _BUTTONMODE

# Provide the information "neither menu nor timing menu open" on a cable
[compare]
    input = _MENU_ACTIVE + _TIMING_ACTIVE
    compare = 0
    ifequal = 1
    else = 0
    output = _MENU_INACTIVE

# -------------------------------------------------
# MIDI output
# -------------------------------------------------

# USB MIDI output of track 1, plays on channel 1
[midiout]
    channel = 1
    pitch1 = O1
    gate1 = O3
    velocity1 = O2 * 0.9 + 0.1
    clock = _CLOCK
    usb = 1
    start = _RESET

# USB MIDI output of track 2, plays on channel 2
[midiout]
    channel = 2
    pitch1 = O5
    gate1 = O7
    velocity1 = O6 * 0.9 + 0.1
    clock = _CLOCK
    usb = 1
    start = _RESET

# DIN MIDI output of track 1, plays on channel 1
[midiout]
    channel = 1
    pitch1 = O1
    gate1 = O3
    velocity1 = O2 * 0.9 + 0.1
    clock = _CLOCK
    usb = 0
    start = _RESET

# DIN MIDI output of track 2, plays on channel 2
[midiout]
    channel = 2
    pitch1 = O5
    gate1 = O7
    velocity1 = O6 * 0.9 + 0.1
    clock = _CLOCK
    usb = 0
    start = _RESET
