diff options
| author | Jake Zerrer <him@jakezerrer.com> | 2025-10-17 19:24:36 -0400 |
|---|---|---|
| committer | Jake Zerrer <him@jakezerrer.com> | 2025-10-17 19:27:44 -0400 |
| commit | 2fdb7ce022b521b93ed314c1d33369bfa5d2bd0e (patch) | |
| tree | 10dde2d060a194bbd22f31b497e4f6ed295c1c6f /src | |
| parent | 4ff62448f9adbb75e79f528ca4528e0faf4399a3 (diff) | |
Working on getting supervision tree right
Diffstat (limited to 'src')
| -rw-r--r-- | src/midi.clj | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/midi.clj b/src/midi.clj index ca70273..4c10de0 100644 --- a/src/midi.clj +++ b/src/midi.clj @@ -58,21 +58,22 @@ "Returns a device for given device name. Returns nil if device not found." [device-name with-device] (m/ap - (when-let [device-info (m/?< (>device-info device-name))] - (let [^MidiDevice device (MidiSystem/getMidiDevice ^MidiDevice$Info device-info)] - ;; Essential problem: Combining taking element from flow to put in - ;; conditional, and cleaning up in catch. - ;; NOTE: You need the MidiDevice type hint when you call open and close! - (try - (println "Opening device") - (m/? (m/via m/blk (.open device))) - (println "Device opened") - (m/?< (with-device device)) - (finally - (println "Closing device") - (m/compel (m/? (m/via m/blk (.close device)))) - (println "Device closed") - )))))) + (let [device-info + (m/?< (>device-info device-name)) + ^MidiDevice device (MidiSystem/getMidiDevice ^MidiDevice$Info device-info)] + ;; Essential problem: Combining taking element from flow to put in + ;; conditional, and cleaning up in catch. + ;; NOTE: You need the MidiDevice type hint when you call open and close! + (try + (println "Opening device") + (m/? (m/via m/blk (.open device))) + (println "Device opened") + (m/?< (with-device device)) + (finally + (println "Closing device") + (m/compel (m/? (m/via m/blk (.close device)))) + (println "Device closed") + ))))) (defn new-device "Generate a new midi device. @@ -111,7 +112,7 @@ (def run (m/ap (prn (m/?< (>device (m/?< >bus-sel) - (fn [v] (m/ap (m/amb (m/?< v))))))) + >midi-messages))) )) (def close ((m/reduce prn {} run) {} {})) |
