-- TODO: DNB Anniv etienne with nass

do
-- region Nova Utils
let gFactor = 1.3
let gG a = (gain ("^77" * a * gFactor)) -- 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 novaIf ch patIf patElse = (sometimesBy ch (>| patIf) patElse)
-- endregion Nova Utils
let gDelayD = (# delay (range 0 5 "^13"))
let gDelayFB = (# delayfb (range 0 0.9 "^14"))
let gRoom = ((|+ room (range 0 0.5 "^29")) . (# dry 0.99))
let gSize = (|+ size (min 0 (range "-0.5" 0.5 "^29")))
let gDelay = (gDelayD . gDelayFB . (# delayt 0.25) . (# orbit 2))
let g = (gDJF . gRoom)
let chords = "<d3'min d3'maj>"
setcps (165/60/4) -- keep it between 110-190 BPM. You won't be sorry you did.
-- resetCycles
d1 $ g -- Kick
  $ superimpose ((# "kick:5")
  . (# crush (range 6 2.5 "^50"))
  -- . (# note (-2))
  . (|* gain (range 0 1 "^50")))
  $ novaOn  "^73" (<| "~ ~ k ~") -- 1D
  $ novaOn  "^74" (<| "k*2") -- 2D
  $ novaOn  "^41" (<| "k*4") -- 4F
  $ novaOff "^41" (<| "k . ~ k ~ ~")-- DNB
  $ novaOn  "^75" (fast 2)-- FASTER
  $ "[jazz,cpu2]"
  # room 0.05
  # gM' 0 1.5 "^78"
d2
  $ g -- Snare
  $ novaOn "^43" (|<| "s*4")
  $ "~ s ~ s*<1!3 2 2 2 [2 1] 1>"
  # "[sn:20,snare:8]"
  # note (range "-12" 4 "^51")
  # orbit 1
  # gM' 0.2 0.9 "^79"

d3 $ g -- Hats
  $ novaOn ("^76")  (slice 8 (run 8) . (loopAt 1) . (>| "breaks165"))
  $ novaOn ("^44")  (<|"h*8") -- TODO Eclaircir
  $ novaOff ("^44") (<| "h*[8 . 8 <8 16 32 4>]")
  $ (|* gain "[1 0.9]*4") -- make sure that you reduce the velocity of the second Hi Hat hit
  $ s "gretsch:4"
  # cut 3
  # orbit 1
  # gM' 0.2 1.5 "^80"
d9 -- CP
  $ sometimesBy "^59" (fast 2)
  $ (# lpf 2000)
  $ g
  $ whenmod 4 2 (superimpose ((# "clap") . (# lpf 4500) . (|* gain 0.8)))
  $ fast 2
  $ "~ cp"
  # gM' 0 1.1 "^83"
  # room 0.2
  # dry 0.9
  # lpf 2000
d4
  $ g
  $ novaOn "^57"  (fast "<2!3 4>")
  $ splice 4 "<2!3 3>"
  $ "fbass:57"
  # dry (range 0.5 1.5 "^17")
  # attack (range 0.5 1.5 "^33")
  # crush (range 10 3.5 "^53")
  # orbit 1
  # gM' 0.25 1.25 "^81"
  # cut 4
d5
  $ g
  $ slice 8 ("<0!4 4!4 0 0 4 4 0 4 0 4>" + "0 1 2 3")
  $ "fguitar:58"
  # gM' 0 1 ("^82" * (range 0.25 1.5 "^54"))
  # cut 5

-- TODO RECYCLE

d5 $ g $ gDelay -- Skank Piano
  $ whenmod 4 3 (sometimesBy "0 1 . 0" (
    (# note "[d5,g4,b4]") . (|* gain 0.8)
  ))
  $ "<[~ p*<1 1 1 <1 2>> ~ p*<1 1 2 1>]>"
  # "superpiano"
  # note chords
  # velocity 0.6
  # sustain 0.34
  # release 0.8
  # room 0.13 # sz 0.4
  # pan 0.4
  # gM' 0 1 ("^82" * (range 0.25 1.5 "^54"))
d6 $ g $ gDelay-- Skank Hammond
  $ ("0.125" ~>)
  $ fast 2
  $ note (("[0 12 0 <~!6 12!2>]" |+ (slow 2 chords)))
  # "superhammond"
  # gM' 0 0.8 ("[0 0.25 0 0]" |+ "^82" * (range 0 0.9 "^34"))
  # voice 6
  # octave 6
  # sustain 0.25
d7
  $ g $ gDelay -- Skank Guitar
  $ note "[~ <a'min!2 e'min!2>]*2"
  # "pluck:5"
  # octave 5
  # gM' 0 1 ("^82" * ((range 0.25 1.5 "^18")))
d8 -- Trompette lancinante
  $ g $ gDelay
  $ novaOn "^59" (mask "<f!3 t>")
  $ note ("<g [<a d> bf d ~]> <g [~ g a]>" + "0 <12 0>")
  # "brass" # n "2"
  # gM' 0.2 0.85 ("^55")
  # attack 0.5 # cut 8
