clj-launchpad-mk2.midi.core
Holds the functions which ‘talk MIDI’ to the Launchpad via messages in the javax.sound.midi
package.
CC_CURSOR_DOWN
Identifies the cursor down control button in messages sent to/from the Launchpad.
CC_CURSOR_LEFT
Identifies the cursor left control button in messages sent to/from the Launchpad.
CC_CURSOR_RIGHT
Identifies the cursor right control button in messages sent to/from the Launchpad.
CC_CURSOR_UP
Identifies the cursor up control button in messages sent to/from the Launchpad.
CC_SESSION
Identifies the “Session” control button in messages sent to/from the Launchpad.
decode-message
(decode-message obj)
Decompose a com.sun.media.sound.FastShortMessage into a Launchpad-specific map.
Examples:
(def lp-msg (decode-message raw-msg))
(println (:x lp-msg) (:y lp-msg))
(println (:button-up? lp-msg))
(println (:velocity lp-msg))
(= (:note lp-msg) (:getData1 raw-msg))
open
(open)
find the launchpad by name in the available midi devices and return a launchpad object suitable for the calls of this library
name
should be the string returned from MidiSystem/getMidiDeviceInfo
Examples:
(open)
remove-button-press-handler
(remove-button-press-handler {:keys [in]})
Remove any event handlers.
- the first argument should be a map containing an
in
key which returns a javax.sound.midi.Transmitter.
Examples:
(remove-button-press-handler lpad)
send-midi
(send-midi {:keys [out]} & args)
Sends a javax.sound.midi.ShortMessage to the specified device.
- the first argument should be a map containing an
out
key which returns a javax.sound.midi.Receiver. args
should be a three element sequence containing thestatus
,data1
anddata2
components of the message respectively.
Examples:
(send-midi lpad 0x90 11 43)
send-midi-sysex
(send-midi-sysex {:keys [out]} & args)
Sends a javax.sound.midi.SysexMessage to the specified device.
- the first argument should be a map containing an
out
key which returns a javax.sound.midi.Receiver. args
should be an arbitary length sequence which will be wrapped by SYSEX_HEADER and SYSEX_FOOTER information and converted to a byte array.
Examples:
(send-midi-sysex lpad 13 4 43)
send-midi-sysex-scroll
(send-midi-sysex-scroll {:keys [out]} text & args)
Sends a javax.sound.midi.SysexMessage to the specified device to produce scrolling text.
- the first argument should be a map containing an
out
key which returns a javax.sound.midi.Receiver. text
should be a sequence of integers representing the letters of the text to scroll (e.g.,(map #(int (char %)) "Hello")
.args
should be an arbitary length sequence which will be wrapped by SYSEX_HEADER, text and SYSEX_FOOTER information and converted to a byte array.
Examples:
(send-midi-sysex-scroll lpad (72 101 108 108 111) 20 45 0)
set-button-press-handler
(set-button-press-handler {:keys [in]} handler-fn)
Specify a single handler that will receive all midi events from the input device.
- the first argument should be a map containing an
in
key which returns a javax.sound.midi.Transmitter. - handler should be a function that accepts a single parameter - a decoded version of the event.
Examples:
(set-button-press-handler
lpad
(fn [msg]
(light-cell
lpad
(:x msg)
(:y msg)
(- 127 (+ (:x msg) (:y msg))))))