MIDI API | [Topic] |
midi-open &key (max-logical-channels *midi-default-max-logical-channels*) (max-routes *midi-default-max-routes*) (max-connections *midi-default-max-connections*) (max-mappings *midi-default-max-mappings*) (queue-size *midi-default-queue-size*) (channel-map *midi-default-channel-map*) (route-map *midi-default-route-map*) (connections *midi-default-connections*) port | [Mi_D API Function] |
Open or re-initialize the MIDI environment. The first five keyword arguments specify size limits for various data structures internal to the environment and hence force an implicit shutdown and re-opening if re-set in runtime. More precisely. max-logical-channels, max-routes and max-connections determine the dimensions of the internal channel and route maps, max-mappings the maximal number of mappings that may be established across both maps, and queue-size the number of events that may be queued for output before calls to midi-write-message block.
channel-map, route-map and connections initialize or re-set the internal data structures. port is provided for backwards compatibility only and its use is deprecated.
All keyword parameters take their defaults from global variables that may (and should) be customized by users to simplify opening MIDI. See their respective documentation for more info on the data expected by each parameter.
Calling midi-open while MIDI is already open closes MIDI first, then re-opens it again.
midi-open returns t if MIDI is open or nil if it is not (i.e., the updated value of midi-open?.)
*midi-default-max-logical-channels*, *midi-default-max-routes*, *midi-default-max-connections*, *midi-default-max-mappings*, *midi-default-queue-size*, *midi-default-channel-map*, *midi-default-route-map*, *midi-default-connections*, midi-open?
midi-close () | [Mi_D API Function] |
midi-open?
midi-update-system-info () | [Mi_D API Function] |
Use this function to update the MIDI environment if you've added new devices to the system such as a new MIDI client that you want to receive messages.
midi-print-environment &optional (verbosity 1) (stream :stderr) | [Mi_D API Function] |
Print a summary of the current MIDI environment to stream. verbosity may be one of 0 (terse), 1 (default), or 2 (technical). stream must be either :stdout or :stderr, requesting output on either *standard-output* or *standard-error, respectively.
midi-get-environment-info &rest selectors | [Mi_D API Function] |
midi-get-environment-info takes as arguments any number of keyword info selectors in selectors and returns the query results for each selector as multiple values.
Possible information selectors are:
? (midi-get-environment-info :mi_d-max-logical-channels :mi_d-max-routes :mi_d-max-connections :mi_d-max-map-cells :mi_d-queue-size) 120 10 10 400 20000
midi-open
midi-check-environment () | [Mi_D API Function] |
Performs an environment consistency check. Returns t if no inconsistencies were found, nil otherwise.
midi-connect connection interface direction | [Mi_D API Function] |
Associate connection connection with the interface named by interface. direction will be one of :input, :output or :bidirectional.
midi-set-connections
midi-write-message msg &optional (time 0) | [Mi_D API Function] |
Schedules the message encoded in msg for output at time time. If time is not specified, it defaults to 0, i.e. the message is sent immediately.
midi-write-note, midi-write-sysex, *midi-sysex-refcounter*
midi-write-sysex vector &key msg route length (time 0) (refcount *midi-sysex-refcounter*) | [Mi_D API Function] |
Schedules a system exclusive message for output at time time. vector contains a complete system exclusive message in form of an array of type
(simple-array (unsigned-byte 8) (*))and length indicates the length of the message in bytes. The route on which to output the message may be given either explicitly via route or implicitly by passing the first return value of make-sysex-message in msg.
If the client wishes to free sysex data after sending it, she is encouraged to pass a refcounter object in refcounter whose value field may be initialized to any number that is meaningful to the client--typically 0. write-sysex increments the counter, schedules the message, and returns immediately, i.e., the message is written out asynchronously. The counter is decremented as soon as the message is written out completely. This mechanism allows the client to write a sysex message to different destinations at different times, while sharing the message's data across calls. After the counter has been decremented it will be safe to deallocate the data. refcounter defaults to *midi-sysex-refcounter*. Additional refcounter objects may be constructed by calling
mi_d:make-refcounter initial-value
*midi-sysex-refcounter*, make-sysex-message
midi-write-note channel keynum velocity duration &optional (time 0) ( off-velocity 64) | [Mi_D API Function] |
Convenience function that schedules a note-on and note-off message pair given a note description.
midi-read-messages &optional (fun *midi-read-hook*) &key skip-data | [Mi_D API Function] |
Remove pending messages from the input queue and optionally map the function fun over each message. fun's lambda list must be compatible with
(msg &optional time &key data length &allow-other-keys)and will be passed each message and its millisecond time in msg and time. Sysex data and its length will be passed to fun via its data and length keywords unless skip-data is t.
? (midi-read-messages #'midi-print-message)
*midi-read-hook*, midi-receive, midi-print-message
midi-flush-input () | [Mi_D API Function] |
Discards ("flushes") events pending in the input queue.
midi-flush-output () | [Mi_D API Function] |
Discards ("flushes") events pending in the output queue.
midi-all-notes-off () | [Mi_D API Function] |
Broadcast "All Notes Off", "All Sound Off", and "Reset All Controllers" control messages on all active output connections. Note that this does not work with some older MIDI devices that are unaware of these messages. These devices continue to need note-off messages on every channel and key number.
midi-hush () | [Mi_D API Function] |
midi-hush is equivalent to a calling midi-all-notes-off followed by midi-flush-input and midi-flush-output.
midi-get-time () | [Mi_D API Function] |
Return the current MIDI time in milliseconds.
midi-set-time ms | [Mi_D API Function] |
Set the MIDI timer to ms milliseconds.
midi-stop-timer | [Mi_D API Function] |
Provided for backwards compatibility. This function does not do anything.
midi-start-timer () | [Mi_D API Function] |
Start the MIDI timer. Equivalent to (midi-set-time 0).
midi-c-print-message msg &optional time &key data length ( maxlines 0) stream time-format &allow-other-keys | [Mi_D API Function] |
Prints MIDI messages in a slightly different format than midi-print-messageonto *standard-output*
midi-print-message