
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 gLPQ =  (# lpqbus  4 (range 0 0.5 "^13"))
let gHPQ =  (# hpqbus  5 (range 0 0.5 "^14"))
let gRoom = (# roombus 6 (range 0 0.5 "^14"))
let gSlow = (midiOn "^42" (slow 2))
let g = gDJF . gSlow
setcps (92/60/4)
let patFunk = "ds gf f <bf4!3 bf>"
d1 $ g
  $ midiOn "^73" (fast 2) -- Techno
  $ midiOn "^41" (<| "k*4") -- Techno
  $ midiOff "^41" (<| "k . k <~ [<~ k> <k ~>]>")-- RubADub
  $ "jazz"
  # midiG' "^78" 0 1.8
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" # "sn" # n "[1,10]"
  # midiG' "^79" 0 1.6
d3 $ g
  $ (# midiG' "^80" 0 1.5)
  $ midiOn "^43" (fast 2)
  -- FIXME(#94) d3 drives more controls than the grid gives it (BT3 only — BL1-3 are the family mutes). ^44 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^44 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). ^44 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^44 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 "^44" (const $
    slice 8 "0 1*<1!5 2!3> 2 3 . 0 .. <<3 1>!4 7!3 3>"
    $ "breaks165"
    # pan 0.75
    # cut 7
    # room 0.2
    # hpf 100
  )
  $ struct "t*[8 <<4 16> 16 <8 [8 4] 4 8> 16>]"
  $ "h2ogmhh" # n "[10|11|12]*4"
d4 $ g -- Smells like Bass
  $ mask "<f!4 t!28>"
  $ note patFunk
  # "bass3"
  # pan 0.2
  # crushbus 40 (range 10 2.85 "^32")
  # midiG' "^81" 0 1.8
d5 $ g -- Guitar
  $ whenmod 8 4 (juxBy 0.75 ((|* gain 0.8) . off "e" id))
  $ whenmod 8 4 (juxBy 0.8 (mask "f t" . ply 2))
  $ note (patFunk + 12)
  # "pluck"
  # room 0.2
  # sz 0.8
  # gain 0.35
  # crushbus 50 (range 10 1.65 "^33")
  # midiG' "^82" 0 1.8
d6 $ g
  $ sometimesBy "0 . 1 0" (ply 2)
  $ midiOn "^58" (sometimesBy "0!3 1" (rev))
  -- FIXME(#94) d6 drives more controls than the grid gives it (BT6 + BL6). ^90 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^90 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 d6's own control with gSel.
  $ midiOn "^90" (chop (slow 4 "<16 32 48 64>"))
  $ "b/4" # "brass:27"
  # midiG' "^83" 0 1.5
  # cut 9
d7 $ g
  $ midiOn "^91" ( -- Arps aigus
    superimpose (
    (# "cbow:11")
    . off "e" id
    . mask "t(4,8)"
    . (# cut 71)
    ))
  $ note ("<g ds>(3,8) f([3 <3 1 1 3> 3],8)")
  # "cbow:10"
  # midiG' "^84" 0 1.5
  # cut 7

d6 $ g
  $ midiOn "^90" (superimpose (
    struct "t . t(3,8)"
    . arpeggiate
    . (|+ note 12)
    . (# cut 51)
    . (|* gain 1.1)
  ))
  $ note (prog - 12)
  # "moog:2"
  # midiG' "^82" 0 1.2
  # attack 0.8
  # room 0.4 # sz 0.9

d6
  $ midiOn "^90" (slice 4 "0 1 2 3")
  $ mask "<t!3 f>"
  $ "fguitar" # n "<34!32 35!16 34!16>"
  # midiG' "^83" 0 1.4
  # crushbus 60 (range 10 2.85 "^34")
  # cut 6
d7 $ g
  $ midiOn "^59" (mask "t([4 <8 8 4 8>],16)")
  $ superimpose (
    (>| note (
      "<0 <-1 2>>" + "0(3,8) 0"
      ))
    . (|+ note 24)
    . (|* gain (1.1 * (range 0 1.25 "^35")))
  )
  $ note (
    progm
    + "<0 0 10 0> <7 12>"
    + "0 . [0!3 ~] 0*<1!7 2>"
  )
  # "cbow:8"
  # pan "<0.7!7 0.3>"
  # midiG' "^84" 0 (1.5 * "^55")
d8 $ g
  $ note (
    struct "t(5,8)"
    $ arpeggiate
    $ prog
    -- + "<0 0 10 0> <7 12>"
    -- + "0 . [0!3 ~] 0*<1!7 2>"
  )
  # "cbow:10"
  # pan "<0.3!7 0.7>"
  # midiG' "^84" 0 1

  do
  -- resetCycles
  setcps (92/60/4)
  let gain p = gain (1.5 * p)
  let gFadeIntro = someCyclesBy "<t!8 f!56>" (|* gain (slow 8 $ range 0 1 saw))
  let patFunk = "ds gf f <bf4!3 bf>"
  let gDJF = whenmod 32 24 (# djf (slow 8 $ range 0.5 0.15 saw))
  let gPont = whenmod 64 32 (mask "<f!6 t!26>")
  let g = (gDJF)
  d1 $ g $ gFadeIntro $ gPont
    $ mask "<f!4 t!60>"
    $ "[bd,jazz]*4" # room 0.1
    # gain 0.45
  d2 $ g $ gFadeIntro $ gPont $ mask "<t(1,2)!4 t!60>"
    $ "~ c ~ c" # "[clap]" # gain 0.4
  d3 $ g $ gPont
    -- $ mask "<f!8 t!24>"
    $ (
      mask "t . t t(2,4)"
      . sometimesBy "0 . <0 1>" (ply "2 . [2|1]*4"))
    $ "gretsch:4*16"
    # pan 0.25
    # gain (0.35 + 0.1 * (segment 8 perlin))
  d6 $ g -- Final guitare rita
    $ whenmod 64 48 (# gain 0.25)
    $ slice 16 "0 . 1 <~ 1 2>"
    $ loopAt 6
    $ "rita:0"
    # gain 0
    # cut 6
    # hpf 400

  d8 $ g -- Organic madness
    $ mask "<f!7 t f!4 t f!19 t!3 f t!28>"
    $ sometimesBy (slow 4 saw) (ply 2)
    $ chop 4
    $ someCyclesBy "<0!32 1!4 0!28>" (|* gain (slow 4 $ range 0.5 1 saw))
    -- $ mask "<f!32 t!32>"
    $ "forgan:14"
    # lpf 1000
    # gain 0.3 * "<1!7 0.95 0.9!7 0.85>"
    # cut 8
  d10 -- F-U-N-K
    $ mask "<f!8 t!24>"
    $ degradeBy "0 <0.5 0.45 0.35 0.3 0.25 0.2 0.15>!7 <1!3 0>"
    $ whenmod 64 48 (swing "<6!8 [3 4]!8>")
    $ someCyclesBy "<1!48 0!16>" (ply "<1 <2 [4 2]>>")
    $ n "5 20 13 10"
    # "alphabet"
    # release 0.8
    # gain (slow 32 $ range 0.2 0.34 cosine)
    # pan "<0.1!4 0.9!4>"
