# Motorfader sequencer with S10

# 

# INPUTS:
#  I1: [CLOCK]
#  I3: [ROOT]
#  I4: [SCALE]

# OUTPUTS:
#  O1: [V/O]
#  O2: [CV2]
#  O3: [CV3]
#  O5: [GATE]
#  O6: [GATE2]
#  O7: [GATE3]

# CONTROLLER 1:
#  S1.1: [Faders]
#  S1.2: [Funstuff] Various experimental modifications of the playing order
#  S1.3: [Buttons] Button mode: up=start/end, mid=gates, down=skip
#  S1.4: [Octave] Octave switch
#  S1.5: [Form] up/down select form AAAB, 16 steps, up=edit A, down = edit B, mid = normal, no form
#  S1.6: [Direct] Direction: up=backward, mid=forward, down=random
#  S1.7: [Quant] Quantization: up=pentatonic, mid=scale, down=chromatic
#  S1.8: [Lucky] up: randomize faders, down=randomize buttons
#  S1.9: [Tuning] up=tuning mode, down=compose mode
#  S1.10: [Preset] Preset: up=1, mid=2, down=3

# CONTROLLER 2:
#  S2.1: [FADER] Fader mode. 6 = extra CV, 7 = CV track 2
#  S2.2: [FUN] Autoreset, Shift, other fun stuff. Off at 0
#  S2.3: [BUT] Button mode: gates, start/end, skip
#  S2.4: [FORM] Form part A, no forms, part B
#  S2.5: [DIR] forward, random, backward
#  S2.6: [LUCKY] Lucky faders / none / buttons
#  S2.7: [OCT] Octave switch
#  S2.8: [QUA] Quantize to Scale, Chromatic scale, Pentatonic
#  S2.9: [TUNE] Compose, Normal, Tuning mode
#  S2.10: [PSET] Preset 1, 2 or 3

# CONTROLLER 4:
#  B4.8: [CLEAR]

[s10]
[m4]
[m4]
[p2b8]

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

[lfo]
    hz = 5
    square = N1

# Das
[copy]
    input = I1
    output = _CLOCK

[lfo]

[lfo]

[lfo]

[lfo]

[lfo]

[lfo]

# -------------------------------------------------
# Rotary switch 1
# -------------------------------------------------

# Fader mode and selection of additional CVs
# 0. Pitch
# 1. Pitch randomization
# 2. Gate propability
# 3. Repeats
# 4. Gate pattern
# 5. Ratchets.
# 6. Extra CV (Velocity)
# 7. Extra CV 2 - independent (CC1)
[switch]
    offset = S1.1
    output1 = _FADERMODE
    input1 = 0
    input2 = 1
    input3 = 2
    input4 = 3
    input5 = 4
    input6 = 5
    input7 = 10
    input8 = 100

[compare]
    input = _FADERMODE
    compare = 100
    ifless = 1
    output = _SELECT_MELODY_SEQ

[compare]
    input = _FADERMODE
    compare = 100
    ifequal = 1
    output = _SELECT_MODULATION_SEQ

# -------------------------------------------------
# Rotary switch 2
# -------------------------------------------------

# Switch position 1: Select pattern 2 (--> <-)
# Switch position 2: Select pattern 3 (--> <-- ->)
# Switch position 3: Select pattern 6 (random skips)
[switch]
    input1 = _DEFAULTPATTERN
    input2 = 2
    input3 = 3
    input4 = 6
    input5 = _DEFAULTPATTERN
    input6 = _DEFAULTPATTERN
    input7 = _DEFAULTPATTERN
    input8 = _DEFAULTPATTERN
    offset = S1.2
    output1 = _PATTERN

# Switch position 4: Autoreset every 3rd clock pulse
# Switch position 5: Autoreset every 16th clock pulse
[switch]
    input1 = 0
    input2 = 0
    input3 = 0
    input4 = 0
    input5 = 3
    input6 = 16
    input7 = 0
    input8 = 0
    offset = S1.2
    output1 = _AUTORESET

# Switch position 6: Shift steps by 1
# Switch position 7: Shift steps by 4
[switch]
    input1 = 0
    input2 = 0
    input3 = 0
    input4 = 0
    input5 = 0
    input6 = 0
    input7 = 1
    input8 = 4
    offset = S1.2
    output1 = _SHIFTSTEPS

# -------------------------------------------------
# Small switches
# -------------------------------------------------

[switch]
    offset = S1.3
    input1 = 3 # Gates
    input2 = 0 # Start / end
    input3 = 1 # skip
    output1 = _BUTTONMODE

# This switch changes the direction of the melody sequencer. In the middle position it enabled random jumps.
[switch]
    offset = S1.6
    input1 = 0
    input2 = 0
    input3 = 1
    output1 = _DIRECTION

# Second switch circuit for selecting the random pattern
[switch]
    offset = S1.6
    input1 = 7
    input2 = 0
    input3 = 0
    output1 = _DEFAULTPATTERN

[switch]
    offset = S1.9
    input1 = 0
    input2 = 0
    input3 = 1
    output1 = _TUNINGMODE

[switch]
    offset = S1.9
    input1 = 1
    input2 = 0
    input3 = 0
    output1 = _COMPOSEMODE

[switch]
    offset = S1.7
    input1 = 0
    input2 = 2
    input3 = 2
    output1 = _QUANTIZE

[switch]
    offset = S1.7
    input1 = 0
    input2 = 1
    input3 = 0
    output1 = _FULLSCALE

[switch]
    offset = S1.8
    input1 = 0.5
    input2 = 0
    input3 = 1
    output1 = _LUCKYAMOUNT

[switch]
    offset = S1.8
    input1 = 1
    input2 = 0
    input3 = 0
    output1 = _LUCKYBUTTONS
    output2 = _LUCKYFADERS

[switch]
    offset = S1.5
    input1 = 1
    input2 = 0
    input3 = 1
    output1 = _FORM

[switch]
    offset = S1.5
    input1 = 1
    input2 = 0
    input3 = 0
    output1 = _PAGE

# -------------------------------------------------
# Melody sequencer
# -------------------------------------------------

# 0: Pitch
# 1: Pitch randomization
# 2: Gate propability
# 3: Repeats
# 4: Gate pattern (once, every, hold, tie)
# 5: Ratchets
# 6: Velocity (CV2)
# 7: Independent modulation sequencer (CV3)
[motoquencer]
    autoreset = _AUTORESET
    buttonmode = _BUTTONMODE
    clearstartend = _FORM
    clock = _CLOCK
    composemode = _COMPOSEMODE
    cvbase = P4.1
    cvrange = P4.2 * 4V
    degree = I4 * 120
    direction = _DIRECTION
    fadermode = _FADERMODE
    clear = B4.8
    form = _FORM
    linktonext = 1
    luckyamount = _LUCKYAMOUNT
    luckybuttons = _LUCKYBUTTONS * _SELECT_MELODY_SEQ
    luckyfaders = _LUCKYFADERS * _SELECT_MELODY_SEQ
    numfaders = 8
    numsteps = 8 * _FORM + 8
    page = _PAGE
    pattern = _PATTERN
    preset = S1.10
    quantize = _QUANTIZE
    root = I3 * 120
    select = _SELECT_MELODY_SEQ
    select1 = 1
    select3 = 1
    select5 = 1
    select7 = 1
    select9 = _FULLSCALE
    select11 = 1
    select13 = _FULLSCALE
    shiftsteps = _SHIFTSTEPS
    tuningmode = _TUNINGMODE
    cv = _CABLE1
    gate = O5

[motoquencer]
    quantize = 0
    cvbase = 0
    cvrange = 8V
    preset = S1.10
    clear = B4.8
    cv = O2
    gate = O6

[copy]
    input = 7 / 120
    output = N4

[copy]
    input = S1.4 * 1V + _CABLE1
    output = O1

# -------------------------------------------------
# Modulation sequencer
# -------------------------------------------------

[motoquencer]
    buttonmode = _BUTTONMODE
    clear = B4.8
    clock = _CLOCK
    composemode = _COMPOSEMODE
    cvbase = 0
    cvrange = 1
    fadermode = 0
    holdcv = 0
    luckyamount = _LUCKYAMOUNT
    luckybuttons = _LUCKYBUTTONS * _SELECT_MODULATION_SEQ
    luckyfaders = _LUCKYFADERS * _SELECT_MODULATION_SEQ
    preset = S1.10
    quantize = 0
    select = _SELECT_MODULATION_SEQ
    cv = O3
    gate = O7

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

[midiout]
    pitch1 = O1 + 2V
    gate1 = O5
    velocity1 = O2 + 0.2
#   channel = S1.2 + 1 # You could use that switch for selecting the MIDI channel
    ccnumber1 = 1
    cc1 = O3
    usb = 1
    activesensing = 0
    clock = _CLOCK
