import Sound.Tidal.ParVagues.Control

do
let gF = 1.3
let gG a = (gain (gF * "^77" * a)) -- gain Global
let gM' l h a = (gG (range l h a)) -- gain Modéré
let gM a = (gM' 0.2 0.8 a) -- gain Modéré doux
let gLPF = (# lpf (min 10000 ((range 200 20000 ("^49")))))
let gHPF = (# hpf (max 0 (min 7500 ((range "-7500" 7500 ("^49"))))))
let gDJF = (gLPF . gHPF)
let novaOn  ch pat = (sometimesBy ch pat)
let novaOff ch pat = sometimesBy (1 - ch) (pat)
let g = gDJF
setcps (115/60/4)
d1 $ g
  $ novaOn "^41" (<| "k k k <k!3 k*2>")
  $ novaOff "^41" (<| "k*2")
  $ "[jazz,808bd:1]"
  # gM' 0 1.2 "^78"
d2
  $ novaOn "^75" (fast 2)
  $ (|* gain
    "0.75 1 1 1 0.75 1 1 1" )
  $ "d ~ ~ d d ~ d <~!3 d>"
  # "snare:22" # gM' 0 1.2 "^79"
  # speed (range 0.5 1.5 "^51")
d4 $ g
  $ novaOn "^44" (slow 2)
  $ novaOn "^76" (slice 8 ("0 1 2 3 <4 0> <5 1>  6 7") . (loopAt 2) . (>| "fbreak80:2") .
  (# gM' 0 1.5 "^80")
  )
  $ (|* gain (slow 2 $ range 1 1.1 perlin))
  $ novaOff "^76" (<| "s*[8 . 16 8 8]" )
  $ "snare:26"
  # speed (range 0.5 1.5 "^52")
  # gM' 0 1 "^80"
  # cut 4
d5 $ g
  $ loopAt 2
  $ slice 8 (run "<4!4 8 8 [4 8 4] 8>")
  $ "fbass:13"
  # pan 0.2
  # gM' 0.4 1.1 "^81"
  # room 0.2
  # crush (range 10 4.5 "^53")
  # cut 4
d6 $ g
  $ whenmod 16 12 (rev)
  $ whenmod 8 4 (chop 4)
  $ loopAt 4
  $ "fguitar" # n "<12!16 13!16>"
  # gM' 0 1 "^82"
  # pan 0.75
  # room 0.2 # dry 1
  # cut 3
d7 $ g
  $ loopAt 4
  $ mask "t(<4 8 12 16>,16)"
  $ slice 16 (run 16)
  $ "fpiano:13"
  # pan 0.45
  # room 0.2
  # gM' 0 1.3 "^83"
  # cut 7
d8 $ g
  $ novaOn "^60" (
  superimpose (
    struct "t(5,8)"
    . arp "down"
    . (|+ note 12)
    . (|* gain 1.1)
    . (|- pan 0.1)
    )
  . superimpose (
    arp "up"
    . (|+ note "[12,-12]")
    . (|* gain 0.9)
    . (|- pan 0.25)
  ))
  $ note "<a3'maj g3'maj a3'min d3'maj>"
  # crush (range 8 4 "^56")
  # room 0.4
  # "moogBass"
  # gM' 0 1 "^84"
  # pan (segment 16 $ "^36")
d9 $ g
  -- $ whenmod 8 4 (juxBy 0.5 rev)
  $ struct "t(3,8) [<t!3 [~ t]> <t ~> <t t*2> <t*2 t t*2 t*2>]"
  $ novaOn "^59" (# speed (range 0.25 2 ("^55" + perlin)))
  $ novaOff "^59" (# speed
    (segment 16 $ fast 2 $ range 0.25 1.2 (perlin + (slow 8 $ sine)))
  )
  $ "hh:3"
  # lpq (range 0 0.2 "^35")
  # gM' 0 2 "^19"