adafruit_usb_host_midi
CircuitPython USB host driver for MIDI devices
Author(s): Scott Shawcroft
- class adafruit_usb_host_midi.MIDI(device, timeout=None)
Stream-like MIDI device for use with
adafruit_midiand similar upstream MIDI parser libraries.- Parameters:
device – a
usb.core.Deviceobject which implementsread(endpoint, buffer)andwrite(endpoint,buffer)timeout (float) – timeout in seconds to wait for read or write operation to succeeds. Default to None, i.e. reads and writes will block.
- read(size)
Read bytes. If
nbytesis 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. If no bytes are read, returnNone.Note
When no bytes are read due to a timeout, this function returns
None. This matches the behavior ofio.RawIOBase.readin Python 3, but differs from pyserial which returnsb''in that situation.- Returns:
Data read
- Return type:
bytes or None