Created
July 30, 2011 03:23
-
-
Save nick-orton/1115153 to your computer and use it in GitHub Desktop.
dirty sequencer
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
(def metro (metronome 128)) | |
(def sequencer {0 [kick] | |
0.5 [c-hat] | |
1 [kick snare] | |
1.5 [c-hat] | |
2 [kick] | |
2.5 [c-hat] | |
3 [kick snare] | |
3.5 [c-hat]}) | |
(defn player | |
[beat] | |
(dorun | |
(for [k (keys sequencer)] | |
(let [b (Math/floor k) | |
offset (- k b)] | |
(if (= 0 (mod (- beat b) 4)) | |
(let [instruments (sequencer k)] | |
(dorun | |
(for [instrument instruments] | |
(at (metro (+ offset beat)) (instrument))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment