
-- TODO: Intro basse volume
-- TODO: Intro rhodes volume premiere note
-- TODO: filtered outro
-- TODO: filler notes bass 8/8
-- TODO Replace scaffolding with relevant noises
setcps 0.5 -- One pattern per two seconds

-- Intro -- Rouge -- Blanc -- Generique -- FIN
-- 0        68       131      143          166
-- SHIT, DIV 2
-- 0        34       65       71           86
do
-- resetCycles
let intro = mask "<f!2 t!84>"
let fromVelo = mask "<f!6 t!80>"
let fromSophie = mask "<f!11 [f t] t!74>"
let rouge = "<0!30 [0 1] 0!5 [1 0 1 1] 1!5 [1!3 0] 0 [0 1!3] 1 0!3 1!4 [1 0!3] 0 0 [0 1] 1!12 0!90>"
let outro = "<0!150 1!16>"
let lOutro =  16
let whenEnd = whenmod 160 86
let whenEndRouge = whenmod 86 68
let whenRouge = someCyclesBy rouge
let whenNotRouge = someCyclesBy (1 - rouge)
let whenOutro = (someCyclesBy outro)
let gPluck = "<0.28!6 0.32!8 0.335!82>"
let prog = "<b'min7 <a'maj7 d'maj7>>"
let g = (whenEnd (# silence))
-- d12 $ whenRouge (|- note 12) $ "superpiano*4" # velocity 0.2 -- Caleur rouge
d1 $ g
  $ intro
  $ whenRouge (fast 4) -- Rouge
  $ whenEndRouge (|* gain (slow 16 $ range 1 0.5 saw))
  $ superimpose ((# "reverbkick") . (# hpf 200) . (|* gain 0.7) .(# legato "<1!4 <q!3 e>!4>"))
  $ "jazz" # gain 0.45
  # lpf 200
d3 $ g
  $ intro
  $ whenOutro (degradeBy (slow lOutro $ range 0.1 0.95 sine))
  $ whenRouge (sometimesBy "<0.25 0.5 0.5 <0.75 0.9>>" (mask "t(16,32)" . ply 2))
  $ whenRouge (|* gain 1.2)
  $ slice 4 "0 1 2 <3!4 2!4 3 3 [2 3] 3*4>"
  $ whenmod 4 2 (off "q" id)
  $ "break:10" # gain 0.5 # cut 3 -- Runner
d4 $ g-- Piano Nappes/Arps
  $ intro
  $ fromVelo
  $ whenOutro (degradeBy ("0 1!7" * (slow lOutro $ range 0.1 0.9 saw)))
  $ whenRouge (degradeBy "1 0.5!15")
  $ off "<e!3 [e|q]>" ( -- swinged echo
    whenRouge (# lpf 500)
    . someCyclesBy "<0!12 1!4 0!8 1!8>" (swing 4)
    . someCycles (|+ note 12)
    . (|* gain 0.78)
  )
  $ superimpose ( -- Arps aigus
    mask "<t!32 f!32 t!32 f!16 t!16 t t t f!7 t t t!16 f!10>"
    . fromSophie
    . sometimesBy (slow 4 "<0 0.25 0.5 0.75>") (ply "1 <1 2 4 8>")
    . struct ("t . t(<3!3 <5 [3 5]>>,8)")
    -- . arp "<up!3 down>"
    . (|+ note 12)
    . (|* amp 0.8)
    . (|+ pan 0.3)
  )
  $ note prog
  # "<FMRhodes1!8 FMRhodes2!8>"
  # octave 4
  # pan 0.4
  # amp 0.35
  # gain (0.54 - (slow 68 $ range 0 0.14 sine)) -- synced bass
d5 $ g -- RESONANT BASSLINE from Angel frappe
  $ fromSophie
  $ someCyclesBy "<1!67 0!99>" (mask "[t ~]*4")
  $ whenRouge (# crush 8.5)
  $ whenOutro (# hpf (slow lOutro $ range 0 1000 saw))
  $ whenNotRouge (mask "t f t <f t f f> . t f <t f> <f!3 t>")
  $ note "b2!6 <bs2!3 <a2 g2>> b2"
  # "supersaw"
  # room 0.85 # sz 0.8
  # hpf (slow 16 $ range 400 0 cosine)
  # pan (slow 16 $ range 0.2 0.3 cosine)
  # gain (slow 68 $ range 0.25 0.34 saw) -- synced piano
d10 $ g -- Events timings
  $ fix (sometimes (ply 2) . (# n 1) . (# hpf 4500)) ("clap")
  $ whenmod 166 75 (mask "t(8,16)" . off "h" id)
  $ every' 166 85 ((<| "a*8") . (# note "d3'maj'2'8") . (# gain gPluck)) -- FIN
  $ every' 166 83 ((>| "clap([4 [8 12] . 10 [4 0 . [16 8]]],16)") . (# gain gPluck)) -- ...Julien! :clap:
  $ every' 166 82 ((>| "clap*[8 . 16 4]") . (# gain gPluck)) -- ...and :clap:
  $ every' 166 81 ((>| "clap(5,8,0)") . (# gain gPluck)) -- Leopold :clap:
  $ every' 166 80 ((>| "clap(3,8,0)") . (# gain gPluck)) -- Gregoire :clap:
  $ every' 166 79 ((>| "clap(3,4,0)") . (# gain gPluck)) -- Gregoire :clap:
  $ every' 166 78 ((>| "clap(4,4,0)") . (# gain gPluck)) -- Sophie :clap:
  $ every' 166 77 ((>| "clap(3,4,0)") . (# gain gPluck)) -- Gregoire :clap:
  $ every' 166 76 ((>| "clap(2,4,0)") . (# gain gPluck)) -- Cyril :clap:
  $ every' 166 75 ((>| "clap(1,4,0)") . (# gain gPluck)) -- ...avec... :clap:
  $ every' 166 74 ((>| "clap(4,4,0)") . (# gain gPluck)) -- SEPTEMBRE ROSE :clap:
  $ every' 166 73 ((>| "clap") . (# gain gPluck)) -- Gregoire :clap:
  $ every' 166 72 ((>| "clap") . (# gain gPluck)) -- Gregoire :clap:
  $ every' 166 71 ((<| "e*4") . (# note "d'maj'2") . (# gain gPluck)) -- Generique?
  $ every' 166 70 ((<| "d*2") . (# note "d'maj'2") . (# gain gPluck)) -- Generique?
  $ every' 166 68 (const -- Tinks résolution
      $ off 1 (degradeBy "0 0.5!7" . rev)
      $ struct "t([16 [12 4]],16)"
      $ note (arp "down" "<b'min7 <a'maj7 d'maj7>>")
      # pan (range 0.1 0.9 saw)
      # "tink" # gain 0.8
      # room "0 0.2 0.4 0.5"
  ) -- Amis
  $ every' 166 60 ((>| note (struct "t(2,8) t(3,8)" $ arp "down" "d'maj7'4")) . (# gain gPluck)) -- Impuissants?
  $ every' 166 50 ((<| "a*4") . (# note (arpeggiate "a4'min7'4")) . (# gain gPluck)) -- Homme femme nombril
  $ every' 166 35 (const -- Tinks glitchés
      $ struct "t([12 32],16)"
      $ note (arp "up" "a'maj7")
      # "tink" # gain 0.8
      # pan (range 0.9 0.1 saw)
      # room "0 0.4"
  ) -- Moon, bientot rouge
  $ every' 166 32 ((<| "a*4") . (# note (arpeggiate "a4'maj'4")) . (# gain gPluck)) -- Hercule
  $ every' 166 30 (const $ "igor:4" # lpf 2000 # gain 0.45) --  Anarchie
  $ every' 166 15 (const -- Tinks retour
      $ off 1 (degradeBy "0 0.5!7" . rev)
      $ struct "t(12,16)"
      $ note (arp "down" "<b'min7 <a'maj7 d'maj7>>")
      # "tink" # gain 0.8
      # pan (range 0.1 0.9 saw)
  ) -- Piece
  $ every' 166 11 ((>| note "b(5,8)") . (# gain gPluck)) -- 1 Fin couple, 2-5 Sophie
  $ every' 166 9 (const -- Tinks aller
      $ off 1 (degradeBy "0 0.5!7" . rev)
      $ struct "t([6 12],16)"
      $ note (arp "up" "<b'min7 <a'maj7 d'maj7>>")
      # "tink" # gain 0.9
      # pan (range 0.9 0.1 saw)
  ) -- Vetement
  $ every' 166 7 ((>| note "~ e ~ [b d ~ e]") . (# note (arp "down" "d'maj7")) . (# gain gPluck)) -- Mains
  $ every' 166 6 ((>| note "~ ~ ~ d") . (# gain gPluck)) -- Velo
  $ every' 166 5 (struct "t([5 10],16)" . (>| note (arp "updown" "b'min7'4")) . (# gain gPluck)) -- Oreille
  $ every' 166 3 ((>| note "[b d](2,8,3)") . (# gain gPluck)) -- Main
  $ every' 166 1 ((>| note (arpeggiate "a'maj'4")) . (# gain "0.5!3 0.6")) -- CLAP
  $ note "a" # "cpluck:4" # gain 0
  # pan 0.4
d7 $ g -- Side high cello
  $ whenRouge (someCyclesBy 0.8 (off "0.625" (|+ pan 0.18)))
  $ someCyclesBy 0.2 (degrade)
  $ whenmod 8 4 (superimpose (
    (|+| note "0 <~!2 12!2> <~ 0!3> . 7")
    . (ply 2)
  ))
  $ whenNotRouge (swing "2")
  $ note (arp "<up!4 converge!2 diverge!2>" "<b'min7 <a'maj7 d6'maj7>>")
  # "cpluck:4"
  # gain (slow 100 $ range 0.1 0.34 cosine)
  # pan 0.8
  # room 0.4
  # hpf (slow 100 $ range 0 9000 cosine)
  # legato (0.7 - (slow 4 $ perlin/8))

once $ "clap([4 [8 12] . 10 [4 0 . [16 8]]],16)"
  # gain 0.6

) . (# gain gPluck)) -- Julien :clap:


once $ "cpluck:4" # gain 0.5

once $ "super808*" # gain 0.7

once $ "igor:0" # cut 21 # gain 0.5

once
  $ off 1 (degradeBy "0 0.5!7" . rev)
  $ struct "t(12,16)"
  $ note (arp "up" "<b'min7 <a'maj7 d'maj7>>")
  # "tink"

once $ "igor:4" # cut 21 # gain 0.5

once
  $ stut 8 1 "[0.1|0.125|0.05]*8"
  $ "coins" # speed ("0.9*8" + (fast 8 perlin/4)) # gain 0.5

-- MATIERE PREMIERE

-- BREAKS
do
d2
  $ "break:16" # gain 0.5 # cut 2 -- Metronome

once $ "break:12" # gain 0.5 # cut 1 -- Afro-sweat

once $ "break:11" # gain 0.5 # cut 1 -- HEAVY

once $ "break:9" # gain 0.5 # cut 1 -- cloche

once $ "break:4" # gain 0.5 # cut 1 -- coin




once $ "dr" # cut 1
