Return Type Format of Python pygame.midi.Input.read()

156 Views Asked by At

I've searched a lot to find out what does the pygame.midi.Input.read() returns.

In every documentation I found they say it's

[[status,data1,data2,data3],timestamp],...]

But what the hell is data1, data2, data3?

Someone, please explain what each list item's type and use in relation to MIDI data

1

There are 1 best solutions below

0
Rabbid76 On

The status and data bytes are specified in the MIDI specification. A short summery can also be found at Music - Midi - Status and Data Bytes.
In the Pygame documentation of pygame.midi.read the data structure of the return value is defined:

Returns: the format for midi_event_list is [[[status, data1, data2, data3], timestamp], ...]

Pygame uses the PortMidi (Platform Independent Library for MIDI I/O), where further documentation can be found.

There is also an example in the Pygame repository how to use the midi module: pygame/examples/midi.py

And there are some other StackOverflow questions related to this topic: