Created
December 6, 2011 05:04
-
-
Save anonymous/1436826 to your computer and use it in GitHub Desktop.
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 test.core | |
(:use [overtone.live] | |
[overtone.inst.synth])) | |
(def kick (sample "kick.wav")) | |
(def snare (sample "snare.wav")) | |
(def hit (sample "hit.wav")) | |
(def insts {:kick kick | |
:snare snare | |
:hit hit}) | |
(def pat {:kick [1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0] | |
:snare [0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0] | |
:hit [0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0]}) | |
(def metro (metronome 135)) | |
(defn play-pat [beat i] | |
(let [t (mod beat 4) | |
p (vec (take 4 (drop (* 4 t) (pat i))))] | |
(if (= 1 (p 0)) (at (metro (+ 0.00 beat)) ((insts i)))) | |
(if (= 1 (p 1)) (at (metro (+ 0.25 beat)) ((insts i)))) | |
(if (= 1 (p 2)) (at (metro (+ 0.50 beat)) ((insts i)))) | |
(if (= 1 (p 3)) (at (metro (+ 0.75 beat)) ((insts i)))))) | |
(defn player [beat] | |
(doseq [i (keys insts)] (play-pat beat i)) | |
(apply-at (metro (inc beat)) #'player (inc beat) [])) | |
(player (metro)) | |
(metro :bpm 160) | |
(metro :bpm 90) | |
(defn player [beat] "stop") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment