Created
April 27, 2012 02:12
-
-
Save zonble/2505098 to your computer and use it in GitHub Desktop.
Piano Flow
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 flow.core | |
(:gen-class) | |
(:use [overtone.core][overtone.inst.piano]) | |
) | |
(definst kick [freq 120 dur 0.3 width 0.5] | |
(let [freq-env (* freq (env-gen (perc 0 (* 0.99 dur)))) | |
env (env-gen (perc 0.01 dur) 1 1 0 1 FREE) | |
sqr (* (env-gen (perc 0 0.01)) (pulse (* 2 freq) width)) | |
src (sin-osc freq-env) | |
drum (+ sqr (* env src))] | |
(compander drum drum 0.2 1 0.1 0.01 0.01))) | |
(definst c-hat [amp 0.8 t 0.04] | |
(let [env (env-gen (perc 0.001 t) 1 1 0 1 FREE) | |
noise (white-noise) | |
sqr (* (env-gen (perc 0.01 0.04)) (pulse 880 0.2)) | |
filt (bpf (+ sqr noise) 9000 0.5)] | |
(* amp env filt))) | |
(defn flow | |
[time x] | |
(at (+ time 200) (piano 64)) | |
(at (+ time 400) (piano 64)) | |
(at (+ time 600) (piano 64)) | |
(at (+ time 800) (piano 60)) | |
(at (+ time 1000) (piano 60)) | |
(at (+ time 1200) (piano 60)) | |
(at (+ time 1400) (piano 57)) | |
(at (+ time 1600) (piano 57)) | |
(at (+ time 1800) (piano 57)) | |
(at (+ time 2200) (piano 57) (piano 54)) | |
(at (+ time 2400) (piano 57) (piano 54)) | |
(at (+ time 2600) (piano 57) (piano 54)) | |
(at (+ time 2800) (piano 60) (piano 57)) | |
(at (+ time 3000) (piano 60) (piano 57)) | |
(at (+ time 3200) (piano 60) (piano 57)) | |
(at (+ time 3400) (piano 64) (piano 60)) | |
(if (< x 4) | |
(at (+ time 3600) (piano 64) (piano 60)) | |
) | |
(if (< x 4) | |
(flow (+ time 4000) (+ 1 x)) | |
) | |
) | |
(defn beat | |
[time x] | |
(at (+ time 200) (kick)) | |
(at (+ time 400) (kick)) | |
(at (+ time 600) (c-hat)) | |
(at (+ time 800) (kick)) | |
(if (< x 30) | |
(beat (+ time 800) (+ 1 x)) | |
) | |
) | |
(defn -main [& args] | |
(do | |
(println "Piano Flow!") | |
(connect-external-server 1234) | |
(beat (now) 0) | |
(flow (+ (now) 2400) 0) | |
) | |
) | |
(-main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment