Skip to content

Instantly share code, notes, and snippets.

@rogerallen
Created October 27, 2014 20:01
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 rogerallen/8ffbc430798b50164998 to your computer and use it in GitHub Desktop.
Save rogerallen/8ffbc430798b50164998 to your computer and use it in GitHub Desktop.
trove additive synth example
(use 'overtone.live)
(defsynth add-synth
[n 60 c0 0.1 c1 0.1 c2 0.1 c3 0.1 c4 0.1 c5 0.5 c6 0.1 c7 0.1]
(let [f (midicps n)]
(out 0 (+ (* c0 (sin-osc (* 1 f)))
(* c1 (sin-osc (* 2 f)))
(* c2 (sin-osc (* 3 f)))
(* c3 (sin-osc (* 4 f)))
(* c4 (sin-osc (* 5 f)))
(* c5 (sin-osc (* 6 f)))
(* c6 (sin-osc (* 7 f)))
(* c7 (sin-osc (* 8 f)))))))
(def s (add-synth))
(defn upd []
(ctl s
:n @K1
:c0 (/ (@S 0) 1023)
:c1 (/ (@S 1) 1023)
:c2 (/ (@S 2) 1023)
:c3 (/ (@S 3) 1023)
:c4 (/ (@S 4) 1023)
:c5 (/ (@S 5) 1023)
:c6 (/ (@S 6) 1023)
:c7 (/ (@S 7) 1023)))
(add-watch K1 :k1-watch (fn [k r os ns] (upd)))
(add-watch S :s-watch (fn [k r os ns] (upd)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment