Created
May 25, 2014 19:16
-
-
Save triss/90fbc36f1aff2ba008bb to your computer and use it in GitHub Desktop.
euclidean beat sin clojure
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
(ns clojtest.core) | |
(defn rotate-left | |
([coll] (rotate-left 1 coll)) | |
([n coll] (concat (drop n coll) (take n coll)))) | |
(defn euclidean-beat | |
([hit-length length rotation] | |
(rotate-left rotation | |
(euclidean-beat hit-length length))) | |
([hit-length] (euclidean-beat hit-length 16)) | |
([hit-length length] | |
(take length | |
(flatten (repeat (cons 1 (repeat (- hit-length 1) 0))))))) | |
(defn sum [xs ys] (map (fn [x y] (+ x y)) xs ys)) | |
(reduce sum [(euclidean-beat 3) | |
(euclidean-beat 3 16 3) | |
(euclidean-beat 5) | |
(euclidean-beat 4)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment