do
let detune = pF "detune"
let filterFreq = pF "filterFreq"
let drive = pF "drive"
let fmRatio = pF "fmRatio"
let fmIndex = pF "fmIndex"
let sweepRate = pF "sweepRate"
let sweepTime = pF "sweepTime"
let lowFreq = pF "lowFreq"
let pitchMod = pF "pitchMod"
d1 $ n "c2 [f2 g2] a1 bf1" 
   # s "reeseBass"
   -- # detune (range 0.1 0.8 $ slow 8 $ sine)
   -- # filterFreq (range 300 1200 $ slow 4 $ tri)
   -- # drive (range 1 4 $ slow 16 $ sine)
   # gain 0.0
d2 
  $ "metallicScreech" 
-- growlMachine.scd  laserZap.scd  .scd  pluckStab.scd  reeseBass.scd  sub808.scd  talkingBass.scd
  -- # n (run 8 + 60)
  -- # fmRatio "2.1 3.2 4.5 1.8"
  -- # fmIndex (range 4 12 $ fast 2 $ sine)
  -- # sweepRate (choose [4, 6, 8, 12])
d3 
 -- $ sometimes (# pitchMod 36)
 $ note (fast 4 $ "<a c a b>") #  "laserZap" 
 -- # freq (scale "minor" $ run 8 * 100 + 600)
 -- # sweepTime "0.05 0.08 0.12 0.06"
 -- # lowFreq (range 60 200 $ slow 8 $ sine)
d4 $ n "c2 ef2 g2 bf2" 
   # s "talkingBass"
   -- # talkRate (choose [1, 2, 4, 0.5])
   -- # brightness (range 0.5 2 $ slow 8 $ sine)
   # drive (range 2 6 $ slow 4 $ tri)

 once $ "talkingBass" # note "c4" # orbit 5


 setcps (92/60/4) -- 92 BPM typical for G-funk
 
once $ "gfunk"
 
do
let cc n = cF n 0.5  -- Center default values
let lagLev = pF "lagLev"
d1 
  $ n ("c3 ef3 g3 bf3")
    # "gfunk"
    # lagLev 0.06  -- portamento control
    # cutoff (slow 4 $ range 800 2400 sine)
    # resonance 0.3
    # amp 0.4
d1 $ n "c3 ef3 g3 bf3 c4 bf3 g3 ef3"
   # s "gfunk" 
   # cutoff (slow 6 $ range 500 3000 (sine + 0.3 * tri))
   # resonance (slow 12 $ range 0.2 0.6 cosine)
   # lagLev 0.06
   -- Main melody
d1
  $ swing 3
  $ n "c3 ef3 g3 bf3 c4 bf3 g3 ef3"
   # s "gfunk"
   # cutoff (slow 4 $ range 1000 2500 sine)
   # lagLev 0.08
   # pan 0.1
   # amp 0.4
-- Harmony layer (fifth above)
d2
  $ swing 6
  $ n "g3 bf3 d4 f4 g4 f4 d4 bf3"
  # s "gfunk" 
  # cutoff (slow 4 $ range 800 2000 sine + 0.2)
  # lagLev 0.08
  # pan 0.8
  # amp 0.25
  # detune 0.02  -- slight detune for thickness
  -- Map Launch Control knobs to key parameters
d1 $ n "c3 ef3 g3 bf3"
   # s "gfunkLead"
   # cutoff (cc 1 * 3000 + 500)      -- Knob 1: Filter cutoff
   # resonance (cc 2 * 0.6 + 0.1)    -- Knob 2: Resonance
   # lagLev (cc 3 * 0.15 + 0.01)     -- Knob 3: Portamento time
   # detune (cc 4 * 0.1 + 0.01)      -- Knob 4: Detuning amount
