usb_midi
– MIDI over USB¶
The usb_midi
module contains classes to transmit and receive MIDI messages over USB.
-
usb_midi.
ports
:Tuple[Union[PortIn, PortOut], ...]¶ Tuple of all MIDI ports. Each item is ether
PortIn
orPortOut
.
-
class
usb_midi.
PortIn
¶ Receives midi commands over USB
You cannot create an instance of
usb_midi.PortIn
.PortIn objects are constructed for every corresponding entry in the USB descriptor and added to the
usb_midi.ports
tuple.-
read
(self, nbytes: Optional[int] = None)¶ Read characters. If
nbytes
is specified then read at most that many bytes. Otherwise, read everything that arrives until the connection times out. Providing the number of bytes expected is highly recommended because it will be faster.Returns: Data read Return type: bytes or None
-
-
class
usb_midi.
PortOut
¶ Sends midi messages to a computer over USB
You cannot create an instance of
usb_midi.PortOut
.PortOut objects are constructed for every corresponding entry in the USB descriptor and added to the
usb_midi.ports
tuple.