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)

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

    // 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) },