Skip to content

Instantly share code, notes, and snippets.

@harold
Created December 16, 2011 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harold/1488464 to your computer and use it in GitHub Desktop.
Save harold/1488464 to your computer and use it in GitHub Desktop.
First cut at a hoover
(definst hoover [freq 220 amp 1 lgu 0.1 lgd 1 gate-sig 1]
(let [freq (midicps (lag-ud (cpsmidi freq) lgu lgd))
freq (* freq (lin-exp (sin-osc:kr (repeat 3 (ranged-rand 2.9 3.1))
(repeat 3 (rand (* Math/PI 2))))
-1 1 0.995 1.005))
pwm (lin-lin (sin-osc:kr (repeat 3 (ranged-rand 2.0 4.0)))
-1 1 0.125 0.875)
main (* (lin-lin (saw (* freq [0.25 0.5 1.0]) 1)
-1 1 0 1)
(- 1 (lf-pulse:ar (* freq [0.5 1.0 2.0]) 0 pwm)))
sub (lf-par (* freq 0.25) 0 0.1)
main (apply + (+ main sub))
main (b-peak-eq main 6000 1 3)
main (b-peak-eq main 3500 1 6)
main (+ main (* (comb-c:ar [main main]
(/ 1.0 200.0)
(lin-lin (sin-osc:kr 3 [(/ Math/PI 2) (* Math/PI 1.5)])
-1 1 (/ 1.0 300.0) (/ 1.0 200.0))
0.0)
0.5))
env (env-gen (asr 0.05 1 0.3) gate-sig)]
(* main env amp)))
(defn play-hoover []
(let [t (now)
s 0.24]
(at t (hoover (midi->hz 20) 1 0.15 0.1 1))
(at (+ t (* 250 s)) (ctl hoover :freq (midi->hz 67)))
(at (+ t (* (+ 250 500) s))
(ctl hoover :lgd 1.5)
(ctl hoover :freq (midi->hz 62)))
(at (+ t (* (+ 250 500 7000) s))
(ctl hoover :lgu 0.15)
(ctl hoover :lgd 0.25)
(ctl hoover :freq (midi->hz 20))
(ctl hoover :gate-sig 0))))
(play-hoover)
(stop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment