def handle_message(self, bytestr): status = miditools.byte(bytestr[0]) if 0x80 <= status <= 0xEF: mtyp, chan = miditools.nibbles(status) return self.handle_channelmessage(mtyp, chan, bytestr[1:]) elif 0xF0 <= status <= 0xFF: return self.handle_systemmessage(status, bytestr[1:]) else: return ValueError()
def test_nibbles(): assert miditools.nibbles(0xAE) == (0x0A, 0x0E) assert miditools.nibbles('\x5C') == (0x05, 0x0C)