{-
Anny: Piston LP
anny.audio | pistonlp.co.uk

Current version: 1.1.0
Compatibility: Tidal Cycles 1.0-dev + SuperDirt 1.0-dev + SuperCollider 3.8
License: CC-BY-SA https://creativecommons.org/licenses/by-sa/4.0/

See README.md for more information
-}

let bpm b = cps (b/60)
    msil = mapM_ ($ silence)
    bassP = (# gain 0.7) . (# hcutoff 485) . (# hresonance 0.001)
    d'drum = d1
    d'perc = d2
    d'gnome = d3
    d'bass = d4
    d'fly = d5
    d'bz = d6
    d'shard = d7
    d'misc = d8
    d'ant = d9
    d'cymb = d10

bpm 138

{-
@p1
Piston I
-}

-- @p1fly
d'fly $
  -- whenmod 5 2 (# vowel "i o") $ whenmod 3 1 (slow 2) $ brak $ -- (1)
  slow 16 $ jux (0.5 <~) $ rev . striate 256 $ s "fly"
  # hcutoff 1985 -- 0.09 * (44100/2)
  # hresonance 0.06
  # gain 1 -- 0.5 -> 1

d'perc $ s "wt/2"
d'drum $ sound "k:1"

-- @p1bass
d'bass $ slow 8 $ (0.25 <~) $ rev . chop 16 $ bassP $ n "[0 1]/2" # s "dubb"

d'perc $ s "{wt/2, [~ wtsn]/8}"

d'drum $ s "k"
d'drum $ s "[k*2, [~ sn]]/2"

-- p1fly @ 1

-- @p1perc
d'perc $
  -- within (0.5, 1) (slow 1.5 . chop 4) $ -- (3)
  -- whenmod 5 3 (rev) $ -- (1) (2) rev . chop 8
  density (4/3) $
  s "[wtsn ~ wt]"

-- p1perc @ 1
-- p1perc @ 2
-- p1perc @ 3

-- @p1gnome
d'gnome $ within (0, 0.5) rev $ chop 8 $ s "[gnome(3,8)]/2"
  # gain 0.8
  # speed (scale 0.8 1 $ slow 1.1 sine1)

d'drum $ s "[k*2, ~ [sn [~ sn*3]/2]]/2"

msil [d'drum, d'bass]

d'drum $ s "[k(3,8)]/2"
d'drum $ s "[k(3,8), ~ sn]/2"
d'drum $ s "[k(3,8), ~ [sn [~ sn*3]/2]]/2"

-- @p1bassout
d'bass $ (every 2 $ within (0.25, 0.75) (0.5 ~>)) $ slow 8 $ rev . chop 16 $ bassP $ n "[0 1]/2" # s "dubb"

d'drum $ within (0.5, 1) (chop 8) $ s "[k(3,8), ~ [sn [~ sn*3]/2]]/2"

msil [d'perc, d'fly]

-- p1fly @ 0

d'perc $ s "[~ wt*4 ~ wt*2 ~]/5"
d'drum $ overlay (3.75 ~> s "wtsn/4") $ s "[k(3,8), ~ sn]/2"

{-
@p2
Piston II
-}

d'drum $ slow 7 $ s "k [sn k] [k sn] [~ sn] [~ k] sn [k [k wtsn]]"

msil [d'fly, d'gnome]

-- @p2perc
d'perc $ s "wt*2"
  # vowel "[u e u a]/2"
  # end 0.15

-- @p2bass
d'bass $ slow 8 $ ((1/8) <~) $ chop 32 $ bassP $ n "[0 1]/2" # s "dubb"
  # speed 1.2
  # shape (scale 0 0.5 $ density 4 sine1)
  # cut 1
  -- # vowel "u a" -- (1)

-- @p2ant
d'ant $ slow 2 $ smash 16 [1,2] $ sound "ant:1"
  # cutoff 1764 -- 0.08 * (44100/2)
  # resonance 0.01

-- @p2sharda
d'shard $ ((1/16) <~) $ chop 16 $ s "[ice [~ ice] ~ ~]/4"
  # gain 0.7

-- @p2fly
d'fly $ chop 64 $ s "[fly ~ [fly ~ ~ fly] ~]/4"
  # cut 1
  # begin 0.3
  # end 0.35
  # shape (scale 0.25 0.75 $ density 8 sine1)
  # speed (scale 0.92 1.92 $ density (5/4) saw1)

-- solo p2fly

d'drum $ 0.5 <~ sound "[[k k:1] [sn ~ ~ k]]/2"

-- p2bass

-- @p2cymb
let o = (0.25 ~>)
    g = 0.65
  in d'cymb $ o $
     within (0.5, 1) (# vowel "e") $ (0.5 ~>) $ chop 2 $ s "[cymb*4 cymb*3]/8"
     # shape (scale 0 (1/3) $ density 3.6 saw1)
     # gain g

-- p2perc
-- p2bass @ 1

-- @p2shardb
d'shard $
  -- every 2 (density 1.5) $ whenmod 5 3 (density 2) $ -- (1)
  rev $
  chop 16 $ s "[ice [~ ice] ~ ~]/4"
  # gain 0.7
  # shape (scale 0.25 0.75 $ density 8 saw1)

-- p2shardb @ 1

msil [d'perc, d'fly]

d'drum $ sound "[[k sn] [~ k:1 k:1 ~]]/2"
d'drum $ sound "[k [sn k:1 k:1 ~]]/2"

{-
@p3
Piston III
-}

-- @p3perc
d'perc $
  {- -- (3)
  -- within (0, 0.5) (# vowel "o") $ -- (5)
  -- whenmod 3 2 rev $ -- (4)
  chop 16 $
  within (0.5, 1.5) (
    (# orbit 1) .
    (# delay 0.3) . (# delayfeedback 0.5) . (# delaytime 0.766) --(138/60)/3
    ) $
  -- -}
  stack [
    s "~ wt*2" -- (0)
    -- sound "[[k:1 [~ k:1] k:1 [~ k:1]] sn]/8" -- (1) alone, (2) w/ wt
    ]

do d'drum $ s "k"
   msil [d'bass, d'cymb]

-- @p3bz
d'bz $ s "[ff(3,8) [~ [ff bz]]]/4"
  # end 0.3
  # shape "0 0.25"
  # gain 0.7

d'drum silence
d'drum $ s "[k k sn k]/2"

-- @p3bass
let v = "i" -- (1) o i
    c = 1 -- (3) 0
    b = id -- (2) brak
    in d'bass $
       (4 <~) $ every 2 (0.5 <~) $
       slow 4 . b $
       rev . chop 16 $
       bassP $ n "[0 1]/2" # s "dubb"
       # cut c
       # vowel v

-- p3bass @ 1
-- p3bass @ 2
-- p3bass @ 3

d'drum $ s "{[k*2 [~ k*2] k ~ k*2 ~ k*2 ~]/8, [~ sn]/2}"

-- solo p3bass

-- p3perc @ 1
d'perc $ sound "[[k:1 [~ k:1] k:1 [~ k:1]] sn]/8"

-- @p3dubb
d'misc $ slow 8 $ chop 16 $ bassP $ n "[0 1]/2" # s "dubb"
  # cut 1
  # speed 0.2
  # vowel "e"

d'drum $ s "{[k*2 [~ k*2] k ~ k*2 ~ k*2 ~]/8, [~ sn]/2}"

-- p3perc @ 2
-- p3perc @ 3
-- p3perc @ 4
-- p3perc @ 5

-- @p3shard
d'shard $ -- iter 4 . density 2 $ -- (1)
  -- (p2sharda)
  (0.5 <~) $ ((1/16) <~) $ chop 16 $ s "[ice [~ ice] ~ ~]/4"
  # gain 0.7 -- (0) 0.7 (1) 0.6
  -- # vowel "e o" -- (1)

-- p1gnome
-- p3bass @ 3

{-
@p4
Piston IV
-}

-- solo p3dubb

-- @p4perc
d'perc $
  -- smash 4 [0.5,0.25] $ iter 4 $ -- (1)
  sound "[[~ [wt wtsn]] ~ wt ~]/5"

-- @p4shard
d'shard $
  -- whenmod 7 3 (density (5/4)) $ -- (1)
  within (0.5, 0.75) (iter 4) $ whenmod 3 2 (slow 2) $ slow 8 $ every 2 rev $
  striate 128 $ s "[ice plode]*2" -- (2) ice wtsn
  # cutoff 441 -- 0.02 * (44100/2)
  # resonance 0.001
  # speed 0.7
  # gain 0.7
  -- # vowel "u e" -- (2)

d'drum $ sound "[k sn k*2 [~ sn] [~ k]]/5"

-- p4perc @ 1

-- @p4bz
d'bz $ (0.5 <~) $ slow 16 . chop 32 $ s "bzl"
  # n (density 1.5 "0 1")
  # speed (scale 1 2 $ density 1.7 sine1)
  # gain 0.9

d'misc silence

-- p4shard @ 1

d'drum $ sound "[[k k:1]*2 sn k*2 [~ sn] [~ k]]/5"

-- @p4bass
let o = 0.75
  in d'bass $ (o ~>) $
  whenmod 5 3 (density (3/2) . brak) $
  bassP $
  rev $ (0.5 ~>) $ slow 2 . chop 8 $ n "[0 1]/2" # s "dubb"
  # speed 0.5
  # cut 1
  # end 0.5

msil [d'perc, d'bz, d'shard]

-- @p4bz2
d'bz $ -- every 3 brak $ -- (2) ev3 (4) ev2 (5) ev3
  whenmod 7 4 (within (0.5, 1) (density 2)) $
  (0.5 <~) $
  slow 16 . chop 32 $
  s "bz" -- (0) bz (1) bz*2 (3) bz bzl (4) bz*2 (5) ~ bzl
  # n (density 1.5 "0 1")
  # speed (scale 1.6 2.6 $ density 2.2 sine1)
  # pan (scale 0.25 0.75 $ density 4.1 sine1)

d'drum $ sound "[k*2 sn [~ k] sn]/4"

-- p4bz2 @ 1
-- p4shard @ 2
-- p4bz2 @ 2

-- p4perc @ 1
d'drum silence
d'drum $ sound "[[k ~ ~ k] sn [~ k] sn]/4"

-- p4bz2 @ 3
msil [d'perc,d'bass,d'shard]
-- p4bz2 @ 4

{-
@p5
Piston V
-}

-- @p5perc
d'perc $ s "~ wt wt wtsn/8"
  # shape (scale 0 0.5 $ density 1.2 saw1)

d'drum $ overlay (s "[[k ~ ~ k] ~ [~ k] ~]/4") $ sound "{[~ ~ ~ k:1], [~ sn]/2}"

-- p2ant

do d'drum $ sound "{[~ ~ ~ k:1], [~ sn]/2}"
   msil [d'bz, d'ant]

d'drum $ sound "{k, [~ ~ ~ k:1], [~ sn]/2}"

-- @p5bass
d'bass $
  -- (# gain (scale 0 0.7 $ saw1)) $ -- (6)
  -- within (0.5, 0.75) (# vowel "u o") $ -- (5), (6) delete
  -- every 2 (density 2) $ -- (2)
  -- density 1.6 $ -- (1)
  -- whenmod 3 2 (density 1.6) $ -- (4) replaces (1)
  chop 16 $ bassP $ s "[~ dubb]"
  # n (slow 4 "0 1")
  # cut 1
  -- # speed (scale 0.75 1.25 $ slow 1.3 sine1) -- (3)

-- @p5fly
let b = id -- (0) id (1) brak
  in d'fly $ whenmod 5 3 rev $ b $
     slow 16 $ jux ((1.5 ~>) . rev) $
     chop 64 $ bassP $ sound "fly:1"
     # speed 0.7
     # shape (scale 0 0.5 $ density 2.1 saw1)

d'fly silence

-- p5bass @ 1
-- p5bass @ 2

-- @p5bass2
d'bz $
  -- within (0, 0.5) rev $ -- (3)
  -- whenmod 4 3 (density 1.8) $ -- (1)
  chop 12 $ sound "[~ ~ [~ k:1] !]/4"
  # speed 0.9
  -- # shape (scale 0 (1/3) $ density 3 sine1) -- (2)
  {- -- (4)
  # orbit 1
  # delay 0.3
  # delayfeedback 0.2
  # delaytime 0.2875 --(138/60)/8
  -- -}

-- p5bass2 @ 1
-- p5bass @ 3
-- p5bass2 @ 2

-- @p5gnome
let g sm f = smash 64 sm $ s "~ gnome" # pan (f $ slow 4 sine1)
  in d'gnome $ whenmod 5 3 (slow 1.5) $ rev $
     stack [
       g [0.5,1] id,
       g [(1/2.5),1] (0.5 <~)
       ]
     # speed 1.2
     # shape ((0.25 ~>) $ scale 0 0.5 $ density 3 sine1)
     # gain 0.6

-- p5bass @ 4
-- p5bass @ 5

msil [d'drum, d'bass]
d'drum $ sound "k:1"

-- p5bass2 @ 3
-- p5bass2 @ 4

-- p5fly @ 1
-- p5bass @ 4

d'drum $ sound "{k, [~ ~ ~ k:1], [~ sn]/2}"

-- p5bass @ 6

msil [d'perc, d'bz]
d'gnome silence

{-
@p6
Piston VI
-}

-- solo p5bass @ 6

-- @p6bass
d'bz $ within (0, 0.5) (slow (7/6)) $
  every 2 (0.5 <~) $ slow 8 $
  rev . chop 32 $ bassP $ n "[0 1]/2" # s "dubb"

-- @p6plode
d'fly $ superimpose (slow (5/3) . iter 2) $
  (# speed (scale 0.7 1.7 $ slow 1.1 sine1)) $
  chop 32 $ s "[plode(5,8)]/8"
  # cut 1

-- @p6cymb
d'cymb $
  -- density (5/4) $ whenmod 9 4 (density 1.5) $ -- (1)
  s "[cymb*8 ~]/8"
  # gain (scale 0.6 0.8 $ density 3.6 saw1)
  # cut 1

-- p2perc w/ gain 0.85

d'bass silence
d'drum $ sound "{k, [~ ~ ~ k:1] [~ k:1]}"

-- @p6fbass
d'misc $ slow 16 $ rev . chop 64 $ bassP $ n "[0 1]/2" # s "dubb"

-- p6cymb @ 1

-- @p6wtsn
d'gnome $ (3 ~>) $ within (0.25, 0.75) rev $
  slowspread ($) [chop 16, chop 32] $ s "[wtsn(3,8)]/2"
  # speed (scale 0.8 1.3 $ density 1.8 sine1)

d'drum $ stack [
  sound "{k, [~ ~ ~ k:1] [~ k:1]}",
  s "[~ sn ~ sn*2]/8"
  ]

-- p4bass w/ o=0.6

msil [d'perc, d'gnome, d'misc]

-- @p6gnome
let d = 5 -- (0) 5 (1) 3
  in d'gnome $ iter 5 $ density (9/8) $
     within (0, 0.5) rev $
     smash 8 [1,2] $ s "[gnome(3,8)]/2"
     # gain 0.8
     # speed (scale 0.76 (0.76 + 1/d) $ slow 1.1 sine1)

-- p6gnome @ 1

msil [d'drum, d'fly, d'bz, d'cymb]

d'drum $ sound "[[k k:1]*2 [sn k:1 ~ k] [~ k:1 k ~] [~ sn ~ k]]/8"

-- p5fly @ 1
-- p2cymb w/ o=(0.5 <~), g=0.7
-- p6bass

d'drum $ stack [
  sound "{k, [~ ~ ~ k:1] [~ k:1]}",
  s "[~ sn ~ sn*2]/8"
  ]

msil [d'perc, d'fly, d'bz]

{-
@p7
Piston VII
-}

-- solo $
d'drum $ whenmod 3 2 (slow (4/3)) $ s "[k*2 [sn ~ ~ wt] k*2 sn [~ k]]/5"

d'drum $ every 3 (density 2) $ within (0, 0.5) (jux ((1/3) ~>)) $
  s "[k [sn ~ k] [~ ~ sn] ~]/8"

-- @p7shard
d'shard $ slow 5 . chop 15 $ s "ice"
  # gain 0.7
  # resonance 0.4
  # cutoff 4410 -- 0.2 * (44100/2)
  # orbit 1
  # delay 0.7
  # delayfeedback 0.3
  # delaytime 0.02 -- (0) 0.02 (1) 0.76

hush
d'drum $ s "[k [sn ~ k] [~ ~ sn] ~]/8"

-- @p7perc
d'perc $ s "[wt*3 ~]/2"
  # shape (scale 0 0.5 $ slow 3 saw1)

-- @p7bassa
d'bass $ slow 8 $
  slowspread (\c -> rev . chop c) [12, 24] $
  bassP $ n "[0 1]/2" # s "dubb"

-- @p7fly
d'fly $ slow (4/3) .
  slowspread ($) [slow 1, density (5/4)] $
  slow 12 $
  slowspread striate [24,36] $ sound "fly:1"
  # gain 0.7
  {- (1)
  # orbit 2
  # delay 0.6
  # delayfeedback 0.4
  # delaytime 0.62 --(112/60)/3
  -- -}

-- @p7bz
d'bz $ rev . chop 12 $ s "bz/4"
  # vowel "o"

msil [d'drum, d'perc]

-- @p7bassb
let bm f = scale f (0.5 + f) $ density (5/4) sine1
  in d'bass $
     (# begin (bm 0)) $
     (# end (bm 0.05)) $
     slow 8 $
     slowspread (\c -> rev . chop c) [12, 24] $
     bassP $ n "[0 1]/2" # s "dubb"

-- p7shard @ 0

d'drum $ s "{[k k]/2, ~ sn}"
d'drum $ s "{[[k ~ k] k]/2, ~ sn}"

-- p7shard @ 1

msil [d'bass, d'shard]

-- @p7bassc
d'bass $ slow 8 $
  within (0.33, 0.67) (0.25 ~>) $
  slowspread (\c -> rev . chop c) [12, 24] $
  bassP $ n "[0 1]/2" # s "dubb"
  # vowel "o"

d'bass silence
d'drum $ within (0, 0.5) (jux ((1/3) ~>)) $ s "[k [sn ~ k] [~ ~ sn] ~]/8"
d'bz silence

{-
@p8
Piston VIII
-}

-- p6fbass w/ chop 32

d'drum $ within (0, 0.5) (superimpose ((1/3) ~>)) $ s "[k [sn ~ k] [~ ~ sn] ~]/8"

-- @p8bz
d'bz $ s "[[ff bz]*2 [~ bz*2]]/2"
  # n (slow 2 $ run 5)
  # begin 0.7
  # end 0.85
  # hcutoff 882 -- 0.04 * (44100/2)
  # hresonance 0.1
  # shape (scale 0 0.2 $ slow (5/3) sine1)
  # gain 0.8

d'drum $ s "[k*2 [sn ~ ~ wt] [~ k] sn [~ k]]/5"
d'drum $ s "[k [sn ~ ~ wt] [~ k] sn]/4"

-- p6fbass
-- p2ant

d'drum $ s "[k [sn ~ ~ k] [~ k] sn]/4"

-- p2fly on d'misc
-- p5bass @ 3

d'perc $ s "{wt/2, [~ wtsn]/8}"

-- p6cymb @ 1

-- @p8perc
-- solo $
d'perc $ stack [
  {- -- (3)
  -- (p1fly @ 2)
  whenmod 5 2 (# vowel "i o") $ whenmod 3 1 (slow 2) $ brak $
  slow 16 $ jux (0.5 <~) $ rev . striate 256 $ s "fly"
  # hcutoff 1985 -- 0.09 * (44100/2)
  # hresonance 0.06,
  -- -}
  -- (p1perc)
  -- within (0.5, 1) (slow 1.5 . chop 4) $ -- (4)
  -- whenmod 5 3 (rev) $ -- (1) (2) rev . chop 8
  density (4/3) $
  s "[wtsn ~ wt]"
  ]

-- p8perc @ 1
-- p8perc @ 2
-- p8perc @ 3
-- p8perc @ 4

d'drum $ s "[k [sn ~ ~ k] [~ k*2] sn]/4"

msil [d'fly, d'bz, d'shard, d'misc, d'ant, d'cymb]

-- @p8bass
d'misc $ stack [
  {- -- (1)
  -- (p5bass)
  every 2 (density 2) $ whenmod 3 2 (density 1.6) $
  chop 16 $ bassP $ s "[~ dubb]"
  # n (slow 4 "0 1")
  # cut 1
  # speed (scale 0.75 1.25 $ slow 1.3 sine1),
  (0.75 ~>) $
  -- -}
  -- (p4bass w/ o=id)
  whenmod 5 3 (density (3/2) . brak) $
  bassP $
  rev $ (0.5 ~>) $ slow 2 . chop 8 $ n "[0 1]/2" # s "dubb"
  # speed 0.5
  # cut 1
  # end 0.5
  ]

d'drum $ s "[k*2 [sn ~ ~ k] [k k*2] sn]/4"

-- p4shard @ 2
-- p5fly @ 1
-- p6bass
-- p6wtsn
-- p6gnome @ 0
-- p3shard @ 0
-- p6gnome @ 1
-- p3shard @ 1

msil [d'fly, d'shard, d'bz, d'misc, d'cymb]

-- p8bass @ 0

-- p2cymb w/ o=(2.75 ~>), g=0.7

msil [d'gnome, d'ant]

-- p4bz2 @ 5

msil [d'bz, d'cymb, d'misc]

-- solo p1perc @ 3
hush
