resetCycles
setcps 0
setcps (135/4/60)

-- Partition 5stems: https://musescore.com/vivacecompositions/bad-guy
-- Partition 2stems: https://musescore.com/zakuramusic/billie-eilish-bad-guy-instrumental-w-vocals


-- 13s per line
-- Intro: 8 Kick+Bassline once
-- Voice: 8 Kick+Bassline+Voice + Clap end
-- Claps: 8 Kick+Bassline+Voice+Claps  +Mute end
-- Cuts:  8 Cut(Kick+Claps)+Bassline+Voice
-- PONT _ I'm BAD - DUH
-- 16 SYNTH MELODY
-- 8 Only voice + Claps echo second
-- 16 Riff bass + retour bassline
-- 16 + Mute end
-- Retour PONT refrain --- DH
-- 16 SYNTH MELODY
-- 16 SYNTH longer + echoes voix
-- Drop Trap, drumroll, slow beat, out of this shit

-- # Summary
-- Intro | Verse 1 | Chorus   | Verse 2 | Chorus | Chorus
--b 0-8    9-32  4c4c|Duh bass| cut reb
--v(1B)    9-32     BAD 33-42| 43-      | 67 BAD
-- 0-7     8-31    |BAD 32-42  | 43-67   | 68-78  | 79-89

-- region CopyCat
-- TODO: Bassline Rework rebond :)
-- TODO: Voice split pan, lead stronger than side, fix aigus chorus2
-- TODO: Claps: could be more "spread manual single-time clap" FIXME check masks
do
-- resetCycles -- FIXME: Not looping, bass out of sync
let bass1 = "5  ~ ~ 5  8  5  ~ 5"
let bass2 = "~ 5 ~ 5 8 5 3 ~"
let bass5 = "8  ~ ~ 8  11 8  ~ 8"
let bass6 = "~ 8 ~ 8 11 8 15 ~"
let bass7 = "10 ~ ~ 10 9  10 ~ 5"
let bass8 = "~ <5 ~> ~ <5!3 ~> . ~"
let bassRel = "~ . 8*2 11*2 [8,[~ ~ 6 ~]]@2"
setcps (135/60/4) -- 135BPM
d1 -- FOUR ON THE FLOOR, cut on last 2 of each verse
  -- TODO: orchestration's cuts might be on both halves, not only second
  -- TODO: orchestration's end might be to cutty? Also, lack last silence
  $ mask (
    "<t!16 t!7 [t . tfff] t!3 [tf] t!3 [tf] f f t!8 f!8 t!16 f f t!8 f f t!8>"
  ) -- Orchestration
  $ superimpose ((# "<tok:1 tok:2>") . (# note (-2)) . (|* gain 0.7))
  $ fast 4
  $ "jazz"
  # lpf 2000
  # attack 0.2
  # gain 1.5
d3 -- Bassline: melodie cut sur la fin du verse
-- $ TODO: Bassline relance end cut seconde verse FIXME trigger?
-- FIXME synchro second verse: restart loop? Copy paste? Fix Decalage & second Chorus
-- Bref, reorchestra fixing both trigger & matching
  $ every' 94 48 (
    (# lpf 200)
    . (# release 0.75)
  )
  -- $ mask ("<t!32 f!2 t!8 f!8 t!16 f!2 t!8>") -- Orchestration
  $ note ("-7" + cat [
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8, -- Intro
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8, -- White
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8, -- Bruises
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8, -- tough guy
    "", "", -- BAD GUY
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8, -- Chorus
    "", "", "", "", "", "", "", bassRel, -- Aclapella
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8,
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8,
    "", "", -- BAD GUY
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8, -- Chorus2
    bass1, bass2, bass1, bass2, bass5, bass6, bass7, bass8 -- Chorus2 repeat
  ])
  # "bass3"
  # cut 3
  # gain 2
d7 -- Claps
  $ mask "t!3 <t!3 f>"
  $ mask "<f!15 t t!24 f!4 t!6 t!24 f!4 t!6 f!4 t!6>" -- Orchestration
  $ superimpose ((# "cp") . (|* gain 0.4) . mask "t(8,16)")
  $ stut 2 0.6 "s"
  $ "~ c ~ c*2" # "superclap"
  # n 2
  -- # room 0.1
  -- # size 0.8
  # rate 50
  -- # pitch1 (range 1 1.5 perlin)
  # gain 1.9
d4 -- Brass voice
  $ jux ((|+ room 0.1))
  $ superimpose ((# "kurt:2") . (|* gain 0.7) . (|+ pan 0.1))
  $ whenmod 34 32 -- FIXME Match 2nd verse etc
  (fix (
    (# note ("d4"))
    . (# "brass:13")
    . (# release 0.45)
    . (# gain 0.7 )
    ) (note "a3")
  ) -- DUH
  $ note (cat [
    "", "", "", "", "", "", "", "", -- Intro
    -- 9 White shirt
    "bf ~ bf ~ ~ bf ~ bf",
    "~ bf ~ bf ~ [d,g] [g,c6]@2",
    "bf ~ bf ~ ~ bf ~ bf",
    "~ bf ~ bf ~ [d,g] [g,c6]@2",
    -- 13 Creeping around
    ("[g,bf,d6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,d6] ~ [g,bf,d6] ~ [g,bf] [bf,d,f]@2",
    "[gf,a,c6] ~ [g,a,c6] ~ ~ [g,a,c6] ~ [g,a,c6]",
    "~ [e,g,bf] [d,gf,a]@2 . ~",
    -- 17 Bruises
    ("[g,bf,g6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,g6] ~ [g,bf,g6] ~ [d,g,d6] [g,c6]@2",
    ("[g,bf,g6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,g6] ~ [g,bf,g6] ~ [d,g,d6] [g,c6]@2",
    -- 21 what I want
    ("[g,bf,d6,g6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,d6,g6] ~ [g,bf,d6,g6] ~ [g,bf,g6] [d6,g6,c7]@2",
    "[gf,a,c6,gf7] ~ [g,a,c6,g7] ~ ~ [g,a,c6,g7] ~ [g,a,c6,g7]", -- FIXME So Cynical
    "~ [e,g,bf,e6] [d,gf,a,d6]@2 . ~ bf bf c6", -- So you're a
    -- 25 tough guy
    "c6 g     . bf c6 c6 bf",
    "c6 [e,g] . bf c6 c6 bf",
    "c6 g     . bf c6 c6 bf",
    "c6 [e,g] . ~ ~ bf c6",
    "d6 d6     . bf c6 c6 bf",
    "d6 d6     . bf c6 c6 bf",
    "d6 d6     . bf c6 c6 bf",
    "d6 [f,d6] . ~ ~ c6 bf",
    -- 33 I'm the BAD GUY
    "a@2 g@2",
    "~ ~ ~ [d5,a3]",
    -- 34 DUH orchestra hit
    "", "", "", "~ ~ [~ a g]", -- I'm the
    "~ ~ ~ [d5,a3]", "", "", "", -- FIXME BAD - GUY
    -- Verse 2
    -- 43 I like it
    ("[g,bf,g6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,g6] ~ [g,bf,g6] ~ [d,g,d6] [g,c6]@2",
    ("[g,bf,g6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,g6] ~ [g,bf,g6] ~ [d,g,d6] [g,c6]@2",
    -- 47 I'll let you play
    ("[g,bf,d6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,d6] ~ [g,bf,d6] ~ [g,bf] [bf,d,f]@2",
    "[gf,a,c6] ~ [g,a,c6] ~ ~ [g,a6,c6] ~ [g,a,c6]",
    "~ [e,g,bf] [d,gf,a]@2 . ~",
    -- 51 My mommy likes it
    ("[g,bf,g6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,g6] ~ [g,bf,g6] ~ [d,g,d6] [g,c6]@2",
    ("[g,bf,g6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,g6] ~ [g,bf,g6] ~ [d,g,d6] [g,c6]@2",
    -- 55 If she reads
    ("[g,bf,d6,g6]" + "0 ~ 0 ~ ~ 0 ~ 0"),
    "~ [g,bf,d6,g6] ~ [g,bf,d6,g6] ~ [g,bf,g6] [d6,g6,c7]@2",
    "[gf,a,c6,gf7] ~ [g,a,c6,g7] ~ ~ [g,a,c6,g7] ~ [g,a,c6,g7]",
    "~ [e,g,bf,e6] [d,gf,a,d6]@2 . ~ bf bf c6", -- So you're a
    -- 59 tough guy
    "c6 g     . bf c6 c6 bf",
    "c6 [e,g] . bf c6 c6 bf",
    "c6 g     . bf c6 c6 bf",
    "c6 [e,g] . ~ ~ bf c6",
    "d6 d6     . bf c6 c6 bf",
    "d6 d6     . bf c6 c6 bf",
    "d6 d6     . bf c6 c6 bf",
    "d6 [f,d6] . ~ ~ c6 bf",
    -- 67 I'm the BAD GUY
    "a@2 g@2",
    "~ ~ ~ [d5,a3]", -- DUH
    -- 69 Chorus compagnie
    "", "", "", "~ ~ [~ a g]", -- I'm the
    "~ ~ ~ [d5,a3]", "", "", "", -- FIXME BAD - GUY
    "~ ~ ~ [b6,d6] [a6,c6] [b6,d6] [a6,c6] [b6,d6]",
    "~ ~ ~ [b6,d6] [a6,c6] [b6,d6] [a6,c6] [b6,d6]",
    "~ ~ ~ [b6,d6] [a6,c6] [b6,d6] [a6,c6] [b6,d6]",
    "~ c6 c6 d6 c6 d6 c6 bf5", --I'm only good at being
    "c6@2 ~!3",  -- bad
    "", "c6@2 ~!3"  -- bad
    -- 76 TODO fin
  ])
  # "moogBass" -- FIXME RESTORE BRASS SAMPLES!
  # legato "<0.75!7 1>"
  # room 0.2
  # gain 0.7
d6 -- synth Chorus
  $ note (cat [
    "","","","","","","","", -- Intro
    "","","","","","","","", -- White shirt
    "","","","","","","","", -- Bruises
    "","","","","","","","", -- So you're a tough guy
    "","", -- BAD GUY
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "c6 g6 ~ c6 . gf6 g6 gf6 ds6",
    "c6 g6 ~ c6 . gf6 g6 gf6 ds6",
    "d6 a7 ~ [d6 ~] . [gf6 d6 ~ [c6 ~]]",
    "c6 ~ ~ . ~", -- Now second verse
    "","","","","","","","", -- I like it
    "","","","","","","","", -- Mommy
    "","","","","","","","", -- So you're a tough guy
    "","", -- BAD GUY
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "c6 g6 ~ c6 . gf6 g6 gf6 ds6",
    "c6 g6 ~ c6 . gf6 g6 gf6 ds6",
    "d6 a7 ~ [d6 ~] . [gf6 d6 ~ [c6 ~]]",
    "c6 ~ ~ . ~", -- End Chorus 1
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "g d ~ g . df d df bf",
    "c6 g6 ~ c6 . gf6 g6 gf6 ds6",
    "c6 g6 ~ c6 . gf6 g6 gf6 ds6",
    "d6 a7 ~ [d6 ~] . [gf6 d6 ~ [c6 ~]]",
    "c6 ~ ~ . ~" -- End Chorus 2
    ]) # "moogBass"
    # release 0.8
    # legato 1.5
    # gain 1

once $ note ("d") # "kurt:7" # gain 0.8


-- endregion


-- region BONUS COMPONENTS

d2 -- Snare sous-marin
  $ whenmod 32 24 (|* gain (slow 8 $ range 1 0.5 saw))
  $ mask "<f!16 t!16>"
  $ "~ snare:34"
  # lpf (slow 16 $ range 200 20000 perlin)
  # room (slow 40 $ range 0.2 0.5 saw)
  # dry "<1!7 [[2|3|5|7] 1]>"
  # gain 0.8

d4
  -- $ whenmod 16 15 (fast 2)
$ fast "<4!3 [4 8 8 4]>"
$ "drum:8" # gain 0.8
