usb_midi

Classes to transmit and receive MIDI messages over USB

class usb_midi.PortIn

Receives midi commands over USB

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
readinto(self, buf: WriteableBuffer, nbytes: Optional[int] = None)

Read bytes into the buf. If nbytes is specified then read at most that many bytes. Otherwise, read at most len(buf) bytes.

Returns:number of bytes read and stored into buf
Return type:bytes or None
class usb_midi.PortOut

Sends midi messages to a computer over USB

write(self, buf: ReadableBuffer)

Write the buffer of bytes to the bus.

Returns:the number of bytes written
Return type:int or None