Last active
August 29, 2015 14:23
-
-
Save kn1kn1/d34e2782118eb98c0aad to your computer and use it in GitHub Desktop.
Steve Reich's Piano Phase - Overtone (beep)
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
(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