import Sound.Tidal.ParVagues.Control

do
let pontH = (someCyclesBy "<0!32 1!8 0!24>" (# hpf (slow 8 $ range 0 500 saw)))
let pontL = (whenmod 16 12 (# lpf 2000))
let toPontL = (every' 16 11 (# lpf 5000))
let chords = "<c'min'2!4 c'maj'2!4>"
let prog = ("<cs5!4 a4 a4 b4 gs4>")
let chorus = pF "chorus"
let mix = pF "mix"
let modIndex = pF "modIndex" -- 0.2
let gDJF1 = (# djfbus 1 (range 0.1 0.9 "^49"))
let gDJF2 = (# djfbus 2 (range 0.1 0.9 "^50"))
let g1 = gDJF1
let g2 = gDJF2
setcps 0.5
d1 $ g1
  $ fix (|* gain 0.75) "kick:5"
  $ midiOn "^41" ( -- KICK RUN
    ((>| "[jazz,kick:5]*<4 4 4 [4!3 8] 4 4 2 <2 [2 8]>>") . (|* gain 0.8))
  )
  $ midiOff "^41" (<| "[k([1|<3!3 5 [3 8]>],8)]*<1!16 2!16>")
  $ "[jazz,cpu]"
  # midiG' "^78" 0 1.4
d2 $ g1  -- Breathing snare contretemps
  $ midiOn "^42" (fast "<2 2 2 2 4 2 2 4 4>")
  $ "~ [snare:12,drum:2]"
  # speed (range 0 4 "^51")
  # midiG' "^79" 0.5 1.3
d3 -- Runny Maracas
  $ g1
  $ midiOn "^43" (ply 2)
  $ whenmod 16 8 (often $ fast 2)
  $ someCyclesBy "<1!16 0!16>" (often $ slow "2!3 1")
  $ fix ((|* gain 0.9) . (# release 0.8)) (n 9)
  $ "hh27*8"
  # n "2 <2 <[2|9] [9 <9 ~> <~ 9> 2]>>"
  # midiG' "^80" 0.25 1.5
  # note (range "-12" 12 "^31")
d6 $ g2 -- Guitar riffs
  $ whenmod 16 12 (off "h" (
    chop 4
  . (# cut 61)
  ))
  $ slice 4 (
    whenmod 16 8 (+| "0 <0!6 ~ ~>")
    "<0!4 1 1 2 3>"
  )
  $ note 2 -- correction
  # "punk"
  # cut 6
  # attack (range 0.5 1 "^34")
  # crushbus 61 (range 16 1.1 "^54")
  # pan 0.9
  # room "<0.13!3 0.05>"
  # sz "<0.6!3 0.9>"
  # midiG' "^81" 0.4 1.5
d4 -- Rhodes base + chordsQ
  $ g2
  $ midiOn "^76" (superimpose ( -- ARPS <3
    (|+ note 12)
    . sometimesBy "0 0.5!7" rev
    . fast "1 2"
    . arp "pinkyup"
    . (|+ pan 0.1)
    . (|* gain 1.2)
  ))
  $ note ((
    "<0 ~> 0"
    + prog
    + "0 -12"
    - "12" -- Octave
  ))
  # "FMRhodes1"
  # modIndex "[0,5,10]"
  # pan 0.8
  # crushbus 41 (range 10 4 "^32")
  # roombus  42 (range 0 0.8 "^32")
  # szbus    43 (range 0.45 0.9 "^32")
  # midiG' "^82" 0.3 1.3
d8 $ g2 -- Electrified laggy moog
  $ midiOn "^92" (ply 2)
  $ midiOn "^60" ((|- note 12))
  -- FIXME(#94) d8 drives more controls than the grid gives it (BT8 + BL8). ^91 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^91 for its new owner also moves this. NOT commented out: this is a `$`-step and something above it is a partial application waiting for it, so removing it would stop the whole block compiling. Fold it onto d8's own control with gSel.
  -- FIXME(#94) d8 drives more controls than the grid gives it (BT8 + BL8). ^91 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^91 for its new owner also moves this. NOT commented out: this is a `$`-step and something above it is a partial application waiting for it, so removing it would stop the whole block compiling. Fold it onto d8's own control with gSel.
  $ midiOn "^91" (segment "4 <4 <8 [8 16]>>")
  $ note (prog + "0 <12!4 12 12 16 <12 16>>" - 12)
  # "moog:2"
  # crushbus 8 (range 10 3.4 "^36")
  # midiG' "^83" 0 1.5
  # legato 2
  # cut 8
  # pan 0.6
  # release 100
d5 $ g2 -- Choirs + arps
  $ juxBy "0.7" (
    arp "<up <up down>>"
    . midiOn "^57" ((|- note 12))
    . (|+| note "[0,7,12]*2")
  )
  $ "moogBass"
  # note (prog + "[0,24]")
  # octave 3
  # crushbus 51 (range 13 1.5 "^33")
  # midiG' "^84" 0 1.6
  # pan 0.2
  # chorus 0.6
