mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-02 18:00:41 +00:00
Added some type annotations for doc help
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
from typing import Union
|
|
||||||
import binascii
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
@@ -13,7 +11,7 @@ class UMIDParser:
|
|||||||
|
|
||||||
This implementation is based on SMPTE ST 330:2011
|
This implementation is based on SMPTE ST 330:2011
|
||||||
"""
|
"""
|
||||||
def __init__(self, raw_umid: bytearray):
|
def __init__(self, raw_umid: bytes):
|
||||||
self.raw_umid = raw_umid
|
self.raw_umid = raw_umid
|
||||||
#
|
#
|
||||||
# @property
|
# @property
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import struct
|
import struct
|
||||||
import binascii
|
|
||||||
from .umid_parser import UMIDParser
|
from .umid_parser import UMIDParser
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
class WavBextReader:
|
class WavBextReader:
|
||||||
def __init__(self, bext_data, encoding):
|
def __init__(self, bext_data, encoding):
|
||||||
@@ -16,44 +16,44 @@ class WavBextReader:
|
|||||||
rest_starts = struct.calcsize(packstring)
|
rest_starts = struct.calcsize(packstring)
|
||||||
unpacked = struct.unpack(packstring, bext_data[:rest_starts])
|
unpacked = struct.unpack(packstring, bext_data[:rest_starts])
|
||||||
|
|
||||||
def sanitize_bytes(b):
|
def sanitize_bytes(b : bytes) -> str:
|
||||||
first_null = next((index for index, byte in enumerate(b) if byte == 0), None)
|
first_null = next((index for index, byte in enumerate(b) if byte == 0), None)
|
||||||
trimmed = b if first_null is None else b[:first_null]
|
trimmed = b if first_null is None else b[:first_null]
|
||||||
decoded = trimmed.decode(encoding)
|
decoded = trimmed.decode(encoding)
|
||||||
return decoded
|
return decoded
|
||||||
|
|
||||||
#: Description. A free-text field up to 256 characters long.
|
#: Description. A free-text field up to 256 characters long.
|
||||||
self.description = sanitize_bytes(unpacked[0])
|
self.description : str = sanitize_bytes(unpacked[0])
|
||||||
#: Originator. Usually the name of the encoding application, sometimes
|
#: Originator. Usually the name of the encoding application, sometimes
|
||||||
#: a artist name.
|
#: a artist name.
|
||||||
self.originator = sanitize_bytes(unpacked[1])
|
self.originator : str = sanitize_bytes(unpacked[1])
|
||||||
#: A unique identifier for the file, a serial number.
|
#: A unique identifier for the file, a serial number.
|
||||||
self.originator_ref = sanitize_bytes(unpacked[2])
|
self.originator_ref : str = sanitize_bytes(unpacked[2])
|
||||||
#: Date of the recording, in the format YYY-MM-DD
|
#: Date of the recording, in the format YYY-MM-DD
|
||||||
self.originator_date = sanitize_bytes(unpacked[3])
|
self.originator_date : str = sanitize_bytes(unpacked[3])
|
||||||
#: Time of the recording, in the format HH:MM:SS.
|
#: Time of the recording, in the format HH:MM:SS.
|
||||||
self.originator_time = sanitize_bytes(unpacked[4])
|
self.originator_time : str = sanitize_bytes(unpacked[4])
|
||||||
#: The sample offset of the start of the file relative to an
|
#: The sample offset of the start of the file relative to an
|
||||||
#: epoch, usually midnight the day of the recording.
|
#: epoch, usually midnight the day of the recording.
|
||||||
self.time_reference = unpacked[5]
|
self.time_reference : int = unpacked[5]
|
||||||
#: A variable-length text field containing a list of processes and
|
#: A variable-length text field containing a list of processes and
|
||||||
#: and conversions performed on the file.
|
#: and conversions performed on the file.
|
||||||
self.coding_history = sanitize_bytes(bext_data[rest_starts:])
|
self.coding_history : str = sanitize_bytes(bext_data[rest_starts:])
|
||||||
#: BEXT version.
|
#: BEXT version.
|
||||||
self.version = unpacked[6]
|
self.version : int = unpacked[6]
|
||||||
#: SMPTE 330M UMID of this audio file, 64 bytes are allocated though the UMID
|
#: SMPTE 330M UMID of this audio file, 64 bytes are allocated though the UMID
|
||||||
#: may only be 32 bytes long.
|
#: may only be 32 bytes long.
|
||||||
self.umid = None
|
self.umid : Optional[bytes] = None
|
||||||
#: EBU R128 Integrated loudness, in LUFS.
|
#: EBU R128 Integrated loudness, in LUFS.
|
||||||
self.loudness_value = None
|
self.loudness_value : Optional[float] = None
|
||||||
#: EBU R128 Loudness rante, in LUFS.
|
#: EBU R128 Loudness rante, in LUFS.
|
||||||
self.loudness_range = None
|
self.loudness_range : Optional[float] = None
|
||||||
#: True peak level, in dBFS TP
|
#: True peak level, in dBFS TP
|
||||||
self.max_true_peak = None
|
self.max_true_peak : Optional[float] = None
|
||||||
#: EBU R128 Maximum momentary loudness, in LUFS
|
#: EBU R128 Maximum momentary loudness, in LUFS
|
||||||
self.max_momentary_loudness = None
|
self.max_momentary_loudness : Optional[float] = None
|
||||||
#: EBU R128 Maximum short-term loudness, in LUFS.
|
#: EBU R128 Maximum short-term loudness, in LUFS.
|
||||||
self.max_shortterm_loudness = None
|
self.max_shortterm_loudness : Optional[float] = None
|
||||||
|
|
||||||
if self.version > 0:
|
if self.version > 0:
|
||||||
self.umid = unpacked[7]
|
self.umid = unpacked[7]
|
||||||
|
|||||||
Reference in New Issue
Block a user