diff --git a/wavinfo/wave_bext_reader.py b/wavinfo/wave_bext_reader.py index d0a1f3c..747353d 100644 --- a/wavinfo/wave_bext_reader.py +++ b/wavinfo/wave_bext_reader.py @@ -8,17 +8,20 @@ class WavBextReader: """ Read Broadcast-WAV extended metadata. :param bext_data: The bytes-like data. - :param encoding: The encoding to use when decoding the text fields of the - BEXT metadata scope. According to EBU Rec 3285 this shall be ASCII. + :param encoding: The encoding to use when decoding the text fields of + the BEXT metadata scope. According to EBU Rec 3285 this shall be + ASCII. """ - packstring = "<256s" + "32s" + "32s" + "10s" + "8s" + "QH" + "64s" + "hhhhh" + "180s" + packstring = "<256s" + "32s" + "32s" + "10s" + "8s" + "QH" + "64s" + \ + "hhhhh" + "180s" rest_starts = struct.calcsize(packstring) unpacked = struct.unpack(packstring, bext_data[:rest_starts]) def sanitize_bytes(b : bytes) -> str: # honestly can't remember why I'm stripping nulls this way - 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] decoded = trimmed.decode(encoding) return decoded @@ -50,8 +53,8 @@ class WavBextReader: #: BEXT version. self.version : int = unpacked[6] - #: SMPTE 330M UMID of this audio file, 64 bytes are allocated though the UMID - #: may only be 32 bytes long. + #: SMPTE 330M UMID of this audio file, 64 bytes are allocated though + #: the UMID may only be 32 bytes long. self.umid : Optional[bytes] = None #: EBU R128 Integrated loudness, in LUFS. diff --git a/wavinfo/wave_cues_reader.py b/wavinfo/wave_cues_reader.py index 8d47a07..9391631 100644 --- a/wavinfo/wave_cues_reader.py +++ b/wavinfo/wave_cues_reader.py @@ -114,7 +114,8 @@ class CueEntry(NamedTuple): @classmethod def read(cls, data: bytes) -> 'CueEntry': assert len(data) == cls.format_size(), \ - f"cue data size incorrect, expected {calcsize(cls.Format)} found {len(data)}" + (f"cue data size incorrect, expected {calcsize(cls.Format)} " + "found {len(data)}") parsed = unpack(cls.Format, data) diff --git a/wavinfo/wave_dbmd_reader.py b/wavinfo/wave_dbmd_reader.py index cfd19ca..f37c91b 100644 --- a/wavinfo/wave_dbmd_reader.py +++ b/wavinfo/wave_dbmd_reader.py @@ -208,8 +208,8 @@ class DolbyDigitalPlusMetadata: class PreferredDownMixMode(Enum): """ - Indicates the creating engineer's preference of what the receiver should - downmix. + Indicates the creating engineer's preference of what the receiver + should downmix. ยง 4.3.8.1 """ NOT_INDICATED = 0b00 @@ -386,7 +386,8 @@ class DolbyDigitalPlusMetadata: # downmix_mode, ltrt_center_downmix_level, ltrt_surround_downmix_level def ext_bsi1_word2(b): - return DolbyDigitalPlusMetadata.PreferredDownMixMode(b & 0xC0 >> 6), \ + return DolbyDigitalPlusMetadata\ + .PreferredDownMixMode(b & 0xC0 >> 6), \ DolbyDigitalPlusMetadata.DownMixLevelToken(b & 0x38 >> 3), \ DolbyDigitalPlusMetadata.DownMixLevelToken(b & 0x7) @@ -423,14 +424,19 @@ class DolbyDigitalPlusMetadata: pid = program_id(buffer[0]) lfe_on, bitstream_mode, audio_coding_mode = program_info(buffer[1]) ddplus_reserved1(buffer[2:2]) - center_downmix_level, surround_downmix_level, dolby_surround_encoded = surround_config(buffer[4]) - langcode_present, copyright_bitstream, original_bitstream, dialnorm = dialnorm_info(buffer[5]) + center_downmix_level, surround_downmix_level, \ + dolby_surround_encoded = surround_config(buffer[4]) + langcode_present, copyright_bitstream, original_bitstream, \ + dialnorm = dialnorm_info(buffer[5]) langcode = langcod(buffer[6]) prod_info_exists, mixlevel, roomtype = audio_prod_info(buffer[7]) - loro_center_downmix_level, loro_surround_downmix_level = ext_bsi1_word1(buffer[8]) - downmix_mode, ltrt_center_downmix_level, ltrt_surround_downmix_level = ext_bsi1_word2(buffer[9]) - surround_ex_mode, dolby_headphone_encoded, ad_converter_type = ext_bsi2_word1(buffer[10]) + loro_center_downmix_level, \ + loro_surround_downmix_level = ext_bsi1_word1(buffer[8]) + downmix_mode, ltrt_center_downmix_level, \ + ltrt_surround_downmix_level = ext_bsi1_word2(buffer[9]) + surround_ex_mode, dolby_headphone_encoded, \ + ad_converter_type = ext_bsi2_word1(buffer[10]) ddplus_reserved2(buffer[11:14]) compression = compr1(buffer[14]) @@ -494,8 +500,9 @@ class DolbyAtmosMetadata: @classmethod def load(cls, data: bytes): - assert len(data) == cls.SEGMENT_LENGTH, "DolbyAtmosMetadata segment "\ - "is incorrect length, expected %i actual was %i" % (cls.SEGMENT_LENGTH, len(data)) + assert len(data) == cls.SEGMENT_LENGTH, ("DolbyAtmosMetadata segment " + "is incorrect length, " + "expected %i actual was %i") % (cls.SEGMENT_LENGTH, len(data)) h = BytesIO(data) @@ -513,7 +520,9 @@ class DolbyAtmosMetadata: warp_mode = a_val & 0x7 return DolbyAtmosMetadata(tool_name=toolname, - tool_version=(major, minor, fix), warp_mode=DolbyAtmosMetadata.WarpMode(warp_mode)) + tool_version=(major, minor, fix), + warp_mode=DolbyAtmosMetadata\ + .WarpMode(warp_mode)) @dataclass @@ -521,7 +530,8 @@ class DolbyAtmosSupplementalMetadata: """ Dolby Atmos supplemental metadata segment. - https://github.com/DolbyLaboratories/dbmd-atmos-parser/blob/master/dbmd_atmos_parse/src/dbmd_atmos_parse.c + https://github.com/DolbyLaboratories/dbmd-atmos-parser/blob/ + master/dbmd_atmos_parse/src/dbmd_atmos_parse.c """ class BinauralRenderMode(Enum): @@ -617,7 +627,8 @@ class WavDolbyMetadataReader: else: seg_size = unpack(" List[DolbyDigitalPlusMetadata]: """