-- https://learningmusic.ableton.com/make-melodies/love-will-tear-us-apart.html
let loveTears = "<<e4!3 [e4 fs4 e4@6]> [fs4@2 g4 fs4@2 e4 d4@2] [b3@7 <d4 fs3>] a3>"
-- How is this melody put together?
--
-- This melody uses only notes in the scale of D major. But the melody starts with a long E, creating a sense of tension against the implied key that continues throughout the whole song.
--
-- Notice the shape (or contour) of the melody. At the beginning, it moves up and down the scale by adjacent notes. But at the end, it leaps from B up to D and then down to A. This contrast between stepwise and leapwise motion helps to make the melody strong and memorable.
-- Try making some of your own melodies that also use a contrast between steps and leaps.
--
let lineTourDeFrance1 = "<[f3@2 bf3 c4 f4@3 d4] [f4 g4 c4 d4 f4@2 bf4@2] <af4 c5>@2>"
let lineTourDeFrance2 = "<[g3@2 c4 d4 g4@3 e4] [g4 a4 d4 e4 g4@2 c5@2] <bf4 [bf4@2 ef5 c5@13]>@2>"
-- The first and second phrases are identical, with the exception of the final note. In the first phrase, the last two notes descend from B♭ to A♭, while in the second phrase, they ascend from B♭ to C. You can hear this as a sort of "question and answer" relationship; the first phrase sounds somehow incomplete, while the second phrase sounds like it serves to resolve the first.
--
--
let praxis = "<[~ d5 d4 e4 g4 a4 b4 d4] [e4 g4 a4 b4 <e4 g4>@4]>"

-- Prestance
do
setcps (134/60/4)
let gMute = (midiOn "^73" (mask "f*16"))
let gM = gMask . gMute
let praxis = "<[~ d5 d4 e4 g4 a4 b4 d4] [e4 g4 a4 b4 <e4 g4>@4]>"
d1 $ gF1 $ gM
  $ midiOn "^42" (<| "k k k k")
  $ midiOff "^42" (<| "k . k(<0!3 1 0 1 3 3>,8,<0!3 6>)")
  $ "[jazz,808bd:3]"
  # midiG' "^78" 0 1.4
d2 $ gF1
  $ midiOn "^43" (<| "~ c ~ c")
  $ midiOff "^43" (<| "~ <~ c>")
  $ "cp"
  # note "-2"
  # midiG' "^78" 0 1.8
d3 $ gF1 $ gM
  $ midiOn "^75" (loopAt 2 . (>| "jungle_breaks:35"))
  $ midiOn "^43" (off 0.5 (ply "<1!3 2>"))
  -- $ chop 8
  $ midiOff "^75" (slice 8 "<0 1 2 3 [0 1] [1 2] [1 2] [1 2]>")
  $ loopAt 2
  $ "break:20"
  # midiG' "^79" 0 1.4
d4 $ gF2 $ gM2 $ note "<[a2@2 ~ ~ a2 b2 ~ <~!1 <b2 e2>>] <e2 g2>>"
  # "FMRhodes1" # cut 4
  # modIndex 5
  # room 0.2
  # delay 0.8
  # delayfb "<0.1!3 0.65>"
  # delayt 0.125
  # crushbus 41 (range 16 2.5 "^53")
  # midiG' "^81" 0 1.6
d6 $ gF3 $ gM2
  $ mask "<f!12 t!4>"
  $ note praxis
  # "bassWarsaw"
  # modIndex 5
  # midiG' "^17" 0 1.4
  # pan 0.3
d7 $ gF3 $ gM2
  $ mask "<t(10,16)!8 f(10,16)!8>"
  $ note (praxis + 36)
  # "prophet5pwmStrings"
  # pan 0.9
  # midiG' "^18" 0 1.4
d8 $ gF3 $ gM2
  $ mask "<f(10,16)!8 t(10,16)!8>"
  $ juxBy 0.3 (mask "t(3,8) . t(12,16)" . (|+ note 12))
  $ note (rev praxis)
  # "moogBass"
  # modIndex 5
  # pan 0.9
  # midiG' "^19" 0 1

do
let loveTears = "<<e4!3 [e4 fs4 e4@6]> [fs4@2 g4 fs4@2 e4 d4@2] [b3@7 <d4 fs3>] a3>"
setcps (148/60/4)
d1 $ "<k!7 [k k*2] [k*4]!8>" # "jazz"
d2 $ fast "<1!7 [1 4] 2!3 [2 4] 2!3 4>" "~ snare:55"
d3 $ "[~ hh]*4"
d4
  $ note (loveTears
    + "[0,12]")
  # "[FMRhodes1]"
  # gain 1.4
  # pan 0.8
d5
  $ mask "<t!4 f!4> t!12"
  $ rev
  -- $ mask "<f!8 t!8>"
  $ note (loveTears
    + "[24]")
  # "[FMRhodes2]"
  # gain 1.2
  # room 0.4 # sz 0.4
  # pan 0.3
