import Sound.Tidal.ParVagues.Controls

-- Controls:
-- 1A 2A 3A 4A 5A 6A 7A 8A UP  DOWN
--^13 14 15 16 17 18 19 20 104 105
-- 1B 2B 3B 4B 5B 6B 7B 8B L   R
--^29 30 31 32 33 34 35 36 106 107
-- 1C 2C 3C 4C 5C 6C 7C 8C
--^49 50 51 52 53 54 55 56
-- 1F 2F 3F 4F 5F 6F 7F 8F
--^77 78 79 80 81 82 83 84
-- 1: Global        - DJF     Room    Size
-- 2: Kick          - TODO    TODO    TODO
-- 3: Drumroll      - Jux     Ply2    Pan
-- 4: Break         - sbSlice sbStri  TODO
-- 5: Etincelles    - LPF5&6  LPQ5&6  Crush5&6
-- 6: ArpElectrique - TODO    TODO    TODO
-- 7: Claps         - TODO    TODO    TODO
-- 8: Choirs        - Room    hpf     cutoff

do
setcps (120/60/4)
let gGain = "^77"
let gRoom = (|* room (range 0 0.5 "^29"))
let gSize = (|* size (range 0 0.8 "^13"))
let gG a = (gain (gGain * a)) -- gain Global
let gM a = (gG (range 0.3 0.8 a))
let gM' l h a = (gG (range l h a))
let gDJF = (midiDJF "^49" 200 9800 0 1000)
let g = (gDJF . gSize . gRoom . (# dry 0.98))
let novaOn  ch pat = (sometimesBy ch pat)
let novaOff ch pat = sometimesBy (1 - ch) (pat)
let prog = ("<f'maj7!3 g'sus4 f'maj7!3 g'sus4 f'maj7!3 <a'minor7 e'minor7> f'maj7!3 g'sus4>")
d1 $ g
  $ "jazz*4"
  # room 0.3 # dry 0.97
  # gM' 0 1 "^78"
d2 $ g
  $ sometimesBy ("^51") (jux rev)
  $ sometimesBy ("^31") (ply 2)
  $ whenmod 4 3 (mask "t . t t f t")
  $ "[gretsch:4,drum:2]*[4 8]"
  # gM' 0.5 1.4 "^79"
  # pan 0.6
  # lpf 4000
d3 $ g
  $ novaOn ("^76") (rev . slice 4 (run 4))
  $ novaOn ("^44") (striate 16)
  $ someCyclesBy ("^52") (
    slice 8 "[0 2 0 <6 4>]*2")
  $ "fbreak120:9"
  # gM' 0.5 1.3 "^80"
  # lpf 5000
  # cut 3
d4 $ g
  $ midiOn "^57" (superimpose (
    (|+ note 24)
    . chop (slow 4 "<1 2 4 8>")
    . arp "updown"
    . (|* gain 0.9)
  ))
  $ note prog
  # "bassWarsaw"
  # gM' 0 1.3 "^81"
  # lpq "^33"
  # room 0.5
  # octave 3
  # crush (range 10 4.2 "^53")
  # sz 0.8
d7 $ g
  $ whenmod 16 8 (fast 2)
  $ "~ cp*<1!3 2>"
  # note (-2)
  # gM' 0.2 1.2 "^83"
  # room 0.2
  # dry 0.99 # lpf 4000
d8 $ g -- CHOIRS
  $ off "h" (
    (|+ note 12)
    . (# legato "<0.75!3 0.5>")
    . (|* gain 0.8)
    )
  -- $ slice 4 (run 2)
  $ superimpose (|+ note 12)
  $ note (prog)
  # "moogBass"
  # octave 3
  -- # amp 0.5
  # crush (range 10 5.5 "^20")
  # hpf (range 0 10000 "^36")
  # cutoff (range 120 10000 "^56")
  # gM' 0.45 1.2 "^84"
