{-
Anny: Haddeo (Algorave Remix)
anny.audio

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)
    withmod a b c d = (whenmod a b . within (c, d))
    every' n o f = when ((== (o-1)) . (`mod` n)) f
    msil = mapM_ ($ silence)
    tmod s e = (# nudge (scale 0 s $ fmap (**e) saw1))
    swing a = within (0.1, 0.4) (a ~>) . within (0.6, 0.9) (a ~>)
    d'drum = d1
    d'bass = d3
    d'bass2 = d2
    d'wax = d4
    d'nim = d5
    d'hi = d6
    d'fx1 = d8
    d'fx2 = d9
    d'fx3 = d10
    -- given bpm = 105
    tmod' s e = tmod (s*(1/(105/60))) e
    mt i = slow 16 $ tmod' 0.5 3 $ density 16 $ i

bpm 105
hush

-- pt 1: intro

-- @hdrum0
d'drum $ stack [
  n "1/4" # s "drum" -- (2) remove
  -- n "[1*2, 0*8]/8" # s "drum", -- (2)
  -- n "[~ 0]" # s "kit" -- (1)
  ]

-- @hic1
d'wax $ slow 16 . striate 256 $ s "icarus"

-- hdrum0 @ 1
-- hdrum0 @ 2

-- @hic2
d'wax $ retrig $ slow 20 $ sound "icarus:1"

-- drop 1

-- @hnim1
d'nim $
  {- -- (1)
  superimpose (iter 4 -- (3) iter 6
               -- .(# speed (scale 0.8 (0.8+(2/3)) $ slow 2.5 sine1)) -- (2)
              ) $ -- -}
  slow 16 . striate 256 $ n "[0 1]/2" # s "nimble"

d'wax silence

-- @hdrum1
d'drum $ stack [
  n "[1*2, 0*8, [~!! [~!! 0] ! ~!!]]/8" # s "drum",
  -- whenmod 3 2 (density 2) $ -- (3)
  -- withmod 11 5 0.5 1 (density 2) $ -- (2)
  n "~ 0" # s "kit"
  -- n "[[~ 0] [[2!! ~]/4 0]]/2" # s "kit" -- (1)
  ]

-- hdrum1 @ 1
-- hic1

-- hdrum1 @ 2

-- @hsnoo
d'fx3 $
  (1.5 ~>) $
  slow 4 $ chop 48 $
  sound (samples "snoo" <$> slow 7 $ run 7)
  # gain 0.8
  # cut 10

-- hnim1 @ 1

-- @hdorr1
d'fx1 $ -- mt $ -- (1)
  (2 ~>) $ chop 16 $
  s "dorr/4"
  # hresonance 0.05
  # hcutoff 200
  # gain 0.8

-- hnim1 @ 2
-- hdrum1 @ 3

--  hnim1 @ 3

-- pt 2 transition

-- @hdrum2
d'drum $ mt $ stack [
  n "[1*2, 0*8, [~!! [~!! 0] ! ~!!]]/8" # s "drum",
  whenmod 3 2 (density 2) $
  withmod 11 5 0.5 1 (density 2) $
  n "[[~ 0] [[2!! ~]/4 0]]/2" # s "kit"
  ]

d'nim $ superimpose (iter 6 .
                     (# speed (scale 0.8 (0.8+(2/3)) $ slow 2.5 sine1)) .
                     (# nudge 0)) $
  mt $ slow 16 . striate 256 $ n "[0 1]/2" # s "nimble"

-- hdorr1 @ 1 (mt)

-- pt 2: offbeat

msil [d'wax, d'fx2, d'fx3]

-- @hnim2
d'nim $
  {- -- (4)
  superimpose (iter 4 .
               (# speed (scale 0.8 (0.8+(2/3)) $ slow 2.5 sine1)) .
               (# nudge 0)) $ -- -}
  mt $
  -- every 3 (density 2) $ -- (3)
  -- every' 2 2 (within (0, 0.5) (const silence)) $ -- (2)
  -- whenmod 5 3 rev $ -- (1)
  slow 16 . striate 256 $ n "[0 1]/2" # s "nimble"

-- hnim2 @ 1
-- hnim2 @ 2

d'fx2 $ mt $ 1.75 ~> s "tubal/4"

-- hnim2 @ 3

-- @hduck
d'fx2 $ mt $
  stack [
    1.75 ~> s "tubal/4",
    (3.75 ~>) $ chop 16 $ s "duck/4"
    # gain 0.6
    # speed 0.9
    ]

-- hnim2 @ 4

-- intermission

msil [d'fx1, d'fx2]

-- solo ~hnim2f
-- solo ~hnim2f w/o mt

-- @hbass
let s = striate 16
  in d'bass $
     slow 8 $ stack [
       s $ sound "bass",
       s $ sound "sine"
       ]
     # gain 0.9

-- hnim2f @ 0 keeping superimpose

-- pt 3: funk

-- @hdrum23
d'drum $ n "0*4" # s "kit" # gain 0.9 -- (1) s "drum"

-- @hdrum3
d'drum $ swing 0.14 $ stack [
  n "[1*2, 0*8, [~!! [~!! 0] ! ~!!]]/8" # s "drum",
  whenmod 3 2 (density 2) $
  withmod 11 5 0.5 1 (density 2) $
  n "[[~ 0] [[2!! ~]/4 0]]/2" # s "kit"
  -- n "[~ 1]/2" # s "sn" # gain 0.85 -- (1)
  -- n "[~ [1 0/8 1/2 0/2]]/2" # s "sn" # gain 0.85 -- (2)
  ]

-- @hnim3
d'nim $
  {- -- (4)
  superimpose (iter 4
               .(# speed (scale 0.8 (0.8+(2/3)) $ slow 2.5 sine1)) -- (5)
              ) $ -- -}
  {- -- (2)
  every' 16 1 ((# vowel "o u")
               {- -- (3)
               .(# orbit 1) -- opt. remove to delay all the things
               .(# delay 0.5).(# delayfeedback 0.6).(# delaytime 0.25)
               -- -}
              ) $ -- -}
  -- whenmod 16 12 (# vowel "[a i]/3") $ -- (1)
  (1 ~>) $ slow 16 . striate 256 $ n "[0 1]/2" # s "nimble"

-- hnim3 @ 1
-- hnim3 @ 2

-- hdrum3 @ 1

-- hdrum3 @ 2

-- @hbass2
d'bass2 $ swing 0.14 $
  n "[~ [~ 1] [~!! 0] [~ 0 1 ~]]/4" # s "bass2"
  # speed (0.5 ~> "[2 1]")
  # gain 0.82

-- @hdorr2
d'fx1 $
  -- superimpose (slow 2) $ -- (1)
  (2 ~>) $ chop 16 $ s "dorr/4"
  # hresonance 0.05
  # hcutoff 200
  # gain 0.8

-- hduck w/o mt
-- hdorr2 @ 1

-- hic1
-- hsnoo

-- hnim3 @ 4

-- @hdrum4
d'drum $ swing 0.14 $ -- mt $ -- (3)
  stack [
    n "[1*2, 0*8, [[~ 0] ~! [~!! 0] [~! 0!] ~!!]]/8" # s "drum",
    -- every' 16 16 (const $ sound "kit:3") $ -- (2)
    -- n "[~ 0]" # s "kit", -- (1)
    n "[[~ 0] [[2!! ~]/4 0]]/2" # s "kit", -- (1) remove
    n "[~ [1 0/8 1/2 0/2]]/2" # s "sn"
    # gain 0.85
    ]

-- hnim3 @ 5
-- hdrum4 @ 1

-- outro

msil [d'nim, d'wax, d'fx2, d'fx3]

-- @hhi
d'hi $
  swing 0.14 $
  every 3 rev $
  whenmod 12 8 (0.5 <~) $
  (0.5 ~>) $
  slow 8 $
  gap 64 $
  n "[0 1]/2" # s "nimble"
  # speed ((-4+).(*(-1)) <$> density 1.1 sine1)

-- @hnim4
d'nim $ -- mt $ -- (2)
  (0.25 ~>) $
  whenmod 4 2 (const silence) $
  slow 16 . striate 256 $ n "[0 1]/2" # s "nimble"
  -- # vowel "o" -- (1)

-- @hduon
d'fx3 $ 3 ~> n "[0 1]/8" # s "duon"
  # gain 0.9

-- hnim4 @ 1
-- hdrum4 @ 2

msil [d'bass, d'bass2, d'hi, d'fx1, d'fx3]

-- hic1
-- hic2
-- hdrum4 @ 3 w/ mt
-- hnim4 @ 2 w/ mt

hush
