Skip to content

Instantly share code, notes, and snippets.

@nick-orton
Created July 30, 2011 03:23
Show Gist options
  • Save nick-orton/1115153 to your computer and use it in GitHub Desktop.
Save nick-orton/1115153 to your computer and use it in GitHub Desktop.
dirty sequencer
(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