diff options
Diffstat (limited to 'dev/scratch.clj')
| -rw-r--r-- | dev/scratch.clj | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/dev/scratch.clj b/dev/scratch.clj index 9459c81..ef7241a 100644 --- a/dev/scratch.clj +++ b/dev/scratch.clj @@ -1,6 +1,6 @@ (ns scratch (:require [unheard.midi :as midi] - [unheard.midi.percussion :refer [kick snare]] + [unheard.midi.percussion :refer [kick snare hat]] [unheard.clock :refer [clock]] [unheard.theory :refer [note poly]] [missionary.core :as m])) @@ -9,19 +9,41 @@ (def midi-keyboard "CoreMIDI4J - Minilab3 MIDI") - (def run (midi/<bus midi-keyboard (fn [v] (m/ap ;; 2 is the number of message types, e.g. :key - (let [[t f] (m/?> 2 (midi/keyboard v))] - [t (rest (m/?< f))]))))) + (let [[>c c] (clock) + p (poly + (note >c 0 1 kick) + (note >c 8 1 kick) + (note >c 16 1 kick) + (note >c 24 1 kick) + + (note >c 0 1 hat) + (note >c 4 1 hat) + (note >c 8 1 hat) + (note >c 12 1 hat) + (note >c 16 1 hat) + (note >c 20 1 hat) + (note >c 24 1 hat) + (note >c 28 1 hat) + + (note >c 4 1 snare) + (note >c 12 1 snare) + (note >c 20 1 snare) + (note >c 28 1 snare))] + (m/amb= + (let [[t f] (m/?> 2 (midi/keyboard v)) + [ch k v] (rest (m/?< f))] + (if (and (= t :control) (= ch 0) (= k 74)) + (do (reset! c v) (m/amb)) + (m/amb))) + [:n (m/?< (m/eduction (dedupe) p))] + [:c (m/?< (m/eduction (dedupe) >c))])))))) -#_ (def cancel (run prn prn)) -#_ (cancel) - |
