commit a01e932c29798809ee3d4661574206f445f822ca Author: Jeremy Dormitzer Date: Sat Nov 9 16:04:54 2019 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e1296b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.nrepl-port +.cpcache \ No newline at end of file diff --git a/deps.edn b/deps.edn new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/deps.edn @@ -0,0 +1 @@ +{} diff --git a/src/midi-playground/midi.clj b/src/midi-playground/midi.clj new file mode 100644 index 0000000..0eb6669 --- /dev/null +++ b/src/midi-playground/midi.clj @@ -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))