:mod:`usb_midi` =============== .. py:module:: usb_midi .. autoapi-nested-parse:: Classes to transmit and receive MIDI messages over USB .. py:class:: PortIn Receives midi commands over USB .. method:: read(self, nbytes: Any = 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. :return: Data read :rtype: bytes or None .. method:: readinto(self, buf: Any, nbytes: Any = None) Read bytes into the ``buf``. If ``nbytes`` is specified then read at most that many bytes. Otherwise, read at most ``len(buf)`` bytes. :return: number of bytes read and stored into ``buf`` :rtype: bytes or None .. py:class:: PortOut Sends midi messages to a computer over USB .. method:: write(self, buf: Any) Write the buffer of bytes to the bus. :return: the number of bytes written :rtype: int or None