Skip to content

Instantly share code, notes, and snippets.

@gustafnk
Last active December 28, 2015 14:29
Show Gist options
  • Save gustafnk/7515507 to your computer and use it in GitHub Desktop.
Save gustafnk/7515507 to your computer and use it in GitHub Desktop.
Play a sequence of chords on a mooger, looping through the list of chords.
(ns insane-noises.core (:use [overtone.live]
[overtone.inst.synth]))
(def metro (metronome 64))
(def chords [[:C3 :E3 :G3 :B3] [:F3 :A3 :C3 :E4]])
(defn play-chord [chord] (doall (map (fn [n] (mooger n :amp 0.9)) (map note chord))))
(defn chord-player
[beat pids]
(let [next-beat (inc beat)]
(at (metro beat)
(let [new-pids (play-chord (get chords (mod beat (count chords))))]
(at (metro beat) (doall (map (fn [pid] (ctl pid :gate 0)) pids)))
(apply-at (metro next-beat) #'chord-player [next-beat new-pids])))))
(chord-player (metro) [])
(stop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment