diff options
| author | Jake Zerrer <him@jakezerrer.com> | 2025-11-25 14:53:20 -0500 |
|---|---|---|
| committer | Jake Zerrer <him@jakezerrer.com> | 2025-11-25 15:24:39 -0500 |
| commit | 20ce2f424552a6124575c79c1ce5476addbaba95 (patch) | |
| tree | 3230c1c7efd7a212cbcdb0b17b0dad1f622a69b1 /src/unheard/instrument | |
| parent | 1a3fefa99bc49f0cbedf0318b802ac334a6be16b (diff) | |
Implement interval tree logic
Diffstat (limited to 'src/unheard/instrument')
| -rw-r--r-- | src/unheard/instrument/util.clj | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/unheard/instrument/util.clj b/src/unheard/instrument/util.clj index 0faa5b5..7c99f8b 100644 --- a/src/unheard/instrument/util.clj +++ b/src/unheard/instrument/util.clj @@ -3,16 +3,16 @@ (:import [javax.sound.midi ShortMessage])) (def matching-control-change - (filter (fn [^ShortMessage m] (= (.getCommand m) ShortMessage/CONTROL_CHANGE)))) + (filter (fn [^ShortMessage m] + (= (.getCommand m) ShortMessage/CONTROL_CHANGE)))) -(defn matching-channel [ch] +(defn matching-channel + [ch] (filter (fn [^ShortMessage m] (= (.getChannel m) ch)))) -(defn matching-data-1 [d1] - (filter (fn [^ShortMessage m] (= (.getData1 m) d1)))) +(defn matching-data-1 [d1] (filter (fn [^ShortMessage m] (= (.getData1 m) d1)))) -(def get-data-2 - (map (fn [^ShortMessage m] (.getData2 m)))) +(def get-data-2 (map (fn [^ShortMessage m] (.getData2 m)))) (defn matching-control "Returns a function filtering flow of ShortMessage `f` down to control @@ -25,15 +25,12 @@ " [init ch k] (fn [f] - ;; TODO: Should be signal - (m/stream - (m/reductions {} init - (m/eduction - (comp - matching-control-change - (matching-channel ch) - (matching-data-1 k) - get-data-2 - ;; TODO git-bug f109911 - (dedupe)) - f))))) + (m/stream (m/reductions {} + init + (m/eduction (comp matching-control-change + (matching-channel ch) + (matching-data-1 k) + get-data-2 + ;; TODO git-bug f109911 + (dedupe)) + f))))) |
