-- region V1
-- Improvements:
-- TODO Premapper valeurs fixes [0,1,3,5,8,..] les pas totaux
-- TODO Peaufiner control scaling coté max
do
let l = 16
let noVoid = fix ((# "cp") . (# gain 0)) "VOID"
let euclidOrVoid inscrit total pat = euclidFull inscrit total pat (s "VOID")
let pasTotal ch = range 1 l $ (cF 0 ch)
let rotVal ch = range 0 (1-l) $ (cF 0 ch)
let maxInscrit ch = (min l (pasTotal ch))
let pasInscrit ch1 ch2 = (range 0.49 (maxInscrit ch2 - 0.49) $ (cF 0 ch1))
let midiRot ch = rot (round <$> rotVal ch)
let midiEuclid a b c = (euclidOrVoid a b c) -- FIXME [API] Add noVoid inside
setcps (90/60/4)
d1
  $ midiOn "^41" (fast 0.5)
  $ midiOn "^73" (ply 2)
  $ midiRot "49"
  $ noVoid $ midiEuclid
    (round <$> pasInscrit "13" "29")
    (round <$> pasTotal "29")
  (s "[808bd:2,808bd:3]")
  # midiG' "^77" 0 0.9
d2
  $ midiOn "^42" (fast 0.5)
  $ midiOn "^74" (ply 2)
  $ midiRot "50"
  $ noVoid $ midiEuclid
    (round <$> pasInscrit "14" "30")
    (round <$> pasTotal "30")
  (s "snare:39")
  # lpf 2000
  # midiG' "^78" 0 1.2
d3
  $ midiOn "^43" (fast 0.5)
  $ midiOn "^75" (ply 2)
  $ midiRot "51"
  $ noVoid $ midiEuclid
    (round <$> pasInscrit "15" "31")
    (round <$> pasTotal "31")
  (s "drum:2")
  # midiG' "^79" 0 1.2
d4
  $ midiOn "^44" (fast 0.5)
  $ midiOn "^76" (ply 2)
  $ midiRot "52"
  $ noVoid $ midiEuclid
    (round <$> pasInscrit "16" "32")
    (round <$> pasTotal "32")
  (s "hh")
  # midiG' "^80" 0 1.2
d5
  $ midiOn "^57" (fast 0.5)
  $ midiOn "^89" (ply 2)
  $ midiRot "53"
  $ noVoid $ midiEuclid
    (round <$> pasInscrit "17" "33")
    (round <$> pasTotal "33")
  (s "hh")
  # midiG' "^81" 0 1.5
d6
  $ midiOn "^58" (fast 0.5)
  $ midiOn "^90" (ply 2)
  $ midiRot "54"
  $ noVoid $ midiEuclid
    (round <$> pasInscrit "18" "34")
    (round <$> pasTotal "34")
  (s "[gretsch:4,gretsch:6]")
  # midiG' "^82" 0 1.2
d7
  $ midiOn "^59" (|+ note 2)
  $ midiOn "^91" (|+ note "[0,12]")
  $ midiRot "55"
  $ noVoid $ midiEuclid
    (round <$> pasInscrit "19" "35")
    (round <$> pasTotal "35")
  (s "superfork")
  # note 9
  # legato 2.8
  # room 0.2
  # dry 1.2
  # sz (slow 32 $ range 0 0.7 saw)
  # midiG' "^83" 0 1.2
d8
  $ midiOn "^60" (fast 0.5)
  $ midiOn "^92" (ply 2)
  $ midiRot "56"
  $ noVoid $ midiEuclid
    (round <$> pasInscrit "20" "36")
    (round <$> pasTotal "36")
  (s "superfork")
  # legato 3.5
  # room (slow 16 $ range 0.6 0.3 saw)
  # sz 0.3
  # dry (1 + (slow 8 $ perlin))
  # (note "<0 <[0,12] [0,7]>>" - 24)
  # midiG' "^84" 0 1.2
d9 -- BASSLINE TODO REW0RK
  $ slow 2
  $ note "<c'min'3!4 df'min'3!4>"
  # "moog"
  # cut 9
  # gain 0.25
  # pan 0.6
  # room 0.5
  # legato 4

-- endregion

d5 $ "hh"


-- region MVP
do
let l = 8
let pasTotal = range 1 l $ (cF 0 "29")
let rotVal = range 0 (l-1) $ (cF 0 "49")
let maxInscrit = (min l pasTotal)
let pasInscrit = (range 0.49 (maxInscrit - 0.49) $ (cF 0 "13"))
let rotInscrit = 0
d1
  $ fix ((# "cp") . (# gain 0)) "VOID"
  $ rot (round <$> rotVal)
  $ euclidFull
    (round <$> pasInscrit)
    (round <$> pasTotal)
  (s "kick:5") (s "VOID")
  # gain (range 0 1.2 "^77")
-- endregion


-- region SANDBOX

do
d1 $ rot 1.2 $ "cp(3,8)" # gain 0.9

d2 $ "dr*4" # pan 0.9

d3 $ rot 3 $ euclidFull 1 4 (s "blip") (s "cp" # gain 0)

d1 $ segment 8 $ euclid 3 8 $ "bd"

d3 $ rot (3) $ euclid 3 8 $ "bd"

once $ "amencutup:7" # gain 2
once $ "amencutup:9" # gain 2

:t cF

d1
  $ sound "cp"
  # gain 1.2


  -- endregion
