-- Metronome
do
  let gF = 1.5
  setcps (100/60/4)
  d1 $ "m*4" # "gretsch:11" # gain gF * 0.55
  d2
    $ every' 4 3 (off (1 - "e")
    (|* gain 0.8)
    . (# lpf 2000)
    )
    $ "[bd,gretsch:12]"
    # release 1
    # gain gF * "<0.55 0.5!3>"

d1 $ slow 2 $ stitch "t . t(3,8)"
  (n "0 .. 7" # sound "bd")
  (sound "arpy")
  # gain 0.7

-- TECHNO
do
  setcps (120/60/4)
  let gG = (# gain 0.95)
  d1 $ gG $ "jazz*4"
  d3 $ gG
    $ sometimesBy (slow 16 $ range 0.2 0.8saw) (off "s" id) $ "hh*8"
  d2 $ gG $ "~ cp" # lpf 2000


-- Techno hh(13/16) PIANO prog+MIDI"note" degrade1
do
d1 $ "jazz*4"
d4 $ "hh(13,16)"
d2
  $ (1 ~>)
  $ degradeBy (1 - (cF 0 "1"))
  $ note "<0 5 7>"
  # "superpiano"
  # velocity 0.7 # legato 4
d3
  $ degradeBy (1 - (cF 0 "1"))
  $ euclid "<8!2 16!2>" 16 $ note (cF (0) "note")
  # "superpiano"
  # velocity 0.7 # legato 4

-- BREAKS
do
  d1 $ ""

-- Lucy's Broken Diamond
do
let gD = (degradeBy 0.1)
setcps (80/60/4)
d1
  $ superimpose (const
      $ "k . <~!16 k!4 k(3,8)!4 k(3,8,3)!4>"
      # "reverbkick"
      # lpf 200
      # gain 1.1
  )
  $ gD
  $ slice 4 ("0 <0 1> <2 0> 3*<1 2 4 4>")
  $ loopAt 1 $ "fbreak80:5" # cut 1
  # gain (slow 32 $ range 0.85 1.25 sine)
d2
  $ fast "<1!8 2!8>"
  $ "~ cp"
  # gain 0.8
  # lpf 2000
d3
  $ whenmod 64 32 (iter 4)
  $ slice 2 ("<<0 1>!16 0!4 1!4 [0 1]!4 [0*2 1*2]!4>")
  $ "fbass:8"
  # cut 3
  # gain (slow 16 $ range 0.85 1.2 sine)

-- rare 9
-- 1 4
-- 5 6 7 8

-- BreakBeat Echographie
do
  let gD = degradeBy "0"
  setcps (80/60/4)
  d1
    $ gD
    $ sometimesBy "0 0" (swing 2)
    $ "k . <~!4 k(<1 2 3 5>,8)!4>" # "[jazz,bd]"
    -- # lpf 1500
  d2
    $ gD
    $ jux (rev . (# cut 21))
    $ whenmod 8 4 (ply "<1 <2 [2|4]>>")
    $ slice (slow 4 "<2 4>") ("0 <0 1>")
    $ "fbreak80:5" # cut 2 # gain 1
    # lpf (slow 24 $ range 10000 200 sine)
  d3
    $ gD
    $ "~ ~ ~ cp/2" # djf (slow 16 cosine)
  d10
    $ fix (|* gain 0.75) (n 4)
    -- $ often (fast "<[2|4] [4|8]>")
    $ n (stack ([
      "4(1,8)",
      "<5 6>(<5 3>,8,<0!3 4>)"
      ]))
    # "space"
    # cut 10
    # gain 0.8



  -- setcps 0
  -- TODO record with SEQ 6: jazz impro All the things you are left hand
  -- Noisy Snake Hats
  do
  setcps 0.55
  -- resetCycles
  let dg = id
  d1
    $ dg
    $ someCyclesBy (slow 16 $ "<0 0.25>") (off "e" id)
    $ "[jazz,cpu]"
    # gain (slow 16 $ range 0.8 0.4 isaw)
    # lpf 2000
    # release 0.2
    # pan 0.45
    # dry 0.9
  d2 -- Snares / claps:  accel 16/8, djf/64
    $ dg
    $ whenmod 16 8 (fast ("2 <4!8 <8!8 [4 . 8 [2|4]]!8>>"))
    $ superimpose ((# "clap:2") . (|* gain 0.7))
    $  "~ snare" # n "[1,2]"
    # gain (slow 32 $ range 0.8 0.5 isaw)
    # pan 0.3
    # djf (slow 64 (cosine + perlin/4))
  d3 -- Hats snake-ish
    $ dg
    $ (|+ pan (slow 10 $ range 0 0.25 saw))
    $ juxBy 0.2 (rev . (|* gain 0.85))
    $ fast 2
    -- $ sometimesBy "0 1" (off "e" id)
    $ "h . h ~ <h!3 h?> ~ ~ <~!3 h?>"
    # "808oh"
    # n "<0 3>"
    # gain (slow 32 $ range 0.6 0.4 (sine + isaw/4))
  d10 -- DELICI0US N0153
    $ dg
    $ whenmod 64 48 (juxBy 0.25 (# crush 5))
    $ whenmod 8 6 (rarely (loopAt 2))
    $ "~ ~ ~ <n!3 [~ n] n [~ n] n [~ n]>"
    # "psr" # n "<1!8 10!4 11!4 12!7 2>" -- 1 10 11 12  rare 2
    # lpf (slow 2 $ range 2000 1000 perlin)
    # pan (slow 4 $ range 0.2 0.9 perlin)
    # gain (slow 32 $ range 0.25 0.45 (saw + perlin))
    # cut 10


-- Hip Beat rebond k k([3|5],8)
do
setcps (120/60/4)
d1
  $ whenmod 32 16 (# djf (slow 16 $ sine))
  $ "k . k(<3 <5 1>>,8)"
  # "jazz" # gain 0.8
d2 $ "~ snare:8"
d3
  $ whenmod 16 8 (jux rev)
  $ fast "<4 4 8 4>"
  $ "drum:8" # gain (slow 16 $ range 0.6 0.85 saw)

-- Space techno beat
do
setcps (115/60/4)
d1 -- Kick techno
  $ s "k*4" # "jazz" # gain 0.525
d2 -- Snare contretemps
  $ mask "<f!2 t!30 t!32>"
  $ s "~ . <s!3 s*2> ~" # s "[snare,cp]" # gain 0.5
d7 -- Drumroll énergisant
  $ jux rev
  $ fast "<4!3 <8 [8 16 8]>>"
  $ "drum:2*[<2!3 4>]"
  # gain 0.65

-- LoopBack
do
setcps (60/60/4)
d1 $ "[bd,jazz]*4" # gain (1.1)
  # djf (slow 32 $ range 0 0.5 cosine)
d2 $ "drum:2*4" # note "0 1 0 1" # gain 0.6
d3
  -- $ off 1 (jux (rev . chop 8))
  -- $ chop 8
  -- $ stut 4 1 0.25
  $ "in"
  -- # room 0.1
  -- # sz 0.8
  -- # legato (slow 16 $ range 0.12 2 sine)
  -- # gain 2

-- Break maracas Mamoi
do
d3 $ "drum:2*4" # gain 0.5
d1
  $ slow 2
  $ "k*<1!3 2> . k(<3 3 [3 5] 3>,8,<0!6 4>)"
  # "reverbkick"
  # gain 0.75 # lpf 4000
d2
  $ whenmod 16 10 (# lpf (slow 6 $ range 5000 200 saw))
  $ loopAt 2
  $ slice 4 "<0 0 3 <0 3>> 1*<1 1 2 <1 2>> 2*<1 2 2 4> 3"
  $ "breaks165" # cps (165/50/4)
  # gain (0.55 * "1 1 0.9 1")

-- LoFi
do
setcps (60/60/4)
let whenIntro    pat = someCyclesBy "<t!8 f!24>" pat
let whenNotIntro pat = someCyclesBy "<f!8 t!24>" pat
let whenBrk      pat = whenmod 16 10 pat
let whenNotBrk   pat = someCyclesBy "<t!10 f!6>" pat
let whenBrkLPF  = whenBrk (# lpf "<400 200 100 50 0 0>")
d1
  $ whenBrkLPF
  $ whenNotBrk (# sz "<0.8 0.9 0.95 0.99>")
  $ "k . k(3,8)" # "[jazz,reverbkick]"
  # gain 1 # lpf 1000
  # room 0.23
  # legato 2 # cut 1
d2
  $ whenBrkLPF
  $ whenmod 16 8 (fast 2)
  $ whenmod 8 6 (mask "<f [f t]>")
  $ superimpose (# hpf 500)
  $ "~ s"
  # "snare:20"
  # gain 0.9
d3
  $ whenBrk (slow "<2 2 4 4 8 8 16 16>")
  $ fast ("8" * "<[2 1!7] 1!3> <2 [2 1] [2 . 1 2] [2 4]>")
  $ "drum:2"
  # room 0.6
  # gain 0.8
d5
  $ swing 2
  $ whenBrk (# crush (slow 6 $ range 16 3.5 saw))
  $ whenNotBrk (off "<e q> . <q h>" (|+ note 7))
  $ struct "t*<[1 0] 2 4 [12 . 8]>"
  $ note ("fs a" - 24)
  # "bassWarsaw"
  # gain 1
d4 -- Toy bogdan
  $ every' 16 15 (# "bogdan:4")
  $ every' 16 9 ((# "~ ~ ~ bogdan:2") . (|* gain 0.8))
  $ "~ ~ ~ bogdan:0"
  # room 0.5
  # legato 2
  # hpf 200
  # gain 1.1

once $ "bogdan:4" # cut 42 # gain 0.9
