{-
generated (unmodified)
-}

-- megalet for battery123.tidal
let msil = mapM_ ($ silence)
    cf = slow 2
    every' n o f = when ((== (o-1)) . (`mod` n)) f
    halfosc = (/2).(+0.5)
    halfosc1 = (+1).(/2)
    thirdosc1 = (+1).(/3)
    d'drum = d1
    d'perc = d2
    d'bass = d3
    d'hand = d4
    d'warb = d5 -- warbler
    d'bass2 = d6 -- more bass right at the end
    d'arpy = d7
    d'tr = d8 -- trump
    d'tac = d9 -- tacscan
    b1'bass = s "bass3 [~ bass3] ! ~"
              # begin "0.2"
    b1'hand = slow 8 $ rev . striate 256 $ s "hand*8"
              # speed "0.7"
    b1'perc = slow 2 $ s "uxay [~ uxay] [psr uxay] ~"
    b1'tac = s "[~ tacscan] ! ~ ~"
             # gain "0.8"
             # vowel (slow 3 "e u")
    b1'warbler = slow 4 $ striate 32 $ s "warbler"
                 # n (slow 7 $ run 7)
                 # gain "0.8"
    b2'uxp = (# gain "0.8") .
             (# speed "[0.7 1 1.2]/2")
    b2'psr = s "psr*4 psr*2"
             # gain "0.6"
    b2'psrf = s "[[psr*4 psr*2] ! ! psr*8]/4"
              # gain "0.6"
    b2'trump p = whenmod 5 4 rev $ s p
                 # n (slow 3.2 $ run 4)
                 # gain "0.8"
                 # speed (halfosc1 <$> slow 4 sinewave1)
                 # vowel (slow 3.2 "a e o")
                 # shape "0.6"
    b2'bass = slow 8 $ s "[jvbass ~] [jvbass [~ ~ ~ ~ jvbass]] [~ [~ ~ ~ ~ jvbass]] [~ jvbass !]"
              # n (slow 2.8 "0 1 2")
              # vowel "i"
              # speed "0.8"
    b2'arpy = s "arpy*8"
              # n "2 1 3 1"
              # gain "0.7"
    b3'perc = s "[tok*2 [rm tok]] [psr:1 tok*2]"
    b3'bass = s "bass*4"
              # n "0 1"
              # begin "0.4"
              # speed "1.2"
              # shape "0.2"
    b3'bassf = s "{bass*4, wobble*3}"
               # n "0 1"
               # begin "0.4"
               # speed "1.2"
               # shape "0.2"
    b3'drum = slow 2 $ s "peri [~ ~ ~ peri] [~ peri peri ~] ~"
    b3'drumf = slow 2 $ s "peri*2 [~ ~ ~ peri] [~ peri peri ~] ~"

-- megalet for juliese.tidal
let every' n o f = when ((== (o-1)) . (`mod` n)) f
    d'drum = d1
    d'perc = d2
    d'bass = d3
    d'eg = d4
    d'gt = d5
    d'udu = d6
    d'pc = d7
    d'pcl = d8
    d'wbass = d9
    bassbass = s "[[vb vb:1] ~]/2"
               # end (slow 1.4 "0.2 0.4")
               # vowel "e o"
    bassbass' = bassbass # speed (slow 2.5 "1 -1")
    morek = every' 8 8 (overlay $ (0.32 ~>) $ s "k*2")
    drum1'f = overlay ((0.5 ~>) $ s "sn/2") $ every' 12 2 (density 3) $ morek $ s "k"
    hhb m = smash 16 [0.25, 0.5] $
            (if m then (every 3 (append $ s "hh:1 hh")) else id) $
            s "hh hh:2"
            # gain "0.6"
    ududu = slow 4 . chop 128 $
            s (samples "udu" (slow 4 $ irand 4))
            # gain "0.8"
            # cut "6"
    eg = gap 128 $ s "eg*2"
         # cut "4"
    gt = every 2 (within (0, 0.5) (0.07 <~)) $ (0.07 ~>) $
         chop 128 $
         s "[gt [~ gt] ! ~]/2"
         # cut "5"
    pcbeep = slow 16 $ gap 48 $ s "pc:1"
             # gain "0.7"
             # cut "7"
             # speed "[1 0.7]"
    ju'drum2 = stack [
               every' 8 7 (overlay $ (0.32 ~>) $ s "k") $ s "[k ~ k*2 ~]/4",
               every' 16 16 (overlay $ (0.82 ~>) $ s "sn") $ (1 ~>) $ s "sn/2"
               ]

-- megalet for pigs-nose.tidal
let msil = mapM_ ($ silence)
    cf = slow 2
    d'drum = d1
    d'print = d2
    d'wobb = d2
    d'qs = d3
    d'jbass = d4
    d'mons = d5
    d'bass = d6
    d'casio = d7
    d'ql = d8
    d'arm = d8
    d'baa = d9
    pn'hointro = s "[~ [~ ho] ~ ho ~ ~ ho ~]/2"
    pn'sn = s "[~ [~ sn:1] ~ sn:1 ~ ~ sn:1 ~]/2"
    pn'bd = s "[bd [~ ~ ~ bd] bd*2 ~]/2"
    pn'hh = s "[hh*8 [hh*4 ho]]/2"
    pn'qs sl = slow sl . striate 4 $ s "qspace"
    pn'bass4 = s "bass*2 bass*2 bass*3 bass*3"
    pn'bass5 = s "bass*2 bass*2 bass*3 bass*3 ~"

-- megalet for piston.tidal
let d'drum = d1 -- k, sn
    d'perc = d2 -- wt, wtsn, hh
    d'gnome = d3 -- gnome, cymb
    d'bass = d4 -- dubb, k
    d'fly = d5 -- fly
    d'bz = d6 -- bz, bzl, ff
    d'shard = d7 -- ice, plode
    d'ant = d9 -- ant
    d'misc = d8 -- overflow channel for a few cases
    d'cymb = d10 -- cymb
    msil = mapM_ ($ silence)
    k = s "k"
    k1 = s "k:1"
    sn = s "[~ sn]/2"
    bass'params = (# gain "0.7").
                  (# hcutoff "0.022").
                  (# hresonance "0.001")
    bass' c = rev . chop c $ bass'params $ s "[dubb dubb:1]/2"
    fly'1 = slow 16 $ jux (0.5 <~) $ rev . striate 256 $ s "fly"
            # hcutoff "0.09"
            # hresonance "0.06"
    fly'1f = whenmod 5 2 (# vowel "i o") $ whenmod 3 1 (slow 2) $ brak $ fly'1
    snare43'1 = density (4%3) $ s "[wtsn ~ wt]"
    shnare'1 = s "[~ ~ sn [~ sn*3]/2]/2"
    kick38'1 = s "[k(3,8)]/2"
    gnome'1 = within (0, 0.5) rev $ chop 8 $ s "[gnome(3,8)]/2"
              # gain "0.8"
              # speed ((+0.8).(/5) <$> slow 1.1 sinewave1)
    bass'1'm = every 2 $ within (0.25, 0.75) (0.5 ~>)
    wt'2 = s "wt*2"
           # vowel "[u e u a]/2"
           # end "0.15"
    bass'2 = slow 8 $ ((1%8) <~) $ chop 32 $
             bass'params $ s "[dubb dubb:1]/2"
             # speed "1.2"
             # shape ((/2) <$> density 4 sinewave1)
             # cut "1"
    ant'2 = slow 2 $ smash 16 [1,2] $ s "ant:1"
            # cutoff "0.08"
            # resonance "0.01"
    shard'2 = chop 16 $ s "[ice [~ ice] ~ ~]/4"
              # gain "0.7"
    shard'2f = every 2 (density 1.5) $ whenmod 5 3 (density 2) $ rev $ shard'2
               # shape ((+0.25).(/2) <$> density 8 saw1)
    fly'2 = chop 64 $ s "[fly ~ [fly ~ ~ fly] ~]/4"
            # cut "1"
            # begin "0.3"
            # end "0.35"
            # shape ((+0.25).(/2) <$> density 8 sinewave1)
            # speed ((+0.92) <$> density (5%4) saw1)
    cymb'2 g = within (0.5,1) (# vowel "e") $
               (0.5 ~>) $ chop 2 $ s "[cymb*4 cymb*3]/8"
               # shape ((/3) <$> density 3.6 saw1)
               # gain g
    bass'3 v c b = (4 <~) $ every 2 (0.5 <~) $
                   slow 4 .
                   (if b then brak else id) $
                   rev . chop 16 $
                   bass'params $ s "[dubb dubb:1]/2"
                   # cut c
                   # vowel v
    bz'3 = s "[ff(3,8) [~ [ff bz]]]/4"
           # end "0.3"
           # shape "0 0.25"
           # gain "0.7"
    drum'3 = overlay (s "[~ sn]/2") $ s "[k*2 [~ k*2] k ~ k*2 ~ k*2 ~]/8"
    bass2'3 = slow 8 $ chop 16 $ bass'params $ s "[dubb dubb:1]/2"
              # cut "1"
              # speed "0.2"
              # vowel "e"
    perc'3 = s "[[k:1 [~ k:1] k:1 [~ k:1]] sn]/8"
    perc'3'delay = (# delay "0.3").
                   (# delayfeedback "0.5").
                   (# delaytime "0.766") --(138/60)/3
    shard'3f = iter 4 . density 2 $ (0.5 <~) $ ((1%16) <~) $ shard'2
               # vowel "e o"
               # gain "0.6"
    drum5'4 = s "[[~ [wt wtsn]] ~ wt ~]/5"
    plox'4 so = within (0.5, 0.75) (iter 4) $
                whenmod 3 2 (slow 2) $
                slow 8 $ every 2 rev $ striate 128 $ s so
                # cutoff "0.02"
                # resonance "0.001"
                # speed "0.7"
                # gain "0.7"
    bass'4 = whenmod 5 3 (density (3%2) . brak) $
             bass'params $
             rev $ (0.5 ~>) $ slow 2 . chop 8 $ s "[dubb dubb:1]/2"
             # speed "0.5"
             # cut "1"
             # end "0.5"
    bz'4 = (0.5 <~) $ slow 16 . chop 32 $ s "bzl"
           # n (density 1.5 "0 1")
           # speed ((+1) <$> density 1.7 sinewave1)
           # gain "0.9"
    bzox'4 so = whenmod 7 4 (within (0.5, 1) (density 2)) $
                (0.5 <~) $
                slow 16 . chop 32 $ s so
                # n (density 1.5 "0 1")
                # speed ((+1.6) <$> density 2.2 sinewave1)
                # pan ((+0.25).(/2) <$> density 4.1 sinewave1)
    perc'5 = s "~ wt wt wtsn/8"
             # shape ((/2) <$> density 1.2 saw1)
    drum'5 = s "{[~ ~ ~ k:1], [~ sn]/2}"
    drum'5f = overlay k $ drum'5
    bass'5 = chop 16 $ bass'params $ s "[~ dubb]"
             # n (slow 4 "0 1")
             # cut "1"
    bass'5f = every 2 (density 2) $ whenmod 3 2 (density 1.6) $ bass'5
              # speed ((+0.75).(/2) <$> slow 1.3 sinewave1)
    fly'5 b = whenmod 5 3 rev $
              (if b then brak else id) $
              slow 16 $ jux ((1.5 ~>).rev) $
              chop 64 $ bass'params $ s "fly:1"
              # speed "0.7"
              # shape ((/2) <$> density 2.1 saw1)
    bass2'5 = chop 12 $ s "[~ ~ [~ k:1] !]/4"
              # speed "0.9"
    bass2'5b = whenmod 4 3 (density 1.8) $ bass2'5
               # shape ((/3) <$> density 3 sinewave1)
               # delay "0.3"
               # delayfeedback "0.2"
               # delaytime "0.2875" --(138/60)/8
    gnome'5 sm f = smash 64 sm $
                   (# speed "1.2").
                   (# shape ((/2) <$> ((0.25 ~>) . density 3) sinewave1)).
                   (# gain "0.6") $
                   s "~ gnome"
                   # pan (f $ slow 4 sinewave1)
    sn'6 = s "[~ sn ~ sn*2]/8"
    bass'6 = (# gain ((*0.7) <$> saw1)) $ bass'5f
    bass2'6 = within (0, 0.5) (slow (7%6)) $
              every 2 (0.5 <~) $ slow 8 $
              bass' 32
    plode'6 = superimpose (slow (5%3) . iter 2) $
              (# speed ((+0.7) <$> slow 1.1 sinewave1)) $
              chop 32 $ s "[plode(5,8)]/8"
              # cut "1"
    cymb'6 = s "[cymb*8 ~]/8"
             # gain ((+0.6).(/5) <$> density 3.6 saw1)
             # cut "1"
    cymb'6f = density (5%4) $ whenmod 9 4 (density 1.5) $ cymb'6
    drum'6 = s "{k, [~ ~ ~ k:1] [~ k:1]}"
    wtsn'6 = (3 ~>) $ within (0.25, 0.75) rev $
             slowspread ($) [chop 16, chop 32] $ s "[wtsn(3,8)]/2"
             # speed ((+0.8).(/2) <$> density 1.8 sinewave1)
    gnome'6 d = iter 4 $ density (9%8) $
                within (0, 0.5) rev $
                smash 8 [1,2] $ s "[gnome(3,8)]/2"
                # gain "0.8"
                # speed ((+0.76).(/d) <$> slow 1.1 sinewave1)
    shard'7 dt = slow 5 . chop 15 $ s "ice"
                 # gain "0.7"
                 # resonance "0.4"
                 # cutoff "0.2"
                 # delay "0.7"
                 # delayfeedback "0.3"
                 # delaytime dt
    bass'7 f = slow 8 $ f $
               slowspread ($) [rev.chop 12, rev.chop 24] $
               bass'params $ s "[dubb dubb:1]/2"
    bass'7'm f = (f . (/2) <$> density (5%4) sinewave1)
    fly'7 = slow (4%3) .
            slowspread ($) [slow 1, density (5%4)] $
            slow 12 $
            slowspread striate [24,36] $ s "fly:1"
            # gain "0.7"
    bz'8 = s "[[ff bz]*2 [~ bz*2]]/2"
           # n (slow 2 $ run 5)
           # begin "0.7"
           # end "0.85"
           # hcutoff "0.04"
           # hresonance "0.1"
           # shape ((/5) <$> slow (5%3) sinewave1)

-- megalet for something-to-say.tidal
let msil = mapM_ ($ silence)
    cf = slow 2
    iter' n p = slowcat $ map (\i -> ((fromIntegral i)%(fromIntegral n)) ~> p) [0 .. n]
    ss'stab = s "stab"
              # n (slow 6 "1 2 3 4 [5 6]/3")
              # vowel "i"
    ss'kurt = s "kurt"
              # speed "0.6"
              # shape "0.3"
              # vowel "u"
    ss'perc = s "{[bd ~ ~ bd] msg, hh*2}"
    ss'perc' = s "{[rm ~ ~ rm] msg, hh*2}"
    ss'verse = s "sitw"
               # n (slow 8 $ run 8)
    ss'chorus = s "sitwc"
                # n (slow 4 $ run 4)
    d'drum = d1
    d'bass = d2
    d'gt = d3 -- guitar [stab]
    d'kurt = d4
    d'moog = d5
    d'voc = d9 -- vocal

{-
specific for leeds
-}

-- resolved channel mapping (reducing conflicts as much as possible)
let d'drum = d1
    d'perc = d2
    d'eg = d3
    d'gnome = d3
    d'hand = d3
    d'qs = d3
    d'tac = d3
    d'tr = d3
    d'bass = d4
    d'fly = d5
    d'gt = d5
    d'mons = d5
    d'warb = d5
    d'bz = d6
    d'kurt = d6
    d'udu = d6
    d'arpy = d7
    d'pc = d7
    d'shard = d7
    d'arm = d8
    d'casio = d8
    d'misc = d8
    d'pcl = d8
    d'ql = d8
    d'ant = d9
    d'baa = d9
    d'print = d9
    d'voc = d9
    d'wbass = d9
    d'wobb = d9
    d'bass2 = d10
    d'cymb = d10
    d'jbass = d10
    d'moog = d10

-- custom lets for this performance to fix sample refs. see samples.csv

let pn'hh = s "[phh*8 [phh*4 ho]]/2"

let hhb m = smash 16 [0.25, 0.5] $
            (if m then (every 3 (append $ s "rhh:1 rhh")) else id) $
            s "rhh rhh:2"
            # gain "0.6"

let ss'perc = s "{[sbd ~ ~ sbd] msg, rhh*2}"
    ss'perc' = s "{[rm ~ ~ rm] msg, rhh*2}"
