Skip to content

Instantly share code, notes, and snippets.

@harold
Created October 12, 2012 16:58
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/3880242 to your computer and use it in GitHub Desktop.
Save harold/3880242 to your computer and use it in GitHub Desktop.
Steve Reich - Clapping Music (Overtone remix)
(use 'overtone.live)
(def clap (sample (freesound-path 48310)))
(def clap2 (sample (freesound-path 132676)))
;(clap)
;(clap2)
(def pattern-1 [1 1 1 0 1 1 0 1 0 1 1 0])
(def pattern-2 [1 1 1 0 1 1 0 1 0 1 1 0])
(defn my-cycle []
(def pattern-2 (let [e (last pattern-2)
p (drop-last pattern-2)]
(vec (conj p e)))))
(def m (metronome 32))
(defn play-beat [beat]
(dorun (map (fn [i]
(let [v (if (= 0 (mod i 3)) 1 0.5)]
(when (= (pattern-1 i) 1)
(at (m (+ (/ i 12.0) beat)) (clap 1 0 0 (* v 0.33))))
(when (= (pattern-2 i) 1)
(at (m (+ (/ i 12.0) beat)) (clap2 1 0 0 v)))))
(range 12))))
(defn player [beat]
(when (= (mod beat 4) 0) (my-cycle))
(play-beat beat)
(apply-at (m (inc beat)) #'player (inc beat) []))
(player (m))
;(defn player [beat] "stop")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment