Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
todbot committed May 9, 2024
1 parent c1bef12 commit 20b9e41
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tmidi.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def _read_byte_works(port):
buf = port.read(1)
if buf:
return buf[0]
print("boop", buf)


def _read_byte(port):
Expand Down Expand Up @@ -210,13 +209,14 @@ def __bytes__(self):
def __str__(self):
mtype = self.type
type_str = "Message(" + _MSG_TYPE_NAMES[mtype]
ch_str = "ch:%d" % self.channel if _is_channel_message(mtype) else "-"
if mtype == PITCH_BEND:
return "%s %d)" % (type_str, self.pitch_bend)
return "%s %s %d)" % (type_str, ch_str, self.pitch_bend)
if mtype in _LEN_2_MESSAGES:
return "%s %d %d)" % (type_str, self.data0, self.data1)
return "%s %s %d %d)" % (type_str, ch_str, self.data0, self.data1)
if mtype in _LEN_1_MESSAGES:
return "%s %d)" % (type_str, self.data0)
return type_str
return "%s %s %d)" % (type_str, ch_str, self.data0)
return "%s)" % type_str

@property
def note(self):
Expand Down Expand Up @@ -304,7 +304,7 @@ def receive(self):
self._error_count += 1
return None

message = Message()
message = Message(status_byte)

# Is this a channel message, if so, let's figure out the right
# message type and set the message's channel property.
Expand All @@ -314,8 +314,6 @@ def receive(self):
# Mask off the channel nibble.
message.type = status_byte & 0xF0
message.channel = status_byte & 0x0F
else:
message.type = status_byte

# Read the appropriate number of bytes for each message type.
if message.type in _LEN_2_MESSAGES:
Expand Down

0 comments on commit 20b9e41

Please sign in to comment.