import Sound.Tidal.ParVagues.Control

-- Accompagnement en ré au https://mmontag.github.io/dx7-synth-js/


resetCycles

once "dr"

-- Break90s∷ :)
do
-- let gF = (whenmod 32 28 (# djf (slow 4 $ range 0 0.5 sine)))
let gDJF1 = (# djfbus 1 (range 0.15 0.85 "^49"))
let gDJF2 = (# djfbus 2 (range 0.15 0.85 "^29"))
let g1 = (gDJF1)
let g2 = (gDJF2)
setcps (80/60/4)
d1
  $ g1
  $ midiOn "^41" (superimpose ((# "kick:5")
  . (|* gain 0.7)).
  . (<| "k k k k k k k [<k ~> <k k ~ k>]")
  . (# room 0)
  )
  $ whenmod 4 2 (off (-1/"<8 16>") (
    degradeBy "0 1!7" . (|* gain 0.9))
  )
  -- FIXME(#94) d1 drives more controls than the grid gives it (BT1 only — BL1-3 are the family mutes). ^42 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^42 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 d1's own control with gSel.
  -- FIXME(#94) d1 drives more controls than the grid gives it (BT1 only — BL1-3 are the family mutes). ^42 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^42 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 d1's own control with gSel.
  $ midiOn "^42" (<| "k . ~ k ~ ~")
  $ midiNo "^41" "^42" (
    someCyclesBy "<0!8 1!8>" (<| "k . k(<5 <3 [3 <8 [8!3 4]>]>>,8)")
   . someCyclesBy "<1!8 0!8>" (<| "k . <~!4 k!4>" )
  )
  $ "[jazz,808bd:2]"
  # room 0.5 # sz 0.2 # dry 0.99
  # midiG' "^78" 0 1.4
d2
  $ g1
  $ midiOn "^75" (ply 2)
  $ midiOn "^42" (slice 4 "0 1*<1 1 2 4>")
  $ midiOff "^42" (
    slice 4 (
    "0 1*[1|2] 2 3*<1 1 2 <2 4>>" -- Progressif
    -- "0 <~ 0 1 ~> <0 0 2 2> <~ 0 2 3>" -- Broken
  ))
  $ "fbreak80:2"
  # midiG' "^79" 0 1.65
  # note (range "-12" 12 "^51")
  # pan 0.6
  # cut 2
d3 -- Bassline
  $ (# lpf (range 10000 500 "^31"))
  $ g1
  $ midiOn "^43" (off "h" (
    mask "t(<8 16> ,16)"
    . ply 2
    . (# cut 31)
    . (|* gain 0.8)
    . (|+ gain 0.1)
  ))
  $ loopAt 2
  -- FIXME(#94) d3 drives more controls than the grid gives it (BT3 only — BL1-3 are the family mutes). ^57 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^57 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). ^57 now belongs to another orbit, so this step STILL FIRES ACROSS COLUMNS — turning ^57 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 "^57" ( -- Le slice
    whenmod 16 4 (
      slice 4 "0 1 2*2 <0 3>"
    ) . every' 16 3 (
      slice 4 "0 1 2 [2 3]"
    )
  )
  $ midiOff "^57" ( -- L'attente
    slice 4 "0 <~ 1> <~ ~ 2 2> <~!3 3>"
  )
  $ "fbass:9"
  # cut 3
  # crushbus 31 (range 16 4 "^31")
  # pan 0.2
  # midiG' ("^81" + 0.125*"^31") 0 1.8
d5 $ g2 -- Piano base
  $ midiOn "^89" (superimpose (
    (0.5 ~>)
    . degradeBy (1 - "^33")
    . fast "<1!8 2!8 4!8 1!4 2!4 4!8>"
    . (|+ note 12)
    . (|* gain 1.2)
    . (|+ pan 0.125)
  ))
  $ degradeBy (1 - "1 ^54!3")
  $ sometimesBy 0.125 ("1/32" ~>)
  $ whenmod 16 4 (|+| note "<0!4 [0 a4]!4>")
  $ note "<d3!3 [g3 . ~ a4]>"
  # "superpiano"
  # velocity (0.4 + perlin/8)
  # room 0.6 # sz 0.8
  # pan 0.65
  # orbit 5
  # midiG' "^82" 0.3 1.7
d4 -- Skank organ
  $ g2
  -- $ superimpose (const $ g
    -- $ whenmod 8 4 (iter "1 4")
    -- $ segment 8 $ "fmono:9"
    -- # midiG' "^55" 0.2 1.2
    -- # cut 42)
  $ midiOn "^76" (superimpose ( -- MAD ARPS
    degradeBy ("0 1!14 0" * (slow 16 $ (1-"^32")))
    . struct "t*16"
    . (|+ note (12 + "[0|5]"))
    . (|* gain (slow 16 $ range 0.85 0.65 sine))
    . (# cut 41)
  ))
  $ slice 8 ("<~ 3 ~ 2> 0 <~ 4 5 6> <0 1>")
  $ "forgan:9" # cut 5
  # orbit 4
  # pan 0.45
  # room 0.7 # sz 0.8
  # crushbus 41 (range 16 4 "^32")
  # midiG' "^83" 0.2 1
d8 -- Tom roll
  $ g2
  $ midiOn "^92"  (fast 2)
  $ midiOn "^60"  (<| "~ h ~ h")
  $ midiOff "^60" (<| "h(<4 5 8 [8 16]>,8)")
  -- $ someCyclesBy (slow 8 $ saw) (juxBy 0.3 rev)
  $ whenmod 16 8 (ply "2 1")
  $ "hh27:2"
  # pan 0.8 # room 0.4 # orbit 8 # dry 0.9
  # midiG' "^80" 0 1.5
d9 -- Finger claps
  $ whenmod 16 12 (
    fast 2 . (|* gain (slow 4 $ range 1 0.5 saw))
  )
  -- $ midiOn "^60"   (<|)
  $ midiOff "^60"  (<| "~ c")
  $ "clap"
  # speed (range 0.75 1.25 "^56")
  # release "<0.25!3 0.125 0.25!4 0.125!4>"
  # midiG' "^84" 0 1.4
