Created
September 22, 2014 16:37
-
-
Save jordanlewis/c71cf6a64f8897d31f7d to your computer and use it in GitHub Desktop.
Hey Downe a Downe
This file contains hidden or 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 overtoneplay.core | |
| (:use [overtone.live :only [now at ctl definst saw env-gen perc FREE midi->hz]] | |
| [leipzig.scale :as scale] | |
| [leipzig.melody] | |
| [leipzig.canon :as canon] | |
| [leipzig.live :as live] | |
| [overtone.inst.sampled-piano])) | |
| (def melody | |
| (->> ; hey downe a downe be hold and see | |
| (phrase [6/8 1/8 1/8 6/8 2/8 4/8 4/8 8/8] | |
| [ 4 3 2 1 2 3 1 0]) | |
| (then | |
| ; what song is this or how may it be 3 parts | |
| (phrase [4/8 2/8 2/8 8/8 3/8 1/8 2/8 2/8 4/8 2/8 6/8 ] | |
| [ 0 0 0 4 3 2 3 4 5 5 7 ])) | |
| (then | |
| ; in one sing all af ter me with a | |
| (phrase [4/8 6/8 2/8 6/8 1/8 1/8 6/8 1/8 1/8] | |
| [ 7 4 4 6 5 4 3 3 4])) | |
| (then | |
| ; hey down down and a down and down | |
| (phrase [2/8 2/8 2/8 1/8 1/8 2/8 2/8 4/8] | |
| [ 5 5 5 4 3 2 0 0])) | |
| (then | |
| ; troll the ber ry drinkand be mer ry | |
| (phrase [6/8 1/8 1/8 6/8 2/8 4/8 2/8 2/8 4/8 4/8] | |
| [ 4 3 2 1 2 3 2 1 0 0])) | |
| (where :part (is :default)))) | |
| (definst beep [freq 440 dur 1.0] | |
| (-> freq | |
| saw | |
| (* (env-gen (perc 0.05 dur) :action FREE)))) | |
| (defmethod play-note :default [{midi :pitch, start :time, duration :duration}] | |
| (let [id (sampled-piano midi)] | |
| (at (+ start duration) (ctl id :gate 0)))) | |
| (defmethod live/play-note :default [{midi :pitch seconds :duration}] | |
| (when midi (-> midi midi->hz (beep seconds)))) | |
| (stop) | |
| (def melodyscaled | |
| (->> melody | |
| (where :time (bpm 60)) | |
| (where :duration (bpm 60)) | |
| (where :pitch (comp scale/E scale/mixolydian)))) | |
| (def notes | |
| (with melodyscaled | |
| (canon/canon (comp (canon/simple 1) (canon/interval -5)) melodyscaled) | |
| (canon/canon (comp (canon/simple 2) (canon/interval -10)) melodyscaled))) | |
| (live/play notes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment