Created
February 6, 2013 14:02
-
-
Save gigasquid/4722675 to your computer and use it in GitHub Desktop.
Mary had a little lamb in overtone
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 overtone-tutorial.mary) | |
(use 'overtone.core) | |
(boot-external-server) | |
(definst saw-wave [freq 440 attack 0.01 sustain 0.4 release 0.1 vol 0.4] | |
(* (env-gen (lin-env attack sustain release) 1 1 0 1 FREE) | |
(saw freq) | |
vol)) | |
;; Define a function for convenience | |
(defn note->hz [music-note] | |
(midi->hz (note music-note))) | |
;; Let's make it even easier | |
(defn saw2 [music-note] | |
(saw-wave (midi->hz (note music-note)))) | |
(defonce metro (metronome 120)) | |
(metro) | |
(def mary-notes [:E3 :D3 :C3 :D3 :E3 :E3 :E3 nil :D3 :D3 :D3 | |
nil :E3 :G3 :G3 nil :E3 :D3 :C3 :D3 :E3 :E3 | |
:E3 :E3 :D3 :D3 :E3 :D3 :C3]) | |
(defn song-player [m beat-num notes] | |
(map-indexed (fn [idx note] | |
(when note | |
(at (m (+ idx beat-num)) (saw2 note)))) | |
notes)) | |
(song-player metro (metro) mary-notes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We used the external server because I thought it was the only option if you installed the SuperCollider in the Mac Applications directory.
Cool to know about temporal recursion! I will have to check it out. Overtone is very fun. The intersection of technology and art is a very interesting place to explore.