Skip to content

Instantly share code, notes, and snippets.

@kn1kn1
Last active August 29, 2015 14:23
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 kn1kn1/d34e2782118eb98c0aad to your computer and use it in GitHub Desktop.
Save kn1kn1/d34e2782118eb98c0aad to your computer and use it in GitHub Desktop.
Steve Reich's Piano Phase - Overtone (beep)
(ns reich.core
(:use overtone.live))
;; Steve Reich's Piano Phase
(def piece [:E4 :F#4 :B4 :C#5 :D5 :F#4 :E4 :C#5 :B4 :F#4 :D5 :C#5])
(definst beep [freq 440 amp 0.1]
(let [env (env-gen (perc 0.1 0.2) :action FREE)]
(* amp (* env (sin-osc freq)))))
(defn player
[t speed notes]
(let [n (first notes)
notes (next notes)
t-next (+ t speed)]
(when n
(at t
(beep (midi->hz (note n))))
(apply-by t-next #'player [t-next speed notes]))))
(def num-notes 1000)
(do
(player (now) 338 (take num-notes (cycle piece)))
(player (now) 335 (take num-notes (cycle piece))))
;;(stop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment