Skip to main content
Version: Matrix OS 3.2

MIDI API

Preview notice

The MatrixOS Python API is in preview and is subject to change; it may contain errors.

Overview

The MIDI system in MatrixOS provides communication with external MIDI devices and software. It supports standard MIDI messages, SysEx data, and handles multiple MIDI ports. The MIDI API is available as MatrixOS.MIDI and is imported by default.

The Python MIDI API is implemented in Applications/Python/PikaPython/MatrixOS_MIDI.py with type hints in Applications/Python/PikaPython/_MatrixOS_MIDI.pyi.


MatrixOS.MIDI.Get

def Get(timeout_ms: int = 0) -> any

Receives the next MIDI packet from the input queue.

Parameters:

  • timeout_ms (int, optional): Timeout in milliseconds to wait for MIDI data (defaults to 0 for no timeout)

Returns:

  • MidiPacket: MIDI packet object on success
  • None: On timeout or no data available

MatrixOS.MIDI.Send

def Send(packet: MidiPacket, timeout_ms: int = 0) -> bool

Sends a MIDI packet to the output.

Parameters:

  • packet (MidiPacket): MIDI packet to send
  • timeout_ms (int, optional): Timeout in milliseconds for send operation (defaults to 0 for no timeout)

Returns:

  • bool: True if sent successfully, False on timeout or error

MatrixOS.MIDI.SendSysEx

def SendSysEx(port: int, length: int, data: bytes, include_meta: bool = False) -> bool

Sends System Exclusive (SysEx) MIDI data.

Parameters:

  • port (int): MIDI port to send on
  • length (int): Length of SysEx data
  • data (bytes): SysEx data bytes
  • include_meta (bool, optional): Whether to include SysEx meta bytes (F0/F7) (defaults to False)

Returns:

  • bool: True if sent successfully

Comments