Skip to main content

MIDI Message Creation and Manipulation

The Smart Multibox has quite a few functions that allow you to create, send and receive MIDI messages. MIDI messages can also be created manually - they are actually Python bytearrays.

Message Creation Functions

midi_msg_make_1byte(msg_type)

Creates and returns a 1 byte MIDI message with the given message type. Message type constants are at the end of this page. 

midi_msg_make_cc(channel, number, value)

Creates and returns a MIDI CC (continuous controller) message with the given MIDI channel (1-16), number (0-127) and value (0-127).

midi_msg_make_chan_pressure(channel, note)value)

Creates and returns a MIDI channel pressure message with the given MIDI channel (1-16) and value (0-127).

midi_msg_make_note(channel, note, velocity)

Creates and returns a MIDI note message with the given MIDI channel (1-16), note number (0-127) and velocity (0-127). Using velocity of 0 is equivalent to a "note off".

midi_msg_make_pc(channel, number)

Creates and returns a MIDI PC (program change) message with the given MIDI channel (1-16) and number (0-127).

midi_msg_make_pitch_bend(channel, number)

Creates and returns a MIDI pitch bend message with the given MIDI channel (1-16) and number (0-16383).

midi_msg_make_poly_pressure(channel, note, value)

Creates and returns a MIDI polyphonic pressure message with the given MIDI channel (1-16), note number (0-127) and value (0-127).

Message Manipulation Functions

midi_msg_get_channel(midi_msg)

Given a MIDI message, returns the MIDI channel the message is on (1-16). Returns -1 if the MIDI message has no channel associated with it.

midi_msg_set_channel(midi_msg, channel)

Given a MIDI message, sets the MIDI channel of the message (1-16). Raises a ValueError exception if the channel value is not valid, or if the message does not have a specific channel.

midi_msg_get_number(midi_msg)

Given a MIDI message, returns the PC, CC or note number from the message is (0-127). Returns -1 if the MIDI message has no number associated with it.

midi_msg_set_channel(midi_msg_set_number(midi_msg, channel)number)

Given a MIDI message, sets the MIDIPC, channelCC or Note number of the message (1-16)0-127). Raises a ValueError exception if the channel value is not valid, or if the message does not have a specificnumber channel.associated with it.

midi_msg_get_type(midi_msg)

Given a MIDI message, returns the MIDI message type, which is the status byte with the MIDI channel value zeroed out (128-250). Constants defined for each message type are defined in the Constants section. Returns -1 if the MIDI message is not valid.

midi_msg_set_type(midi_msg, msg_type)

Given a MIDI message, sets the type of the message (128-250). Constants defined for each message type are defined in the Constants section. The existing MIDI channel of the message, if any, is left unchanged. Raises a ValueError exception if the type value or the MIDI message is not valid.

midi_msg_get_value(midi_msg)

Given a MIDI message, returns the CC, velocity or pressure value of the message (0-127). Returns -1 if the MIDI message has no value associated with it.

midi_msg_set_value(midi_msg, channel)

Given a MIDI message, sets the CC, velocity or pressure value of the message (0-127). Raises a ValueError exception if the value is not valid, or if the message does not have a value associated with it.

 

//

 Message manipulation functions
    { MP_ROM_QSTR(MP_QSTR_midi_msg_get_channel), MP_ROM_PTR(&py_multibox_midi_msg_get_channel_obj) },
    { MP_ROM_QSTR(MP_QSTR_midi_msg_set_channel), MP_ROM_PTR(&py_multibox_midi_msg_set_channel_obj) },
    { MP_ROM_QSTR(MP_QSTR_midi_msg_get_number), MP_ROM_PTR(&py_multibox_midi_msg_get_number_obj) },
    { MP_ROM_QSTR(MP_QSTR_midi_msg_set_number), MP_ROM_PTR(&py_multibox_midi_msg_set_number_obj) },
    { MP_ROM_QSTR(MP_QSTR_midi_msg_get_type), MP_ROM_PTR(&py_multibox_midi_msg_get_type_obj) },
    { MP_ROM_QSTR(MP_QSTR_midi_msg_set_type), MP_ROM_PTR(&py_multibox_midi_msg_set_type_obj) },
    { MP_ROM_QSTR(MP_QSTR_midi_msg_get_value), MP_ROM_PTR(&py_multibox_midi_msg_get_value_obj) },
    { MP_ROM_QSTR(MP_QSTR_midi_msg_set_value), MP_ROM_PTR(&py_multibox_midi_msg_set_value_obj) },