once $ "gfunk_lead"

do
setcps (120/60/4)
-- resetCycles

let width = pF "width"
let gMask = (midiOn "^41" (mask "t!3 <t!3 [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 dMask = (whenmod 8 7 (mask "t t <t [f t]> f"))
let gM1 = gMask . gMute
let gM2 = gMask . gMute2
let gM3 = gMask . gMute3
d1 $ gF1 $ gM2 
  $ "[jazz,kick:5]*4"
d2 $ gF1 $ gM1 $ dMask $ "~ cp ~ cp*<1!3 2>" # "h2ogmcp" # gain 1.3
d3 $ gF1 $ gM1 $ dMask 
  $ midiOn "^44" ((# "vec1_snare") -- Mechant drum-snare!!
  . (struct "~ t ~ t ~ t*<1 2 1 1> ~ t*<1!3 2>")
  )
  $ midiOff "^44"(<| "~ h ~ h ~ h*2 ~ h*<1!15 2>" )
  $ "h2ogmhh:19" 
  # hpf (slow 32 $ range 200 8000 sine)
d4 $ gF2 $ gM3 
  $ midiOn "^57" (ply 2)
  $ midiOn "^89" (slice 8 "<6>*<2 2 2 4 2 2 4 8 2 8 8 16 8 16 16 16>")
  $ chop (8 * 8) -- 8 chops times 8 loops 
  $ loopAt 8 
  $ "gfunk_bass:1"
  # cut 4
  # room 0.8 # sz 0.5 # dry 1.2
  # crushbus 41 (range 16 3.5 "^53")
  # octersubbus 42 (range 0 1.5 "^33")
  # gain 1.3
d9 $ gF3 $ gM3 
  $ midiOn "^18" (superimpose (
    (# n "2") . (# cut 91) . (# room 0) . (|* gain 0.9))
  )
  $ note "<b b b g>@7 <cs6!3 fs6>" 
  # "moog" # cut 9
  # crushbus 91 (range 16 1.5 "^19")
  # pan 0.8 
d5 $ gF3 $ gM3 
  $ midiOn "^58" (superimpose (("s" ~>) . (|+ note 12)))
  $ note ("b4!4 . <[b4 b4 <b4 a4 g4 g4> <b4!7 fs4>] [b4 b4 d5 cs5]>")
  # "acidOto3092" 
  # width (range 0.05 0.5 "^54")
  # crushbus 51 (range 16 3.5 "^34")
  # room 0.3
d7 $ gF1 $ gM1 $ dMask -- Tracey Trancey's loop art
  $ midiOff "^59" (mask "t(4,8,1)" . chop 16) -- TECHNO MASK
  $ midiOn "^55" (# n 2) -- UPDOWN
  $ chop 8 
  $ loopAt 4 
  $ "trance_loops:0"
  # cut 7
  # gain 1.3
d8 $ gF1 $ gM1 $ dMask -- BYOB: Bring your own Breaks
  $ midiOn "^92" ( -- Bouton Nassim <3
    slice 16 "[0 .. 7]"
    . loopAt 0.5 . (# "breaks165")
    -- . (# octer 0.4) . ( octersubsub 4)
    . (# lpf 2500)
    . (# room 0)
  )
  $ midiOff "^60" (mask "t([4!3 8],8,1)" . chop 16) -- TECHNO MASK
  $ midiOn "^36" (loopAt 2 . (# n 23))
  $ midiOn "^56" (loopAt 2 . (# n 19))
  $ midiOff "^56" (slice 4 "0 <~ 1> 2*<1 2 4 <4 [8 <8 4>]>> 3*<1 2>")
  $ chop 4 
  $ loopAt 1 $ "jungle_breaks:78"
  # gain 1.4
d10 $ gF3 $ gF3
  $ iter "1 4"
  $ note ((scale "mixolydian" "0 1 2 3 3 4 5 6") + "<a4!4 a5!4>") 
  # s "giorgio_syn:5" 
  # cut 10
  # gain 1.4
  # room 0.4 # sz 0.3 # dry 0.8
-- TODO: FIND FRIENDS 10-12
d11 $ gF3 $ gM3
  $ struct "t(3,8) t(<3 5>,8)"
  $ arp (slow 4 "<up down updown converge>" )
  $ note ((scale "mixolydian" "[0,2,4] [1,3,5] [2,4,6]") + "a")
  # s "giorgio_syn:14" -- 13 
  # cut 11
  # gain 1.1
  # room 0.6 # sz 0.4

  -- Pinky up arpeggio with faster movement
  d11 $ every 4 (fast 2) 
    $ arp "pinkyup thumbupdown" 
    $ note ((scale "mixolydian" "[0,2,4,6] [3,5,0]") + "a")
    # s "giorgio_syn:8" 
    # cut 11
    # lpf 1200 # gain 1.0

  -- Diverging arpeggio pattern
  d11 $ arp "diverge disconverge" 
    $ note ((scale "mixolydian" "[0,2,4] [5,3,1] [6,4,2]") + "a")
    # s "giorgio_syn:17" 
    # cut 11 # octave 5
