Messages
MidiType
Bases: AttrEnum
MIDI message type enumerator to use as MidiMsg
type
attribute.
NOTE_ON = 'NOTE_ON'
NOTE_OFF = 'NOTE_OFF'
CONTROL_CHANGE = 'CONTROL_CHANGE'
POLYTOUCH = 'POLYTOUCH'
AFTERTOUCH = 'AFTERTOUCH'
PROGRAM_CHANGE = 'PROGRAM_CHANGE'
PITCH_BEND = 'PITCH_BEND'
SYSEX = 'SYSEX'
MidiMsg
Bases: Msg
The base class for MIDI messages that will produce ChannelMsg
or SysexMsg
objects depending on init arguments.
It is advised to use ChannelMsg
or SysexMsg
classes to create own MIDI messages for clarity.
ChannelMsg
ChannelMsg(
type: MidiType = MidiType.CONTROL_CHANGE,
channel: int = 1,
data1: int = 0,
data2: int = 64,
*,
combined_data: None | int = None,
source: None | MidiIn = None
)
Bases: MidiMsg
Channel voice/mode MIDI message. The most common MIDI message.
Parameters:
-
type
(MidiType
, default:CONTROL_CHANGE
) –MIDI message type
-
channel
(int
, default:1
) –MIDI message channel (1-16)
-
data1
(int
, default:0
) –First data byte: note, control, program or aftertouch value depending on MIDI message type (0-127)
-
data2
(int
, default:64
) –Second data byte: velocity, value depending on MIDI message type (0-127)
-
combined_data
(None | int
, default:None
) –Both data bytes combined to 14-bit number - pitch value for pitch bend MIDI message (0-16383)
-
source
(None | MidiIn
, default:None
) –The
MidiIn
instance that generated the message
data1
First data byte: note, control, program or aftertouch value depending on MIDI message type (0-127).
combined_data
Both data bytes combined to 14-bit number - pitch value for pitch bend MIDI message (0-16383).
matches
matches(
type: None | Container[MidiType] | MidiType = None,
channel: None | Container[int] | int = None,
data1: None | Container[int] | int = None,
data2: None | Container[int] | int = None,
*,
combined_data: None | Container[int] | int = None
) -> bool
Checks if message's attributes match all provided attribute conditions:
-
If condition is
None
or omitted, it matches anything. -
If condition equals attribute, it matches the attribute.
-
If condition is a container and contains the attribute, it matches the attribute.
Use Not(condition)
to invert condition matching.
Returns:
-
bool
–True
if all attributes match,False
if any does not match
SysexMsg
Bases: MidiMsg
System exclusive MIDI message
Parameters:
-
combined_data
(Sequence[int, ...]
) –Whole sysex message including opening (
240
) and closing (247
) bytes -
source
(None | MidiIn
, default:None
) –The
MidiIn
instance that generated the message
combined_data
Whole sysex message including opening 240
and closing 247
bytes.
matches
matches(
type: None | Container[MidiType] | MidiType = None,
channel: None | Container[tuple[int, ...]] | tuple[int, ...] = None,
data1: None | Container[tuple[int, ...]] | tuple[int, ...] = None,
data2: None | Container[tuple[int, ...]] | tuple[int, ...] = None,
*,
combined_data: None | Container[tuple[int, ...]] | tuple[int, ...] = None
) -> bool
Checks if message's attributes match all provided attribute conditions:
-
If condition is
None
or omitted, it matches anything. -
If condition equals attribute, it matches the attribute.
-
If condition is a container and contains the attribute, it matches the attribute.
Use Not(condition)
to invert condition matching.
Returns:
-
bool
–True
if all attributes match,False
if any does not match