Skip to content

Instantly share code, notes, and snippets.

@velveteer
Created March 7, 2016 21:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velveteer/95444bf37fd787709c1c to your computer and use it in GitHub Desktop.
Save velveteer/95444bf37fd787709c1c to your computer and use it in GitHub Desktop.
klangmeister - infinity series
(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