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_MIXER

Identifies the “Mixer” control button in messages sent to/from the Launchpad.

CC_SESSION

Identifies the “Session” control button in messages sent to/from the Launchpad.

CC_USER1

Identifies the “User 1” control button in messages sent to/from the Launchpad.

CC_USER2

Identifies the “User 2” control button in messages sent to/from the Launchpad.

close

(close lpad)

close the launchpad device.

Examples:

(close lpad)

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

Examples:

(open)

remove-button-press-handler

(remove-button-press-handler {:keys [in]})

Remove any event handlers.

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 the status, data1 and data2 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.

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))))))

SYSEX_HEADER

The common set of header bytes sent with each Sysex message

SYSEX_LIGHT_COLUMN_STATUS

The status byte for a light column Sysex message

SYSEX_LIGHT_GRID_STATUS

The status byte for a light grid Sysex message

SYSEX_LIGHT_ROW_STATUS

The status byte for a light row Sysex message

SYSEX_RGB_STATUS

The status byte for a RGB Sysex message

SYSEX_SCROLL_STATUS

The status byte for a scroll text Sysex message