Created
October 15, 2012 04:13
-
-
Save harold/3890789 to your computer and use it in GitHub Desktop.
16th note sequencer
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
(def snare (sample (freesound-path 26903))) | |
(def kick (sample (freesound-path 2086))) | |
(def ch (sample (freesound-path 802))) | |
(def oh (sample (freesound-path 26657))) | |
(def insts {:kick kick | |
:snare snare | |
:oh oh | |
:ch ch}) | |
(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] | |
:oh [1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0] | |
:ch [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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment