setcps 0.5 -- One pattern per two seconds

-- TODO: Intro basse volume
-- TODO: Intro rhodes volume premiere note
-- TODO: better bass volume, more manual than sine?
-- TODO: filtered outro
-- TODO: filler notes bass 8/8

-- 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!164>"
let fromVelo = mask "<f!6 t!160>"
let fromSophie = mask "<f!11 [f t] t!154>"
let rouge = "<0!36 1!6 0!2 1!2 0!3 1!2 0!6 2!12 0!90>"
let outro = "<0!150 1!16>"
let lOutro =  16
let whenRouge = someCyclesBy rouge
let whenNotRouge = someCyclesBy (1 - rouge)
let whenOutro = (someCyclesBy outro)
-- let gain amount = (gain (amount * 1.5))
d1
  $ intro
  $ whenRouge (fast 4) -- Rouge
  $ superimpose ((# "reverbkick") . (# hpf 200) . (|* gain 0.7) .(# legato "<1!4 <q!3 e>!4>"))
  $ "jazz" # gain 0.45
  # lpf 200
d3
  $ 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 -- 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 "<b'min7 <a'maj7 d'maj7>>"
  # "<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 -- RESONANT BASSLINE from Angel frappe
  $ fromSophie
  $ someCyclesBy "<1!67 0!99>" (mask "[t ~]*4")
  $ 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"
  -- # gM' 0 1 "^81"
  # room 0.5 # 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 -- Metronome timings
  $ (|* gain 0.5)
  $ every' 166 110 ((<| "a*2") . (# note "b'maj'2") . (# gain 0.8)) --
  $ every' 166 90 ((<| "a*2") . (# note "c'maj'2") . (# gain 0.8)) --
  $ every' 166 85 ((<| "a*8") . (# note "d'maj'2") . (# gain 0.8)) -- FIN
  $ every' 166 80 ((<| "a*4") . (# note "e'maj'2") . (# gain 0.8)) --
  $ every' 166 72 ((<| "a*2") . (# note "d'maj'2") . (# gain 0.8)) -- Generique?
  $ every' 166 68 ((<| "a*2") . (# note "d'maj'2") . (# gain 0.8)) -- Amis
  $ every' 166 60 ((<| "a*2") . (# note "c'maj'2") . (# gain 0.8)) -- Impuissants?
  $ every' 166 50 ((<| "a*2") . (# note "a'maj'2") . (# gain 0.8)) -- Homme femme nombril
  $ every' 166 35 ((>| note "f(5,8)") . (# gain 0.8)) -- Moon, bientot rouge
  $ every' 166 32 ((<| "a*4") . (# note (arpeggiate "a4'maj'4")) . (# gain 0.8)) -- Hercule
  $ every' 166 30 ((>| note "f(5,8)") . (# gain 0.8)) --  Anarchie
  $ every' 166 15 ((# note "g") . (# gain 0.8)) -- Piece?
  $ every' 166 11 ((>| note "f(5,8)") . (# gain 0.8)) -- 1 Fin couple, 2-5 Sophie
  $ every' 166 9 ((# note "d") . (# gain 0.8)) -- Vetement
  $ every' 166 7 ((>| note "~ e ~ e*4") . (# gain 0.8)) -- Mains
  $ every' 166 6 ((>| note "~ ~ ~ d") . (# gain 0.8)) -- Velo
  $ every' 166 5 ((>| note "c*4") . (# gain 0.8)) -- Oreille
  $ every' 166 3 ((>| note "b(3,8)") . (# gain 0.8)) -- Main
  $ every' 166 1 ((>| note (arpeggiate "a'maj'4")) . (# gain "0.8!3 1.1")) -- CLAP
  $ note "a" # "arpy" # gain 0

once $ "super808*" # gain 0.7

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