def time_signature(data: Union[FileIO, BufferedReader]) -> Tuple[int, Tuple[int, int, int, int], bytearray]:
length_bytes = bytearray(data.read(1))
length = int.from_bytes(length_bytes, "big")
if length != 0x04:
raise EventLengthError("Time Signature event has invalid length. Should be 4, value was {}".format(length))
data_bytes = bytearray(data.read(4)) # type: bytearray
numerator = data_bytes[0] # type: int
denominator = data_bytes[1] # type: int
clock_num = data_bytes[2]
ts_number = data_bytes[3]
return length, (numerator, denominator, clock_num, ts_number), data_bytes
评论列表
文章目录