resetCycles


do
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 gMute3 = (midiOn "^75" (mask "f*16"))
let gM1 = gMask . gMute
let gM2 = gMask . gMute2
let gM3 = gMask . gMute3
let width = pF "width"
let fundamental = slow 4 $ "<gb3'maj db3'maj bb2'min bb2'maj>"
setcps (128/60/4)
d1 $ gF1 $ gMute2
  -- $ midiOff "^42"  (<| "<k [~!7 k*<1 2>]>")
  $ fix (# bandf 300) "clubkick"
  $ midiOff "^42" (<| "k . ~ k*<1 2> ~ <~ k k <~ k*4>>")
  $ midiOn "^42" (<| "k  k . k <k [~ k] k k*2>")
  $ "[jazz,clubkick]"
  # cut 1
  # gain 1.5
d2 $ gF1 $ gM1 -- Clap Technocratique
  $ midiOn "^43" (mask "[t <f t!3>] [t <f t>]" . fast 2)
  $ "~ s ~ [s*<1 2> <~ s*<2 [4 2]>>]"
  # "vec1_claps" # n 10
  # gain 1.7
  # lpf 4000 # cut 2
d3 $ gF1 $ gM1 
  $ midiOn "^44" (ply "2 <2!3 [2|4|[4 8]]>")
  $ "~ h ~ h ~ h*<1!3 2> ~ h*<1 [1|2]>" 
  # "h2ogmhh" # n "<0!4 1!3 2>"
  # gain (1.4 * (range 0.9 1.2 perlin))
d4 $ gF2 $ gM3
  $ midiOn "^89" (ply 4) -- HIGHER
  $ chop 8 
  $ loopAt 4 
  $ midiOn "^57" ( -- HIGHER
    slow 2 . ply 2 . 
    (# n "<1 1 2 2 6 6 6 1 16 16 17 18>" )
    .  (|* gain 0.9)
  )
  $ midiOff "^57" ( -- LOWER
    (# n "<5 5 5 6>")
    )
  $ "perfect" 
  # room 0.4 
  # sz 0.4
  # octersub 0.4
  # crushbus 41 (range 16 4.5 "^53")
  # octersubbus 42 (range 0 2.5 "^33")
  # octersubbus 43 (range 0 5 "^17")
  # cut 4 
  # gain 1.5
d5 $ gF3 $ gM3 -- COUNT TO SUPERSTARDOM
  -- $ slow 2
  $ midiOn "^29" (
    slice 16 "<<[0 1 2 3] [<0 10> <1 11> 10 11]> <[8 9 10 11] [<12!3 15> <13!3 15> <14 12> <15 13>]>>" 
    . (>| "perfect")
    )
  $ midiOn "^90" (ply "<2 4>")
  $ midiOn ("^34" - "^18") ( -- THE HIPS THE FACE THE LIPS THE MICROPHONE 
    slice 4 "<0 1 0 1 2 2 [2 2] 3>"
    . (# n 14) . (|* gain 0.8)
    )
  $ midiOn "^18" -- SUPERSTAR
    (
      -- mask "<t f!3>" 
      loopAt 4
      . (0.5 ~>)
      . (# n 8)
      . mask "<t!4 t f t t>"
      . (# end "<0.18!3 0.45 1!4>")
      . (# begin "<0!4 0.5!4>")
      . (|* gain 0.9)
      )
  $ midiOn ("^58") ( -- Slice 1 2 3 4!
    slice 8 "<[0 1] [0 1] [0 0 <0 1> <1 0>] [2 3]>" )
  $ midiOff ("^58"+"^29" + "^34") ( -- WATCH ME WORK IT
    slice 8 "<[0 1] [2 3] [4 5] [6 <7 <6 6*2>>]>"
    )
  $ "perfect" 
  # cut 5
  # room 0.4 # sz 0.39
  # pan "0.2 0.8 0.2 0.8"
  # gain 1.5
  # octersub 0.8  
d6 $ gF1 $ gM3 
  $ mask "f t" 
  $ midiOn "^89" (ply "<4 8>")
  $ chop 16
  $ "meth_bass:3/8" 
  # room 0.4 
  # sz "<0.7!3 1.1>"
  # delay 0.8 # delayt 0.125 # delayfb 0.5
  # gain 1.4
  # cut 6
d7 $ gF3 $ gM3 
  $ midiOn "^59" (off (1/16) (|+ note 7))
  $ note (
    fast 2 
    "<[f3 <bf3!2 bf3!2 cs4!2 f4!2> <cs4!2 gs4!2> f4]>"
     + "[0,<0!8 12!8>]"
    )
  # s "acidOto3092"
  # gain 1.4
  # width (range 0.5 0.98 "^35")
  # crushbus 71  (range 16 3.5 "^55")
  # cutoff (slow 3 $ range 300 3000 (sine * saw)) -- more erratic filter
  # room 0.2 # sz 0.4 
d12 $ gF3 $ gM3 -- Acid techno arp with structured rhythms
  $ note (slow 2 $ 
        "<[bf2 . cs3 [ef3 bf3]] [cs3 ef3 . bf3] [ef3 . [bf3 cs4] ef3] [[bf3 gs3] . cs3 ef3]>")
    # s "acidOto3091" 
    # gain 1.3
    # cutoff (slow 4 $ range 400 2500 saw)  -- classic acid filter sweep
    # resonance 0.3
    # accelerate (choose [0, 0.1, -0.1]) -- slight pitch drift
    # room 0.2 # sz 0.3
d8 $ gF1 $ gM1 
  $ midiOff "^60" (mask "t(<4 [<2 4> 8]>,8,1)" . chop 8)
  $ midiOff "^56" (
    slice 8 "0 1 <2!3 ~> <3!3 0> <4!3 1> 5 <6!12 ~!3 6*4> 7*<1 2 0 8>")
  $ midiOn "^56" (loopAt 2 . (# "jungle_breaks:19"))
  $ chop 8 
  $ loopAt 1 
  $ "breaks165" 
  # cut 8
  # gain 1.2 
  # pan (slow 4 $ range 0.9 0.1 sine)
d9 $ gF2 $ gM3-- slow arpeggiated synth, high register 
  $ mask "t <f!8 t!8> <f!4 t!4> <f!8 t!8>"
 $ fast 4
 $ arp "up" 
 $ note (slow 2 $ "<bf4'min cs4'maj ef4'min bf4'min>")
 # "90s_synatm:3" |+ note 12  -- or "foo" 
 # room 0.7 # sz 0.9
 # delay 0.5 # delaytime (1/3) # delayfb 0.4
 # lpf 1400
 # cut 9
d10 -- Euclidian mid arpss
 $ struct "t(5,8,2)" 
 $ note (slow 2 $ "<bf3 cs4 ef3 bf3>" + "<0 7 12>")
 # s "moogBass"
 # gain 1.2
 # room 0.5 # sz 0.6
 # lpf (slow 4 $ range 2000 3500 sine)
-- d11: sparse chord stabs, ambient pad
d11 
 -- $ slow 8
 $ note (slow 2 $ "<bf3'min'5 cs3'maj'5 ef3'min'5 bf3'min'5>")
 # s "sine" |- note 12
 # gain 1.4
 # attack 0.5 # release 2
 # room 0.9 # sz 0.95
 # lpf 3000
 # delay 0.7 
 # delayt "e" 
 # delayfb 0.8

-- d12: high shimmer, random note selection from chords
d12 
 $ fast 2
 $ note ((slow 2 $ "<bf cs ef bf>") 
        + (slow 3 $ "0 12 19 24 <0 7>"))  -- chord tones, high octaves
 # s "superpiano"
 # gain 0.5
 # velocity (range 0.3 0.6 perlin)
 # room 0.8 # sz 0.8
 # lpf 5000 # hpf 800  -- shimmer zone
 # delay 0.6 # delaytime "0.375" # delayfb 0.5





-- Layered periodicities - 4 bar chords + 3 bar melody = phasing
d1 $ note ((slow 4 "<gb4 db4 bb3 bb3>") 
          + (slow 3 "<[0 2] [3 5] [7 5]>"))
   # s "FMRhodes1" 
   # velocity (slow 2 $ range 0.6 0.9 sine)
   # room 0.5

-- Fundamental + rhythmic variation at different rates
d1 $ note ((slow 4 "<gb4 db4 bb3 bb3>") 
          + (slow 2 "0 ~ 3 ~ 5 ~ 7 2"))
   # s "FMRhodes1" 
   # lpf (slow 8 $ range 2500 4000 sine)
   # room 0.4

-- Complex algorithmic: structure + melody + octave shifts
d1 $ note ((slow 4 "<gb4 db4 bb3 bb3>")        -- 4-bar roots
          + (slow 2 "<0 3 5 7>")                -- 2-bar melody
          + (slow 3 "<0 12 -12>"))              -- 3-bar octaves (polyrhythm!)
   # s "FMRhodes1" 
   # room (slow 8 $ range 0.3 0.7 sine)        -- reverb automation
   # lpf 3500

-- Sparse topline with evolving density
d1 $ note ((slow 4 "<gb4 db4 bb3 bb3>") 
          + (slow 2 "<[0 ~ 5 ~] [3 ~ 7 ~] ~ [2 5]>"))
   # s "FMRhodes1" 
   # delay 0.4 # delaytime (1/3) # delayfb 0.3
   # room 0.5

-- Full algorithmic composition
d1 $ note ((slow 4 "<gb4 db4 bb3 bb3>")        -- fundamental
          + (slow 3 "<0 2 3 5 7 9>")            -- melodic movement
          + (slow 5 $ "0 ~ 12 ~ -12"))          -- octave variation
   # s "FMRhodes1" 
   # velocity (slow 2.5 $ range 0.5 0.9 perlin) -- random dynamics
   # lpf (slow 6 $ range 2800 4200 sine)
   # room 0.4 # sz (slow 4 $ range 0.6 0.9 sine)


once $ "perfect"
