mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-01 17:30:41 +00:00
autopep8
This commit is contained in:
@@ -5,27 +5,27 @@ from typing import Tuple, NamedTuple, List
|
|||||||
|
|
||||||
|
|
||||||
class WaveSmplLoop(NamedTuple):
|
class WaveSmplLoop(NamedTuple):
|
||||||
ident: int
|
ident: int
|
||||||
loop_type: int
|
loop_type: int
|
||||||
start: int
|
start: int
|
||||||
end: int
|
end: int
|
||||||
fraction: int
|
fraction: int
|
||||||
repetition_count: int
|
repetition_count: int
|
||||||
|
|
||||||
|
|
||||||
class WaveSmplReader:
|
class WaveSmplReader:
|
||||||
|
|
||||||
def __init__(self, smpl_data: bytes):
|
def __init__(self, smpl_data: bytes):
|
||||||
"""
|
"""
|
||||||
Read sampler metadata from smpl chunk.
|
Read sampler metadata from smpl chunk.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
header_field_fmt = "<IIIIIIbbbbII"
|
header_field_fmt = "<IIIIIIbbbbII"
|
||||||
loop_field_fmt = "<IIIIII"
|
loop_field_fmt = "<IIIIII"
|
||||||
header_size = struct.calcsize(header_field_fmt)
|
header_size = struct.calcsize(header_field_fmt)
|
||||||
loop_size = struct.calcsize(loop_field_fmt)
|
loop_size = struct.calcsize(loop_field_fmt)
|
||||||
|
|
||||||
unpacked_data = struct.unpack(header_field_fmt,
|
unpacked_data = struct.unpack(header_field_fmt,
|
||||||
smpl_data[0:header_size])
|
smpl_data[0:header_size])
|
||||||
|
|
||||||
#: The MIDI Manufacturer's Association code for the sampler manufactuer,
|
#: The MIDI Manufacturer's Association code for the sampler manufactuer,
|
||||||
@@ -39,7 +39,7 @@ class WaveSmplReader:
|
|||||||
#: The number of nanoseconds in one audio frame.
|
#: The number of nanoseconds in one audio frame.
|
||||||
self.sample_period: int = unpacked_data[2]
|
self.sample_period: int = unpacked_data[2]
|
||||||
|
|
||||||
#: The MIDI note number for the loops in this sample
|
#: The MIDI note number for the loops in this sample
|
||||||
self.midi_note: int = unpacked_data[3]
|
self.midi_note: int = unpacked_data[3]
|
||||||
|
|
||||||
#: The number of semitones above the MIDI note the loops tune for.
|
#: The number of semitones above the MIDI note the loops tune for.
|
||||||
@@ -48,22 +48,22 @@ class WaveSmplReader:
|
|||||||
#: SMPTE timecode format, one of (0, 24, 25, 29, 30)
|
#: SMPTE timecode format, one of (0, 24, 25, 29, 30)
|
||||||
self.smpte_format: int = unpacked_data[5]
|
self.smpte_format: int = unpacked_data[5]
|
||||||
|
|
||||||
#: The SMPTE offset to apply, as a tuple of four ints representing
|
#: The SMPTE offset to apply, as a tuple of four ints representing
|
||||||
#: hh, mm, ss, ff
|
#: hh, mm, ss, ff
|
||||||
self.smpte_offset: Tuple[int, int, int, int] = unpacked_data[6:10]
|
self.smpte_offset: Tuple[int, int, int, int] = unpacked_data[6:10]
|
||||||
|
|
||||||
loop_count = unpacked_data[10]
|
loop_count = unpacked_data[10]
|
||||||
sampler_udata_length = unpacked_data[11]
|
sampler_udata_length = unpacked_data[11]
|
||||||
|
|
||||||
#: List of loops in the file.
|
#: List of loops in the file.
|
||||||
self.sample_loops: List[WaveSmplLoop] = []
|
self.sample_loops: List[WaveSmplLoop] = []
|
||||||
|
|
||||||
loop_buffer = smpl_data[header_field_fmt:
|
loop_buffer = smpl_data[header_field_fmt:
|
||||||
header_field_fmt + loop_size * loop_count]
|
header_field_fmt + loop_size * loop_count]
|
||||||
|
|
||||||
for unpacked_loop in struct.iter_unpack(loop_field_fmt, loop_buffer):
|
for unpacked_loop in struct.iter_unpack(loop_field_fmt, loop_buffer):
|
||||||
self.sample_loops.append(WaveSmplLoop(
|
self.sample_loops.append(WaveSmplLoop(
|
||||||
ident=unpacked_loop[0],
|
ident=unpacked_loop[0],
|
||||||
loop_type=unpacked_loop[1],
|
loop_type=unpacked_loop[1],
|
||||||
start=unpacked_loop[2],
|
start=unpacked_loop[2],
|
||||||
end=unpacked_loop[3],
|
end=unpacked_loop[3],
|
||||||
@@ -72,7 +72,5 @@ class WaveSmplReader:
|
|||||||
|
|
||||||
#: Sampler-specific user data.
|
#: Sampler-specific user data.
|
||||||
self.sampler_udata: bytes = smpl_data[
|
self.sampler_udata: bytes = smpl_data[
|
||||||
header_field_fmt + loop_size * loop_count :
|
header_field_fmt + loop_size * loop_count:
|
||||||
header_field_fmt + loop_size * loop_count + sampler_udata_length]
|
header_field_fmt + loop_size * loop_count + sampler_udata_length]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user