do
-- DESHADOW(#96): now global in BootTidal.hs; body kept in case it was music
-- let midiGGlobal = "^77" * 1.5
let _gainG ch     = (gain (midiGGlobal * ch)) -- gain Global
let midiG' ch l h = _gainG (range l h ch)     -- midiGain   control
let midiG  ch     = midiG' ch 0 1             -- let midiG ch val  = (gGain (ch * val))
let midiOn    ch    pat = someCyclesBy ch             pat
let midiOff   ch    pat = someCyclesBy (1 - ch)       pat
let midiNo    c1 c2 pat = someCyclesBy (1 - c1 - c2)  pat
let gDJF =  (# djfbus 1 (range 0.1 0.9 "^49"))
let g = gDJF
setcps (110/60/4)
let prog = "<c6'maj7'2 <g6'maj'2 g6'maj> d6'm9 <g6'maj g6'maj'4>>"
-- let prog = "<d6'm9 g6'maj'4>"
let progm = "<<c c e e> d e <d g>>"
d1 $ g
  $ midiOn "^41" (<| "k k k <k k*2 [~ k] k*2>") -- Kick it!
  $ midiOff "^41" (<| "k . k <~ [<~ k> <k ~>]>") -- RubADub
  $ "[jazz,909,kick:5]"
  # midiG' "^78" 0 1.5
d2 $ g
  $ whenmod 8 4 (ply "1 <1 2 1 1> <2 1 1 2> <1 1 2 1>")
  $ midiOn "^42" (fast 2)
  $ "~ s ~ <s!3 ~>" # "sn" # n "[1,10]"
  # midiG' "^79" 0 1.6
d3 $ g
  $ midiOn ("^43") (fast 2)
  -- FIXME(#94) d3 drives more controls than the grid gives it (BT3 only — BL1-3 are the family mutes). ^76 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^76 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 d3's own control with gSel.
  -- FIXME(#94) d3 drives more controls than the grid gives it (BT3 only — BL1-3 are the family mutes). ^76 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^76 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 d3's own control with gSel.
  $ midiOn ("^76") (ply 2)
  $ struct "t*[8 <<4 16> 16 <8 [8 4] 4 8> 16>]"
  $ "h2ogmhh" # n "[10|11|12]*4"
  # midiG' "^80" 0 1.5
d3
  $ mask "t . <t!6 f f>"
  $ sometimesBy "0 ^16!6 0" ((|* gain 0.9) . (|/ speed 2))
  $ sometimesBy "^31" (|* speed 1.5)
  $ sometimesBy "0 ^52!7" (ply "<2!3 [2!3 1]>")
  $ g
  $ chop 16
  $ loopAt 2
  $ "break:2"
  # cut 3
  # midiG' "^80" 0 1.5
d4 $ g -- Bassline
  $ swingBy "h" 8
  $ midiOn "^44" (degradeBy $ "0 1!3 0 1!2 0" * 0.5)
  $ note ((struct "t(3,8) t(<4 4 5 [5 8]>,8)"
  $ arp "<pinkyup!2 converge!2>" prog)
  + "[0,<0 12>]"
  - 36)
  # "supersaw" # voice 0.01
  # pan 0.2
  # room 0.2
  # crushbus 40 (range 10 1.85 "^32")
  # midiG' "^81" 0 1.5
d5 $ g -- Nappes plage
  $ midiOn "^89" (superimpose (
    struct "t . t(3,8)"
    . arpeggiate
    . (|+ note 12)
    . (# cut 51)
    . (|* gain 1.1)
  ))
  $ note (prog - 12)
  # "moog:2"
  # crushbus 50 (range 10 1.2 "^33")
  # midiG' "^82" 0 1
  # attack 0.8
  # room 0.4 # sz 0.9
d6 -- Guitare nostalgique
  $ midiOn "^90" (slice 4 "0 1 2 3")
  $ mask "<t!3 f>"
  $ "fguitar" # n "<34!32 35!16 34!16>"
  # midiG' "^83" 0 1.5
  # crushbus 60 (range 10 2.85 "^34")
  # pan 0.65
  # cut 6
d7 $ g -- C-Bows
  $ midiOn "^59" (mask "t([4 <8 8 4 8>],16)")
  $ superimpose (
    (>| note (
      "<0 <-1 2>>" + "0(3,8) 0"
      ))
    . (|+ note 24)
    . (|* gain (range 0 0.95 "^35"))
  )
  $ note ( -- Graves!
    progm
    + "<0 0 10 0> <7 12>" -- FIXME?
    + "0 . [0!3 ~] 0*<1!7 2>"
  )
  # "cbow:8"
  # pan "<0.7!7 0.3>"
  # midiG' ("^84" * "^55") 0 1.4
d8 $ g
  $ midiOn "^60" (off "q" (# n 11) . (|* gain 0.95))
  $ note (
    struct "t . t(<1!4 3!4 [5 3]!4 5!4>,8,<0!3 4>)"
    $ arp "pinkyup <updown downup>"
    $ (fast 2 $ prog)
  )
  # "cbow" # n "[9,<~!4 10!4>]"
  # pan "<0.3!7 0.7>"
  # midiG' ("^84" * "^36") 0 1
