Skip to content

Commit

Permalink
The note-sequencer accepts a seq of key/value pairs
Browse files Browse the repository at this point in the history
Unlike a step-sequencer, where each step is either 0 or 1, the
note-sequencer takes the step and does partial application on to the
instrument.
  • Loading branch information
mwunsch committed Feb 16, 2016
1 parent 32a41c6 commit 4e9d63a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/sonic_sketches/core.clj
Expand Up @@ -33,6 +33,20 @@
(apply-at (+ t (/ tick bars)) #'step-sequencer [nome instrument (rest pulses) channel]))
(apply-at (+ t tick) async/>!! [channel [nome drum]])))))

(defn note-sequencer
"Similar to the step-sequencer, except the sequence should be a
vector of key, value pairs to be applied to the instrument"
[nome instrument pulses]
(let [t (now)
tick (metro-tick nome)
bars (metro-bpb nome)]
(if-let [pulse (first pulses)]
(do
(when (some? pulse)
(at t (apply instrument pulse)))
(apply-at (+ t (/ tick bars)) #'note-sequencer [nome instrument (rest pulses)]))
(apply-at (+ t tick) println ["All finished"]))))

(defn drummachine
"Accepts a metronome and a vector of instructions. Each instruction
is a pair of instruments and a sequence of 0's or 1's. Returns a seq
Expand Down

0 comments on commit 4e9d63a

Please sign in to comment.