Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2011 05:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1436826 to your computer and use it in GitHub Desktop.
Save anonymous/1436826 to your computer and use it in GitHub Desktop.
(ns test.core
(:use [overtone.live]
[overtone.inst.synth]))
(def kick (sample "kick.wav"))
(def snare (sample "snare.wav"))
(def hit (sample "hit.wav"))
(def insts {:kick kick
:snare snare
:hit hit})
(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]
:hit [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))
(metro :bpm 160)
(metro :bpm 90)
(defn player [beat] "stop")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment