MIDI message parsing and construction logic.
Interpreting and constructing of midi message as byte arrays (signed) or long arrays (unsigned).
(def msg (byte-array 3 [130 64 100])) ;; Middle C on channel 2 with velocity 100
(channel msg) ;; => 2
(event-type msg) ;; => :note-on
(note msg) ;; => 64
(velocity msg) ;; => 100
(event msg) ;; => [2 :note-on 64 100]
MIDI message parsing and construction logic. Interpreting and constructing of midi message as byte arrays (signed) or long arrays (unsigned). ``` clojure (def msg (byte-array 3 [130 64 100])) ;; Middle C on channel 2 with velocity 100 (channel msg) ;; => 2 (event-type msg) ;; => :note-on (note msg) ;; => 64 (velocity msg) ;; => 100 (event msg) ;; => [2 :note-on 64 100] ```
(add-receiver port k callback)Register a MIDI receiver function. Gets called for each individual event. Callback signature is [event millis], with event a [channel type & bytes] vector, with type a keyword. Millis is an millisecond-level epoch (Unix) timestamp.
Use the value of k (registration key), to replace or remmove a receiver.
Calling this again with the same k replaces the previous callback, similar
to how [[add-watch]] works. See also remove-receiver.
Register a MIDI receiver function. Gets called for each individual event. Callback signature is [event millis], with event a [channel type & bytes] vector, with type a keyword. Millis is an millisecond-level epoch (Unix) timestamp. Use the value of `k` (registration key), to replace or remmove a receiver. Calling this again with the same `k` replaces the previous callback, similar to how [[add-watch]] works. See also [[remove-receiver]].
(add-receiver* port k callback)Low level variant of add-receiver, receives byte arrays instead of vectors.
Register a MIDI receiver function. Gets called for each individual event. Callback signature is [message millis], with message the raw midi byte array. Millis is an millisecond-level epoch (Unix) timestamp.
Use the value of k (registration key), to replace or remmove a receiver.
Calling this again with the same k replaces the previous callback, similar
to how [[add-watch]] works. See also remove-receiver.
Low level variant of [[add-receiver]], receives byte arrays instead of vectors. Register a MIDI receiver function. Gets called for each individual event. Callback signature is [message millis], with message the raw midi byte array. Millis is an millisecond-level epoch (Unix) timestamp. Use the value of `k` (registration key), to replace or remmove a receiver. Calling this again with the same `k` replaces the previous callback, similar to how [[add-watch]] works. See also [[remove-receiver]].
(b->l b)Signed byte (-127 to 128) to long (0 to 255)
Signed byte (-127 to 128) to long (0 to 255)
(data-full msg)Return the data bytes combined into a single integer
Used for pitch-wheel messages.
Return the data bytes combined into a single integer Used for pitch-wheel messages.
(data1 msg)Return the first data byte
Semantics depend on the message type, e.g. note number, controller number, program number
Return the first data byte Semantics depend on the message type, e.g. note number, controller number, program number
(data2 msg)Return the second data byte
Semantics depend on the message type, e.g. velocity, pressure
Return the second data byte Semantics depend on the message type, e.g. velocity, pressure
(event msg)Convert a message (array) to an event vector.
Given a three element message array, return a four element vector with [channel event-type data-byte-1 data-byte-2]
Convert a message (array) to an event vector. Given a three element message array, return a four element vector with [channel event-type data-byte-1 data-byte-2]
(message v)(message channel type & data)Convert an event vector to a message array
The inverse of event.
Convert an event vector to a message array The inverse of [[event]].
(-add-receiver port callback)Register a MIDI receiver callback
Callback signature is [message millis], with message a byte-array, and millis a epoch-based timestamp (can be compared with System/currentTimeMillis).
This is a low-level protocol method, see add-receiver for the user-side
API.
Register a MIDI receiver callback Callback signature is [message millis], with message a byte-array, and millis a epoch-based timestamp (can be compared with System/currentTimeMillis). This is a low-level protocol method, see [[add-receiver]] for the user-side API.
(-remove-receiver port callback)Remove a MIDI receiver callback, relies on object identity of the callback
This is a low-level protocol method, see add-receiver for the user-side
API.
Remove a MIDI receiver callback, relies on object identity of the callback This is a low-level protocol method, see [[add-receiver]] for the user-side API.
(-write port message offset)Write (send) a MIDI message to the given port
Offset is application specific, for 'direct' (push-based) ports, offset should be ignored, and messages are sent immediately (or at the start of the next cycle). For pull-based (processing callback), offset is generally in frames, and can be used for precise sequence scheduling.
Write (send) a MIDI message to the given port Offset is application specific, for 'direct' (push-based) ports, offset should be ignored, and messages are sent immediately (or at the start of the next cycle). For pull-based (processing callback), offset is generally in frames, and can be used for precise sequence scheduling.
(remove-receiver port k)Remove a previously added receiver, based on the supplied k (key)
Remove a previously added receiver, based on the supplied k (key)
(write port msg)(write port msg offset)Write a message to a given port, version with offset is for
pullback (processing callback based) ports, and is application
dependant (typically: frames within the current callback). Message is a
vector [channel msg-type & data], with msg-type a keyword.
See event/message. Use -write directly if you already have raw
bytes you want to send
Write a message to a given port, version with offset is for pullback (processing callback based) ports, and is application dependant (typically: frames within the current callback). Message is a vector [channel msg-type & data], with msg-type a keyword. See [[event]]/[[message]]. Use [[-write]] directly if you already have raw bytes you want to send
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |