Created
March 7, 2016 21:42
-
-
Save velveteer/95444bf37fd787709c1c to your computer and use it in GitHub Desktop.
klangmeister - infinity series
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
(defn iform | |
"Derive the infinity series interval of a particular index in the seq" | |
[n] | |
(let [bin (map #(js/parseInt %) (.split (.toString n 2) #""))] | |
(reduce #(if (zero? %2) (unchecked-negate-int %1) (inc %1)) 0 bin))) | |
(def iseries | |
"Generate the infinity series lazily - 0, 1, -1, 2, 1, 0, -2, 3..." | |
(map #(iform %) (iterate inc 0))) | |
(defn synth [note] | |
(connect-> | |
(add (square (* 1.01 (:pitch note))) (sawtooth (:pitch note))) | |
(low-pass 600) | |
(adsr 0.001 0.4 0.5 0.1) | |
(gain 0.05))) | |
(def melody | |
(->> (phrase (cycle [1/2 1/2 1/2 1/2]) (take 100 iseries)) | |
(all :instrument synth))) | |
(->> melody | |
(tempo (bpm 90)) | |
(where :pitch G)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment