Created
October 27, 2014 20:01
-
-
Save rogerallen/8ffbc430798b50164998 to your computer and use it in GitHub Desktop.
trove additive synth example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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