Initial commit
This commit is contained in:
commit
a01e932c29
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.nrepl-port
|
||||
.cpcache
|
22
src/midi-playground/midi.clj
Normal file
22
src/midi-playground/midi.clj
Normal file
@ -0,0 +1,22 @@
|
||||
(ns midi-playground.midi
|
||||
(:import [javax.sound.midi MidiSystem ShortMessage Receiver Sequencer Synthesizer]))
|
||||
|
||||
(defn midi-message [command channel data1 data2]
|
||||
{:command command
|
||||
:channel channel
|
||||
:data1 data1
|
||||
:data2 data2})
|
||||
|
||||
(defn map->ShortMessage [{:keys [command channel data1 data2]}]
|
||||
(ShortMessage. command channel data1 data2))
|
||||
|
||||
(def default-receiver (MidiSystem/getReceiver))
|
||||
|
||||
(defn get-device-named [name]
|
||||
(MidiSystem/getMidiDevice
|
||||
(first
|
||||
(filter #(= name (.getName %))
|
||||
(MidiSystem/getMidiDeviceInfo)))))
|
||||
|
||||
(defn send-midi [rcvr midi-message]
|
||||
(.send rcvr (map->ShortMessage midi-message) -1))
|
Loading…
Reference in New Issue
Block a user