# (C) Guitar Machine
# LABELS: master=18

# Trigger und Hüllkurven für die beiden Akkordstimmen

# INPUTS:
#  I1: [Clock]
#  I2: [Reset]

# OUTPUTS:
#  O1: [Env CH1]
#  O3: [Filt Left]
#  O4: [Filt Right]
#  O5: [CH2-1]
#  O6: [CH2-2]
#  O7: [CH2-3]
#  O8: [CH2-4]

# GATES ON MODULE 1:
#  G1.1: [LB Trig] Trigger for low bass
#  G1.2: [Gate CH]
#  G1.5: [CH Trig 1]
#  G1.6: [CH Trig 2]
#  G1.7: [CH Trig 3]
#  G1.8: [CH Trig 4]

# CONTROLLER 1:
#  S1.1: [Euklid]
#  S1.2: [Delay CH2] Trigger delay for CH2, in clock ticks per voice
#  S1.3: [8/16/32]
#  S1.4: [Branches]
#  S1.5: [Triplets]
#  S1.6: [Loop]
#  S1.7: [LB src] lo: bars, mid: CH1, up: CH2
#  S1.8: [LB bars] lo: 1, mid: 2, up: 4
#  S1.9: [Source 1] Trigger source CH1: Algo/Euklid/Manual
#  S1.10: [Source 2] Trigger source CH2: Algo/Euklid/Manual

# CONTROLLER 2:
#  E2.1: [CH2 Harp]
#  E2.2: [Tide] Depth of tide (left = slow, right = fast)
#  E2.3: [Tide speed]
#  E2.4: [Cutoff]

# CONTROLLER 3:
#  B3.1: [Step 1]
#  B3.2: [...]
#  B3.3: [...]
#  B3.4: [...]
#  B3.5: [...]
#  B3.6: [...]
#  B3.7: [...]
#  B3.8: [...]
#  B3.9: [...]
#  B3.10: [...]
#  B3.11: [...]
#  B3.12: [...]
#  B3.13: [...]
#  B3.14: [...]
#  B3.15: [...]
#  B3.16: [Step 16]
#  B3.17: [Fills]
#  B3.18: [Accents]
#  B3.19: [Alternate]
#  B3.20: [Length] Einstellung Länge Algoquencer
#  B3.21: [Long gate] Use gatelength = 1 Clock when on
#  B3.22: [Clkdiv] Clock divider for Chord rhythm
#  B3.23: [Overdub]
#  B3.24: [16 | 32]
#  B3.25: [Pad CH1]
#  B3.26: [LB] Enable low bass
#  B3.27: [FM loop]
#  B3.28: [Beat loop] Looper for playing steps
#  B3.29: [Mute CH1]
#  B3.30: [Mute CH2]
#  B3.31: [Reset]
#  B3.32: [Manual] Manual trigger for Chords

# CONTROLLER 4:
#  E4.1: [Activity]
#  E4.2: [CH2 Attack]
#  E4.3: [CH1 Accents]
#  E4.4: [CH1 Attack] Attack CH1

# CONTROLLER 5:
#  E5.1: [CH2 Speed ?]
#  E5.2: [CH2 Release]
#  E5.3: [CH1 Speed ?]
#  E5.4: [CH1 Release] Decay / Release CH1

# CONTROLLER 6:
#  E6.1: [CH2 Shape]
#  E6.3: [CH1 Shape]
#  E6.4: [CH1 Sustain] Sustain Ch1

# CONTROLLER 7:
#  E7.1: [CH2 Level ?]
#  E7.2: [CH2 Level]
#  E7.3: [CH1 Level ?]
#  E7.4: [CH1 Level] Level Ch1

[s10]
[e4]
[b32]
[e4]
[e4]
[e4]
[e4]

# -------------------------------------------------
# Inputs
# -------------------------------------------------

[copy]
    input = I1
    output = _CLOCK

[copy]
    input = I2 + B3.31
    output = _RESET

# Check if the state of the clock is running and provide this as a 0/1 value.
# We assume a stopped clock if no tick has arrived for 3 seconds. This means that
# the BPM is limited to 1/12 BPM.
[contour]
    trigger = _CLOCK
    hold = 3
    output = _CLOCK_RUNNING
    attack = 0
    decay = 0
    sustain = 0
    release = 0

# -------------------------------------------------
# Clock divider
# -------------------------------------------------

[button]
    button = B3.22
    led = L3.22
    states = 1
    output = _CLOCK_DIVISION_MODE
    inverted = _NO_CLOCK_DIVISION_MODE

[buttongroup]
    select = _CLOCK_DIVISION_MODE
    button1 = B3.1
    button2 = B3.2
    button3 = B3.3
    button4 = B3.4
    button5 = B3.5
    button6 = B3.6
    button7 = B3.7
    button8 = B3.8
    led1 = L3.1
    led2 = L3.2
    led3 = L3.3
    led4 = L3.4
    led5 = L3.5
    led6 = L3.6
    led7 = L3.7
    led8 = L3.8
    value1 = 1
    value2 = 2
    value3 = 4
    value4 = 8
    value5 = 16
    value6 = 32
    value7 = 64
    value8 = 128
    output = _CLOCK_DIVISION

[clocktool]
    clock = _CLOCK
    divide = _CLOCK_DIVISION
    output = _DIVIDED_CLOCK
    reset = _RESET

# -------------------------------------------------
# Algoquencer
# -------------------------------------------------

[encoder]
    encoder = E4.1
    mode = 2
    outputoffset = 0.5
    outputscale = 0.5
    color = 0
    negativecolor = 1.1
    button = _RESET_ACTIVITY
    clear = _RESET_ACTIVITY
    notch = 0.1
    output = _ACTIVITY

[button]
    button = B3.17
    led = L3.17
    offvalue = 0
    onvalue = 0.5
    output = _FILLS

[algoquencer]
    select = _NO_CLOCK_DIVISION_MODE
    clock = _DIVIDED_CLOCK
    reset = _RESET
    activity = _ACTIVITY
    dejavu = 1
    morphs = 0.1
    button1 = B3.1
    button2 = B3.2
    button3 = B3.3
    button4 = B3.4
    button5 = B3.5
    button6 = B3.6
    button7 = B3.7
    button8 = B3.8
    button9 = B3.9
    button10 = B3.10
    button11 = B3.11
    button12 = B3.12
    button13 = B3.13
    button14 = B3.14
    button15 = B3.15
    button16 = B3.16
    led1 = L3.1
    led2 = L3.2
    led3 = L3.3
    led4 = L3.4
    led5 = L3.5
    led6 = L3.6
    led7 = L3.7
    led8 = L3.8
    led9 = L3.9
    led10 = L3.10
    led11 = L3.11
    led12 = L3.12
    led13 = L3.13
    led14 = L3.14
    led15 = L3.15
    led16 = L3.16
    alternatebutton = B3.19
    lengthbutton = B3.20
    accentbutton = B3.18
    fills = _FILLS
    fillorder = 3
    branches = 1
    gatelength = _GATE_LENGTH
    gate = _SEQ_GATE_UNBRANCHED
    accent = _SEQ_ACCENT
    branch = _C1_BRANCH

[compare]
    input = _C1_BRANCH
    compare = 2
    ifequal = 1
    output = _C1_BRANCH_IS_2

[compare]
    input = _C1_BRANCH
    compare = 1
    ifequal = 1
    output = _C1_BRANCH_IS_1

[switch]
    input1 = 1 * _SEQ_GATE_UNBRANCHED
    input2 = _C1_BRANCH_IS_2 * _SEQ_GATE_UNBRANCHED
    input3 = _C1_BRANCH_IS_1 * _SEQ_GATE_UNBRANCHED
    offset = S1.4
    output1 = _SEQ_GATE

# -------------------------------------------------
# Euclidean
# -------------------------------------------------

# Number of beats
[switch]
    input1 = 1
    input2 = 2
    input3 = 2
    input4 = 3
    input5 = 5
    input6 = 5
    input7 = 7
    input8 = 9
    offset = S1.1
    output1 = _EUKLID_BEATS

# Length
[switch]
    input1 = 3
    input2 = 5
    input3 = 7
    input4 = 7
    input5 = 12
    input6 = 16
    input7 = 16
    input8 = 16
    offset = S1.1
    output1 = _EUKLID_LENGTH

# Start offset
[switch]
    input1 = 0
    input2 = 0
    input3 = 0
    input4 = 0
    input5 = 0
    input6 = 1
    input7 = 2
    input8 = 3
    offset = S1.1
    output1 = _EUKLID_OFFSET

[euklid]
    clock = _DIVIDED_CLOCK
    reset = _RESET
    length = _EUKLID_LENGTH
    beats = _EUKLID_BEATS
    offset = _EUKLID_OFFSET
    output = _GATE_EUKLID

[gatetool]
    inputgate = _GATE_EUKLID
    outputtrigger = _TRIGGER_EUKLID

# -------------------------------------------------
# Manual triggers
# -------------------------------------------------

[copy]
    input = S1.5 * 3 + S1.3
    output = _MANUAL_CLOCK_TIMING

# Clock multiplier for manual gates
[switch]
    input1 = 1
    input2 = 1
    input3 = 2
    input4 = 3
    input5 = 3
    input6 = 3
    input7 = 1
    input8 = 1
    input9 = 2
    offset = _MANUAL_CLOCK_TIMING
    output1 = _MANUAL_CLOCK_MULT

# Clock divider for ribbon
[switch]
    input1 = 2
    input2 = 1
    input3 = 1
    input4 = 4
    input5 = 2
    input6 = 1
    input7 = 6
    input8 = 3
    input9 = 3
    offset = _MANUAL_CLOCK_TIMING
    output1 = _MANUAL_CLOCK_DIV

[clocktool]
    clock = _DIVIDED_CLOCK
    reset = _RESET
    multiply = _MANUAL_CLOCK_MULT
    divide = _MANUAL_CLOCK_DIV
    output = _MANUAL_CLOCK

[sample]
    input = B3.32
    sample = _MANUAL_CLOCK
    output = _CLOCKED_MANUAL_BUTTON

[ifequal]
    input1 = _GATE_LENGTH
    input2 = 1
    ifequal = _CLOCKED_MANUAL_BUTTON
    else = _CLOCKED_MANUAL_BUTTON * _MANUAL_CLOCK
    output = _MANUAL_GATE_UNLOOPED

# -------------------------------------------------
# Looper for manual triggers
# -------------------------------------------------

[button]
    button = B3.24
    offvalue = 16
    onvalue = 32
    led = L3.24
    output = _MANUAL_LOOP_LENGTH

[button]
    button = B3.23
    led = L3.23
    output = _MANUAL_LOOP_OVERDUB

[button]
    button = B3.28
    led = L3.28
    output = _MANUAL_LOOP_SWITCH

# CV looper for the ribbon input (pitch) signal and the "Ribbon is hold down" signal. The ribbon pressure
# is done in a second looper.
[cvlooper]
#   bypass = _MANUAL_LOOP_BYPASS
    clock = _DIVIDED_CLOCK
    cvin = 0
    gatein = _MANUAL_GATE_UNLOOPED
    length = _MANUAL_LOOP_LENGTH
    loopswitch = _MANUAL_LOOP_SWITCH
    overdub = _MANUAL_LOOP_OVERDUB
    overlay = 1
    reset = _RESET
    tapespeed = 0.2
    gateout = _MANUAL_TRIGGER_UNBRANCHED

[switch]
    input1 = 1 * _MANUAL_TRIGGER_UNBRANCHED
    input2 = _C1_BRANCH_IS_2 * _MANUAL_TRIGGER_UNBRANCHED
    input3 = _C1_BRANCH_IS_1 * _MANUAL_TRIGGER_UNBRANCHED
    offset = S1.4
    output1 = _MANUAL_TRIGGER_UNCHECKED

[copy]
    input = _MANUAL_TRIGGER_UNCHECKED * _CLOCK_RUNNING
    output = _MANUAL_TRIGGER

# -------------------------------------------------
# Cutoff looper
# -------------------------------------------------

[encoder]
    encoder = E2.4
    output = _CUTOFF_POT
    movedup = _MOVED_UP
    moveddown = _MOVED_DOWN

[button]
    button = B3.27
    output = _FM_LOOP_RECORDING
    inverted = _FM_LOOP_PLAYING

[once]
    trigger = _STOP_LOOPER_AT_START
    delay = 1

[mixer]
    input1 = _MOVED_UP * _FM_LOOP_PLAYING
    input2 = _MOVED_DOWN * _FM_LOOP_PLAYING
    input3 = _STOP_LOOPER_AT_START
    output = _STOP_FILT_CV_LOOPER

# State von Bypass
[flipflop]
    reset = _FM_LOOP_RECORDING * -1 + 1
    set = _STOP_FILT_CV_LOOPER
    startvalue = 1
    output = _FM_LOOP_BYPASS

[recorder]
    cvin = _CUTOFF_POT
    cvout = _CH1_FIXED_CUTOFF
    loop = 1
    mode = _FM_LOOP_RECORDING + 1
    bypass = _FM_LOOP_BYPASS
    recordled = L3.27

[lfo]
    hz = 3
    square = _FM_LOOPER_LED_LFO

[select]
    input = _FM_LOOPER_LED_LFO
    output = L3.27

[select]
    select = _FM_LOOP_BYPASS
    input = 0
    output = L3.27

[select]
    select = _FM_LOOP_RECORDING
    input = 1
    output = L3.27

# -------------------------------------------------
# Envelope encoders
# -------------------------------------------------

# CH1 Accents
[encoder]
    encoder = E4.3
    color = 1.1
    output = _CH1_ACCENTS_POT

# CH1 Attack
[encoder]
    encoder = E4.4
    color = 0.8
    output = _CH1_ATTACK_POT

# CH1 Decay + Release
[encoder]
    encoder = E5.4
    color = 1.2
    output = _CH1_RELEASE_POT

# CH1 Sustain
[encoder]
    encoder = E6.4
    color = 0.8
    output = _CH1_SUSTAIN_POT

# CH1 Shape (lin / log)
[encoder]
    encoder = E6.3
    color = 0.2
    output = _CH1_SHAPE_POT

# CH1 Level
[encoder]
    encoder = E7.4
    color = 0.4
    output = _CH1_LEVEL_POT

# CH1 Level
[encoder]
    encoder = E7.2
    color = 0.4
    output = _CH2_LEVEL_POT

# (free)
# [encoder]
#   encoder = E5.2
#   color = 0

# CH1 Level animation
[encoder]
    encoder = E7.3
    color = 0.73
    output = _CH1_LEVEL_ANIMATION_POT

# CH1 Speed animation
[encoder]
    encoder = E5.3
    color = 1
    output = _CH1_SPEED_ANIMATION_POT

[encoder]
    encoder = E5.1
    color = 1
    outputoffset = 1
    outputscale = 3
    output = _CH2_RAND_RELEASE_LONGER

# CH1 Shape (lin / log)
[encoder]
    encoder = E6.1
    color = 0.2
    output = _CH2_SHAPE_POT

[encoder]
    encoder = E7.1
    output = _CH2_RAND_LEVEL_AMOUNT

# CH1 Attack
[encoder]
    encoder = E4.2
    color = 0.8
    output = _CH2_ATTACK_POT

# CH1 Decay + Release
[encoder]
    encoder = E5.2
    color = 1.2
    output = _CH2_RELEASE_POT

# -------------------------------------------------
# Chords 1
# -------------------------------------------------

# Fade out when master clock stops
[contour]
    trigger = _CLOCK
    hold = 1
    attack = 0.1
    sustain = 1
    release = 3
    releaseshape = 0.8
    level = 1.2
    output = _C1_FADEOUT_RAMP

# [copy]
#   input = -1 * 0.2 + _C1_FADEOUT_RAMP
#   output = _C1_FADEOUT_LEVEL

[switch]
    input1 = 1
    input2 = -0.2 + _C1_FADEOUT_RAMP
    offset = _CH1_PAD
    output1 = _C1_FADEOUT_LEVEL

[button]
    button = B3.21
    led = L3.21
    onvalue = 1.1
    offvalue = 0.01
    output = _GATE_LENGTH

[button]
    button = B3.29
    led = L3.29
    output = _CH1_UNMUTED_UNSLEWED

[slew]
    input = _CH1_UNMUTED_UNSLEWED * _C1_FADEOUT_LEVEL
    slew = 0.1
    linear = _CH1_UNMUTED

[button]
    button = B3.25
    led = L3.25
    offvalue = 0
    onvalue = 0.5
    output = _CH1_PAD
    negated = _CH1_NO_PAD

[slew]
    input = _CH1_PAD * 0.5
    linear = _CH1_PAD_LEVEL
    slewup = 0.3
    slewdown = 0

[switch]
    input1 = 0 + _MANUAL_TRIGGER
    input2 = _TRIGGER_EUKLID + _MANUAL_TRIGGER
    input3 = _SEQ_GATE + _MANUAL_TRIGGER
    offset = S1.9
    output1 = _CH1_GATE

[copy]
    input = _CH1_SPEED_ANIMATION_POT * 3 + 1
    output = _CH1_RAND_RELEASE_LONGER

[math]
    input1 = _CH1_RAND_RELEASE_LONGER
    reciprocal = _CH1_RAND_RELEASE_SHORTER

[random]
    clock = _CH1_GATE
    minimum = _CH1_RAND_RELEASE_SHORTER
    maximum = _CH1_RAND_RELEASE_LONGER
    output = _CH1_RANDOM_RELEASE

[copy]
    input = _CH1_LEVEL_ANIMATION_POT * 0.4
    output = _CH1_RAND_LEVEL_AMOUNT

[copy]
    input = _CH1_RAND_LEVEL_AMOUNT * -1
    output = _CH1_RAND_LEVEL_AMOUNT_NEG

[copy]
    input = 0.6
    output = _CH1_UNRAND_LEVEL

[random]
    clock = _CH1_GATE
    minimum = 1 * _CH1_RAND_LEVEL_AMOUNT_NEG + _CH1_UNRAND_LEVEL
    maximum = 1 * _CH1_RAND_LEVEL_AMOUNT + _CH1_UNRAND_LEVEL
    output = _CH1_RANDOM_LEVEL

[ifequal]
    input1 = _SEQ_ACCENT
    input2 = 0
    ifequal = _CH1_ACCENTS_POT * -0.4 + 1
    else = _CH1_ACCENTS_POT * 0.4 + 1
    output = _CH1_ACCENT_IMPACT

[copy]
    input = _CH1_RANDOM_LEVEL * _CH1_LEVEL_POT
    output = _CH1_LEVEL_WO_ACCENT

[copy]
    input = _CH1_LEVEL_WO_ACCENT * _CH1_ACCENT_IMPACT
    output = _CH1_LEVEL

[contour]
    attack = _CH1_ATTACK_POT + 0.05
    decay = _CH1_RELEASE_POT * _CH1_RANDOM_RELEASE + 0.05
    release = _CH1_RELEASE_POT * _CH1_RANDOM_RELEASE + 0.05
    sustain = _CH1_SUSTAIN_POT
    level = _CH1_LEVEL * _CH1_NO_PAD
    gate = _CH1_GATE
    decayshape = _CH1_SHAPE_POT * -1 + 1
    releaseshape = _CH1_SHAPE_POT * -1 + 1
    output = _CH1_ENVELOPE
    shape = 0.1

[encoder]
    encoder = E2.2
    clear = _TIDE_BIPOLAR_CLEAR
    button = _TIDE_BIPOLAR_CLEAR
    mode = 2
    output = _TIDE_BIPOLAR

[compare]
    input = _TIDE_BIPOLAR
    compare = 0
    ifless = _TIDE_BIPOLAR * -1
    else = 0
    output = _TIDE_SLOW

[compare]
    input = _TIDE_BIPOLAR
    compare = 0
    ifgreater = _TIDE_BIPOLAR
    else = 0
    output = _TIDE_FAST

[encoder]
    encoder = E2.3
    output = _TIDE_SPEED_POT

[pot]
    pot = _TIDE_SPEED_POT
    slope = 2
    output = _TIDE_SPEED

[lfo]
    hz = _TIDE_SPEED * 20
    bipolar = 1
    triangle = _TIDE_LFO_FAST

[lfo]
    hz = _TIDE_SPEED * 1
    bipolar = 1
    triangle = _TIDE_LFO_SLOW

[mixer]
    input1 = _TIDE_SLOW * _TIDE_LFO_SLOW
    input2 = _TIDE_FAST * _TIDE_LFO_FAST
    output = _TIDE

[mixer]
    input1 = _CH1_FIXED_CUTOFF * 0.5
    input2 = _TIDE * -1
    input4 = _CH1_PAD_LEVEL
    output = _CUTOFF_LEFT

[mixer]
    input1 = _CH1_FIXED_CUTOFF * 0.5
    input2 = _TIDE * 1
    input4 = _CH1_PAD_LEVEL
    output = _CUTOFF_RIGHT

[mixer]
    input1 = _CH1_ENVELOPE * _CH1_NO_PAD
    input2 = _CH1_PAD_LEVEL * _CH1_PAD
    output = _VCA_LEVEL_OUTPUT

[copy]
    input = _VCA_LEVEL_OUTPUT * _CH1_UNMUTED
    output = O1

[copy]
    input = _CUTOFF_LEFT * _CH1_UNMUTED
    output = O3

[copy]
    input = _CUTOFF_RIGHT * _CH1_UNMUTED
    output = O4

[copy]
    input = _CH1_GATE * _CH1_NO_PAD
    output = G1.2

# -------------------------------------------------
# Chords 2
# -------------------------------------------------

[button]
    button = B3.30
    led = L3.30
    output = _CH2_UNMUTED_UNSLEWED

[slew]
    input = _CH2_UNMUTED_UNSLEWED
    slew = 0.1
    linear = _CH2_UNMUTED

[switch]
    input1 = 0 + _MANUAL_TRIGGER
    input2 = _TRIGGER_EUKLID + _MANUAL_TRIGGER
    input3 = _SEQ_GATE + _MANUAL_TRIGGER
    offset = S1.10
    output1 = _CH2_GATE

[encoder]
    encoder = E2.1
    output = _CH2_HARP

[copy]
    input = S1.2 + _CH2_HARP
    output = _CH2_DELAY

[triggerdelay]
    input = _CH2_GATE
    delay = _CH2_DELAY
    clock = _CLOCK
    gatelength = 0.01
    output = _CH2_TRIGGER1

[triggerdelay]
    input = _CH2_GATE
    delay = _CH2_DELAY * 2
    clock = _CLOCK
    gatelength = 0.01
    output = _CH2_TRIGGER2

[triggerdelay]
    input = _CH2_GATE
    delay = _CH2_DELAY * 3
    clock = _CLOCK
    gatelength = 0.01
    output = _CH2_TRIGGER3

[triggerdelay]
    input = _CH2_GATE
    delay = _CH2_DELAY * 4
    clock = _CLOCK
    gatelength = 0.01
    output = _CH2_TRIGGER4

[triggerdelay]
    input = _CH2_GATE
    delay = _CH2_DELAY * 5
    clock = _CLOCK
    gatelength = 0.01
    output = _CH2_TRIGGER5

[copy]
    input = _CH2_RAND_LEVEL_AMOUNT * -1
    output = _CH2_RAND_LEVEL_AMOUNT_NEG

[copy]
    input = 0.6
    output = _UNRAND_LEVEL

[random]
    clock = _CH2_TRIGGER1
    minimum = 1 * _CH2_RAND_LEVEL_AMOUNT_NEG + _UNRAND_LEVEL
    maximum = 1 * _CH2_RAND_LEVEL_AMOUNT + _UNRAND_LEVEL
    output = _CH2_RANDOM_LEVEL_1

[random]
    clock = _CH2_TRIGGER2
    minimum = 1 * _CH2_RAND_LEVEL_AMOUNT_NEG + _UNRAND_LEVEL
    maximum = 1 * _CH2_RAND_LEVEL_AMOUNT + _UNRAND_LEVEL
    output = _CH2_RANDOM_LEVEL_2

[random]
    clock = _CH2_TRIGGER3
    minimum = 1 * _CH2_RAND_LEVEL_AMOUNT_NEG + _UNRAND_LEVEL
    maximum = 1 * _CH2_RAND_LEVEL_AMOUNT + _UNRAND_LEVEL
    output = _CH2_RANDOM_LEVEL_3

[random]
    clock = _CH2_TRIGGER4
    minimum = 1 * _CH2_RAND_LEVEL_AMOUNT_NEG + _UNRAND_LEVEL
    maximum = 1 * _CH2_RAND_LEVEL_AMOUNT + _UNRAND_LEVEL
    output = _CH2_RANDOM_LEVEL_4

[math]
    input1 = _CH2_RAND_RELEASE_LONGER
    reciprocal = _CH2_RAND_RELEASE_SHORTER

[random]
    clock = _CH2_TRIGGER1
    minimum = _CH2_RAND_RELEASE_SHORTER
    maximum = _CH2_RAND_RELEASE_LONGER
    output = _CH2_RANDOM_RELEASE_1

[random]
    clock = _CH2_TRIGGER2
    minimum = _CH2_RAND_RELEASE_SHORTER
    maximum = _CH2_RAND_RELEASE_LONGER
    output = _CH2_RANDOM_RELEASE_2

[random]
    clock = _CH2_TRIGGER3
    minimum = _CH2_RAND_RELEASE_SHORTER
    maximum = _CH2_RAND_RELEASE_LONGER
    output = _CH2_RANDOM_RELEASE_3

[random]
    clock = _CH2_TRIGGER4
    minimum = _CH2_RAND_RELEASE_SHORTER
    maximum = _CH2_RAND_RELEASE_LONGER
    output = _CH2_RANDOM_RELEASE_4

[contour]
    attack = _CH2_ATTACK_POT + 0.001
    release = _CH2_RELEASE_POT * _CH2_RANDOM_RELEASE_1 + 0.01
    level = _CH2_RANDOM_LEVEL_1 * _CH2_LEVEL_POT
    trigger = _CH2_TRIGGER1 * _CH2_UNMUTED
    output = O5
    shape = _CH2_SHAPE_POT * -1 + 1

[contour]
    attack = _CH2_ATTACK_POT + 0.05
    release = _CH2_RELEASE_POT * _CH2_RANDOM_RELEASE_2 + 0.01
    level = _CH2_RANDOM_LEVEL_2 * _CH2_LEVEL_POT
    trigger = _CH2_TRIGGER2 * _CH2_UNMUTED
    output = O6
    shape = _CH2_SHAPE_POT * -1 + 1

[contour]
    attack = _CH2_ATTACK_POT + 0.05
    release = _CH2_RELEASE_POT * _CH2_RANDOM_RELEASE_3 + 0.01
    level = _CH2_RANDOM_LEVEL_3 * _CH2_LEVEL_POT
    trigger = _CH2_TRIGGER3 * _CH2_UNMUTED
    output = O7
    shape = _CH2_SHAPE_POT * -1 + 1

[contour]
    attack = _CH2_ATTACK_POT + 0.05
    release = _CH2_RELEASE_POT * _CH2_RANDOM_RELEASE_4 + 0.01
    level = _CH2_RANDOM_LEVEL_4 * _CH2_LEVEL_POT
    gate = _CH2_TRIGGER4 * _CH2_UNMUTED
    output = O8
    shape = _CH2_SHAPE_POT * -1 + 1

# -------------------------------------------------
# Low bass
# Sends triggers for the low bass (no pitch)
# 
# Switch S1.7 selects the type of the triggers
# 
# 2 (up)  Use CH2 trigger nr. 5
# 1 (mid) Use CH1 trigger
# 0 (low) Trigger on the beginning of every 1st, 2nd, or 4th bar depending on S1.8
# -------------------------------------------------

[button]
    button = B3.26
    output = _LB_ENABLED

[contour]
    trigger = _LB_GATE * _LB_ENABLED
    release = 0.3
    level = 0.5
    output = _LB_LED_GATE

[copy]
    input = _LB_ENABLED * 0.1 + _LB_LED_GATE
    output = L3.26

[switch]
    input1 = 1
    input2 = 2
    input3 = 4
    offset = S1.8
    output1 = _LB_BARS

[clocktool]
    clock = _DIVIDED_CLOCK
    divide = _LB_BARS * 16
    reset = _RESET
    output = _LB_BAR_TRIGGER

[switch]
    input1 = _LB_BAR_TRIGGER
    input2 = _CH1_GATE
    input3 = _CH2_TRIGGER5
    offset = S1.7
    output1 = _LB_GATE

[gatetool]
    inputgate = _LB_GATE * _LB_ENABLED
    outputtrigger = G1.1
