Created
June 29, 2013 01:30
-
-
Save fronx/5889268 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
(def rock | |
{ :snare '(_ O) | |
:kick '(O _) }) | |
(def dnb | |
; '(1 _ . _ 2 _ . _ 3 _ . _ 4 _ . _) | |
{ :snare '(_ _ _ _ O _ _ o _ o _ _ O _ _ _) | |
:kick '(O _ _ _ _ _ _ _ _ _ O _ _ _ _ _) }) | |
(def reggae | |
; '(1 _ . _ 2 _ . _ 3 _ . _ 4 _ . _) | |
{ :hihat '(O O O _ O _ O _ _ O O _ O _ O _) | |
:snare '(_ _ _ _ O _ _ o _ _ _ _ O _ _ _) | |
:kick '(_ _ _ _ O _ _ _ _ _ _ _ O _ _ _) }) | |
(defn hit-intensity | |
[hit] | |
(cond | |
(= hit '_) 0 | |
(= hit 'o) 1 | |
(= hit 'O) 2)) | |
(defn parse-beat-sequence | |
[beat-sequence] | |
(map parse-hit beat-sequence)) | |
(defn stretch | |
[beat-sequence factor] | |
(mapcat #(cons % (repeat (dec factor) '_)) beat-sequence)) | |
(defn map-beat | |
[f beat] | |
(into {} (for [[k v] beat] [k (f v)]))) | |
(defn stretch-beat | |
[beat factor] | |
(map-beat #(stretch % factor) beat)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment