MIDI API
Overview​
Matrix OS's MIDI system is complex and powerful. It allows you to send and receive MIDI messages, including System Exclusive (SysEx) messages to different registered MIDI ports or multiple MIDI ports at the same time.
You can even create virtual ports on a thread to communicate with your applications.
See the MIDI Packet and MIDI Port documentation for more information on the MIDI packet and port structures.
The header file for this API is part of os/MatrixOS.h and the implementation is in os/system/MIDI.cpp.
MatrixOS::MIDI::Get
​
bool Get(MidiPacket* midiPacketDest, uint16_t timeout_ms = 0);
Retrieves the next available MIDI packet. If no packet is available, the function waits for the specified timeout.
The source of the MIDI packet is in the port
field of the packet.
Parameters:
midiPacketDest
(MidiPacket*
): Pointer to store the retrieved MIDI packet.timeout_ms
(uint16_t
, optional): Maximum time to wait for a MIDI packet in milliseconds. Defaults to0
.
Returns:
bool
:true
if a MIDI packet was retrieved successfully, otherwisefalse
.
MatrixOS::MIDI::Send
​
bool Send(MidiPacket midiPacket, uint16_t timeout_ms = 0);
Sends a MIDI packet. The packet will be send to the port specified in the packet.
Parameters:
midiPacket
(MidiPacket
): The MIDI packet to send.timeout_ms
(uint16_t
, optional): Maximum time to wait for the send operation in milliseconds. Defaults to0
.
Returns:
bool
:true
if the MIDI packet was sent successfully, otherwisefalse
.
MatrixOS::MIDI::SendSysEx
​
bool SendSysEx(uint16_t port, uint16_t length, uint8_t* data, bool includeMeta = true);
Sends a System Exclusive (SysEx) MIDI message buffer. Optionally includes the correct SysEx header and ending.
Parameters:
port
(uint16_t
): The MIDI port to send the SysEx message through.length
(uint16_t
): The length of the SysEx data.data
(uint8_t*
): Pointer to the SysEx data to send.includeMeta
(bool
, optional): Whether to include the default SysEx header and ending. Defaults totrue
. If this is false, the data must include the SysEx header and ending.
Returns:
bool
:true
if the SysEx message was sent successfully, otherwisefalse
.
Comments