Liking cljdoc? Tell your friends :D

casa.squid.midi

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]
```
raw docstring

__protocolsclj

source

add-receiverclj

(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]].
sourceraw docstring

add-receiver*clj

(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]].
sourceraw docstring

aget-bytecljmacro

(aget-byte arr idx)
source

b->lclj

(b->l b)

Signed byte (-127 to 128) to long (0 to 255)

Signed byte (-127 to 128) to long (0 to 255)
sourceraw docstring

cc-dataclj

source

channelclj

(channel msg)
source

controllerclj

source

data-fullclj

(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.
sourceraw docstring

data1clj

(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
sourceraw docstring

data2clj

(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
sourceraw docstring

eventclj

(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]
sourceraw docstring

event-typeclj

(event-type msg)
source

event-typesclj

source

event-valclj

(event-val msg)
source

event-valsclj

source

l->bclj

(l->b l)

Long to signed byte

Long to signed byte
sourceraw docstring

messageclj

(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]].
sourceraw docstring

MidiOpscljprotocol

-add-receiverclj

(-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-receiverclj

(-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.

-writeclj

(-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.
source

noteclj

source

pitchwheelclj

source

remove-receiverclj

(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)
sourceraw docstring

special-typesclj

source

special?clj

(special? msg)
source

statusclj

(status msg)
source

velocityclj

source

writeclj

(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
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close