-- Study: Ableton Learning Music
-- https://learningmusic.ableton.com/make-basslines/good-life.html
let lineGoodLife = "b3 ~ ~ b3 ~ ~ b3 ~     ~ fs3 ~ ~ fs3 ~ ~ a3           ~ a3 ~ a3 ~ ~ e3 ~       ~ e3 ~ e3 b3 ~ b3 ~"
let lineAround0 = "~ ~ ~ ~ a4 ~ ~ ~ a4 ~ ~ ~ a4 ~ b4 c5" -- [0,1,2,3]
let lineAround1 = "~ ~ ~ ~ c5 ~ ~ ~ c5 ~ ~ ~ c5 ~ d5 e5"
let lineAround2 = "~ ~ ~ ~ e5 ~ ~ ~ e5 ~ ~ ~ e5 ~ ~ ~"
let lineAround3 = "fs5 ~ e5 ~ d5 ~ c5 ~ b4 ~ a4 ~ g4@3 a4"
let lineTeng = "cs d d d cs d d d cs d d d g ~ fs ~"
let lineNever = "<[~ ~ c5 b4 a4 ~ ~ ~] [~ <g4 <~ <g4 d5>>> <a4 ~> <g4 d5> a4 ~ ~ ~]>"
let lineOblivion1 = "d4 d4 d5 a4 d4 <d4 d5> <f4 a4> a4" -- [1,1,2,2]
let lineOblivion2 = "b4 b4 b5 fs4 b4 <b4 b5> <d4 fs4> fs4"

do
setcps (148/60/4)
let lineLoveTear = "e4@8"
d1 $ "jazz"
d2 $ "~ clap:2"
d4 $ note () # "FMRhodes1"

-- Exercise in space
do
setcps (127/60/4)
let lineNever = "<[~ ~ c5 b4 a4 ~ ~ ~] [~ <g4 <~ <g4 d5>>> <a4 ~> <g4 d5> a4 ~ ~ ~]>"
d1 $ loopAt 2 $ "break:1"
  # cut 1 # gain 0.8
d4
  $ note (lineNever)
  # "bass:4" # att 0.1 # rel 2 # lpf 4000
  # gain 1.1

do -- Oblivious to your synths
let lineOblivion1 = "d4 d4 d5 a4 d4 <d4 d5> <f4 a4> a4"
let lineOblivion2 = "b4 b4 b5 fs4 b4 <b4 b5> <d4 fs4> fs4"
d4
  $ note (cat [lineOblivion1,lineOblivion1,lineOblivion2,lineOblivion2])
  # "cs80leadMH"
  # att 0.1 # rel 1
  # room 0.4
  # cut 4

do
setcps (82/60/4)
let gF1 =  (# djfbus 1 (range 0.05 0.95 "^49"))
let gF2 = (# djfbus 2 (range 0.05 0.95 "^50"))
let gF3 = (# djfbus 3 (range 0.05 0.95 "^51"))
let gMask = (midiOn "^41" (mask "t . <f t f <f t>> <t f f <t f>>"))
let gMute = (midiOn "^73" (mask "f*16"))
let gMute2 = (midiOn "^74" (mask "f*16"))
let gM = gMask . gMute
let gM2 = gMask . gMute2
d1 $ gF1 $ gM
  $ midiOn "^42" ((<| "k k k k k k <k <~ k*2>> k*<1 2 2 2>") . (# "[jazz:0]"))
  $ midiOff "^42" (<| "k . <~!4 k!4 k(3,8)!8>")
  $ "[rootsDrums:0,rootsDrums:4]"
  -- $ "[techno,jazz,kick:5]*4"
  # midiG' "^78" 0 1.5
d3 $ gF1 $ gM
  $ "[~ drum:2]*8"
  # midiG' "^80" 0 1.5
d4 $ gF2 $ gM2
  $ midiOff "^57" ((slow 2) . ( # room 0.5))
  $ note (lineTeng)
  # "rootsBass"
  # crushbus 41 (range 16 2.5 "^53")
  # end 0.35 # room 0.3
  # legato 2 # gain 1.9 # cut 1
  # midiG' "^81" 0 1.5
d8 $ gF1
  $ midiOn "^92" (ply "1 2")
  $ midiOn "^60" (slice 16 (run "<16!8 [16 8]!7 [8 16]> <16!3 <32 [8 32]>>") )
  $ chop 8
  $ (someCyclesBy "^20" (# n "21"))
  $ "jungle_breaks:33"
  # midiG' "^84" 0 1.5


d2 $ gF1
  $ whenmod 32 24 (fast "<2!3 [<2 4> 4]>")
  $ "~ [cp,snare:24]"
  # pan 0.7
  # midiG' "^79" 0 1.4
d3 $ gF1
  $ sometimesBy (slow 16 $ range 0 0.5 saw) (mask "t(3,8) t(5,8)")
  $ "hh*[16 16 16 <8!2 16 12>]"
  # midiG' "^80" 0 1.6
  # room 0.2 # dry 1
  # pan (0.4 + 0.2 * (slow 4 perlin))
d4 $ gF2
  $ midiOn "^89" (|+ note "c'minPent'2")
  -- $ midiOn "^57" (<| note lineAround3)
  $ note (slow 2 $ lineGoodLife) # "bassWarsaw"
  # octave 4
  # crushbus 41 (range 16 2.5 "^53")
  # octersubbus 42 (range 0 4 "^33")
  -- # delayfb 0.8 # delayt 0.25
  # midiG' "^81" 0 1.4
  # pan 0.3
d5
  $ midiOn "^90" (sometimesBy "0 1" rev)
  $ midiOn "^58" (struct "t(<3!3 <5 2>>,<8!7 4>) . t(<5!7 <8 16>>,8)" . arp "pinkyup")
  $ note ("<[a4,c4,e4] [c4,e4,g4] [e4,g4,b4] [d4,fs4,g4]>")
  # "moogBass"
  # midiG' "^82" 0 1.6
d8 $ gF3
  $ midiOn "^92" ((# pan 0.4) . (# n "19"))
  $ sometimesBy "^56" (slice 4 ("0 <1 <1*2 ~> ~ 1> <2 ~> 3*<1 <2 4>>"))
  -- $ whenmod 4 3 (slice 4 ("0 1 2 3*4"))
  $ loopAt 2 $ chop 8
  $ n "20" # "jungle_breaks"
  # pan 0.55
  # midiG' "^84" 0 1.8
