# LIBRARY: number=1, version=1.0

# Arpeggiator with one P2B8
# The arpeggiator is an algorithmic melody generator. Usually there
# is no randomization but several algorithms, which can be combined
# in order to create complex and interesting patterns. This version
# just needs one P2B8 but still allows to select and combine all of
# the arpeggiator circuit's algorithms. It can be clocked externally
# or internally.
# INPUTS
# OUTPUTS
# POTS
# BUTTONS

# INPUTS:
#  I1: [CLK] optional external clock

# OUTPUTS:
#  O1: [CLK] internal clock
#  O3: [ENV] envelope
#  O4: [V/O] pitch (V/oct)

# CONTROLLER 1:
#  P1.1: [SPE] Speed of internal clock
#  P1.2: [PAT] Arpeggio pattern (0 ... 6)
#  B1.1: [DIR] Direction up (off) or down (on)
#  B1.2: [PNG] Enable ping pong: go forth and back
#  B1.3: [FLY] Switch on butterfly mode
#  B1.4: [OCT] Set octaving mode in three state: off, up down
#  B1.5: [DRP] When on, drop some of the notes (off / x. / xx. / x..)
#  B1.6: [STA] Enforce start note: off / 3rd / 5th / 7th
#  B1.7: [TRI] Switch between all notes of the scale (off) and just the triad (on)
#  B1.8: [MIN] Switch between minor (off) and major (on)

[p2b8]

# -------------------------------------------------
# Master clock
# -------------------------------------------------

# Send the clock the the normalization of input 1. In the
# rest of the patch I1 will be used as input, and you can
# override the internal clock by patching an external in.
[lfo]
    hz = 40 * P1.1
    square = N1

# Make the clock also available on O1
[copy]
    input = N1
    output = O3

[copy]
    input = I1
    output = O1

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

[button]
    button = B1.1
    led = L1.1
    output = _DIRECTION

[button]
    button = B1.2
    led = L1.2
    output = _PINGPONG

[button]
    button = B1.3
    led = L1.3
    output = _BUTTERFLY

[button]
    button = B1.4
    led = L1.4
    value1 = 0
    value2 = 1
    value3 = 2
    output = _OCTAVES

[button]
    button = B1.5
    led = L1.5
    value1 = 0
    value2 = 1
    value3 = 2
    value4 = 3
    output = _DROP

[button]
    button = B1.6
    led = L1.6
    value1 = 0
    value2 = 3
    value3 = 5
    value4 = 7
    output = _STARTNOTE

[button]
    button = B1.7
    led = L1.7
    onvalue = 0
    offvalue = 1
    output = _SCALE

[button]
    button = B1.8
    led = L1.8
    offvalue = 7 # minor
    onvalue = 1 # major
    output = _DEGREE

# -------------------------------------------------
# Arpeggiator
# -------------------------------------------------

[arpeggio]
    clock = I1
    direction = _DIRECTION
    pingpong = _PINGPONG
    butterfly = _BUTTERFLY
    octaves = _OCTAVES
    drop = _DROP
    startnote = _STARTNOTE
    pattern = P1.2 * 6
    pitch = 1V
    range = 2V
    root = 0 # 0 means C
    degree = _DEGREE
    select1 = 1
    select3 = 1
    select5 = 1
    select7 = _SCALE
    select9 = _SCALE
    select11 = _SCALE
    select13 = _SCALE
    output = O4

# -------------------------------------------------
# Envelope generator
# -------------------------------------------------

# This envelope is optional. You can either use the output O1 for triggering a synth voice that has its own envelope.
# Or you use output 3 and use DROID also as the envelope generator for you synth.
# In that case you just need VCO, VCF and optionally a VCA.
[contour]
    gate = I1
    attack = 0.1
    sustain = 0.7
    output = O3
