Skip to content

Commit

Permalink
add repr
Browse files Browse the repository at this point in the history
  • Loading branch information
todbot committed Aug 5, 2024
1 parent 20b9e41 commit 30633c3
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions tmidi.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,26 @@ def _is_channel_message(status_byte):
return status_byte >= NOTE_OFF and status_byte < SYSEX


def _read_n_bytes(port, buf, dest, num_bytes):
while num_bytes:
if port.readinto(buf):
dest.append(buf[0])
num_bytes -= 1


def _read_byte_works(port):
while True:
buf = port.read(1)
if buf:
return buf[0]


def _read_byte(port):
while not (buf := port.read(1)):
pass
return buf[0]


# def _read_n_bytes(port, buf, dest, num_bytes):
# while num_bytes:
# if port.readinto(buf):
# dest.append(buf[0])
# num_bytes -= 1


# def _read_byte_works(port):
# while True:
# buf = port.read(1)
# if buf:
# return buf[0]


class Message:
"""
MIDI Message.
Expand Down Expand Up @@ -205,6 +205,9 @@ def __bytes__(self):
return bytes([status_byte, self.data0])
return bytes([status_byte])

def __repr__(self):
return self.__str__()

# pylint: disable=consider-using-f-string
def __str__(self):
mtype = self.type
Expand Down

0 comments on commit 30633c3

Please sign in to comment.