BasicMIDISocket:
Filter:
ddwMIDI/Classes (extension) | External Control > MIDI

BasicMIDISocket
ExtensionExtension

Generic note-on/off responder

Description

BasicMIDISocket installs a pair of functions to respond to note-on and -off messages. The functions receive the note number and velocity as arguments.

Channel information is not passed in, on the assumption that you're filtering the messages by device and channel according to the specification given in ddwMIDI_Guide: Identifying MIDI channels. If you need a function to respond to incoming note messages from multiple devices or channels, and the function needs to be aware of the message's source, use MIDIFunc or MIDIdef instead.

Class Methods

.new

Create a new instance. Arguments are:

chan
The messages' source. See ddwMIDI_Guide: Identifying MIDI channels.
onfunc
The function to handle note-on messages. The function's arguments should be |note_num, velocity|.
offfunc
The function to handle note-off messages. Same arguments as onfunc.

Note that the argument names shown by SCIde's method completion pop-up are different. This is because *new is inherited from AbstractMIDISocket, which provides a generic argument template.

Returns:

A BasicMIDISocket instance.

Instance Methods

.onPlayer

Returns:

The note-on function.

.offPlayer

Returns:

The note-off function.

.noteOn

This method is called in response to note-on messages. In normal use, you do not need to call this method. You may call it directly for testing or debugging.

Arguments:

note

The MIDI note number (0-127).

vel

Velocity (0-127).

.noteOff

This method is called in response to note-off messages. In normal use, you do not need to call this method. You may call it directly for testing or debugging.

Arguments:

note

The MIDI note number (0-127).

vel

Velocity (0-127).

.active

Returns:

Boolean: true if the socket's destination exists and is active; false otherwise.

Examples