diff options
| author | Jake Zerrer <him@jakezerrer.com> | 2025-11-07 15:42:03 -0500 |
|---|---|---|
| committer | Jake Zerrer <him@jakezerrer.com> | 2025-11-07 15:51:27 -0500 |
| commit | 945eb221209a6c3c00b2f0fcbbc7e19b343ee9d9 (patch) | |
| tree | badb4423a670751101ac84b25c80eee32cc9151c /src/unheard/instrument/minilab3.clj | |
| parent | 6b25663be05e32a856dfa64dc9dbc92990ccbc56 (diff) | |
Add new instrument
Diffstat (limited to 'src/unheard/instrument/minilab3.clj')
| -rw-r--r-- | src/unheard/instrument/minilab3.clj | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/src/unheard/instrument/minilab3.clj b/src/unheard/instrument/minilab3.clj index 4973be2..3a60058 100644 --- a/src/unheard/instrument/minilab3.clj +++ b/src/unheard/instrument/minilab3.clj @@ -1,41 +1,10 @@ (ns unheard.instrument.minilab3 - (:require [missionary.core :as m]) - (:import [javax.sound.midi ShortMessage])) + (:require [unheard.instrument.util :refer [matching-control]])) -(def matching-control-change - (filter (fn [^ShortMessage m] (= (.getCommand m) ShortMessage/CONTROL_CHANGE)))) +(def device-name + "CoreMIDI4J - Minilab3 MIDI") -(defn matching-channel [ch] - (filter (fn [^ShortMessage m] (= (.getChannel m) ch)))) - -(defn matching-data-1 [d1] - (filter (fn [^ShortMessage m] (= (.getData1 m) d1)))) - -(def get-data-2 - (map (fn [^ShortMessage m] (.getData2 m)))) - -(defn matching-control - "Returns a function filtering flow of ShortMessage `f` down to control - change messages where channel is `ch` and data-1 is `k`, and then returning - a signal of values for data-2. Initial value of signal will be `init`. - - Though a little esoteric sounding, this is actually quite useful. - The signal returned by this is useful for representing knobs, faders, and - pads on a midi controller. - " - [init ch k] - (fn [f] - (m/signal - (m/reductions {} init - (m/eduction - (comp - matching-control-change - (matching-channel ch) - (matching-data-1 k) - get-data-2) - f))))) - -(def minilab3 +(def config {:knob {1 (matching-control 0 0 74) 2 (matching-control 0 0 71) |
