Commit 778ee967 authored by Jan Kiene's avatar Jan Kiene
Browse files

formatting + linter complaints

parent eae9faa0
Loading
Loading
Loading
Loading
+27 −8
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts"))
import numpy as np
import pyaudio3dtools
import pyivastest

# Hack to resolve import when using from command line or from within scripts.
try:
    from .constants import ODG_PATTERN_PQEVALAUDIO
@@ -38,7 +39,7 @@ def cmp_pcm(
    odg_ref=None,
    ref_jbm_tf: Optional[Path] = None,
    cut_jbm_tf: Optional[Path] = None,
) -> (int, str):
) -> tuple[int, str]:
    """
    Compare 2 PCM files for bitexactness
    """
@@ -80,8 +81,12 @@ def cmp_pcm(
    if allow_differing_lengths:
        # to allow for MLD comparison, pad shorter file
        max_len = max(s1.shape[0], s2.shape[0])
        s1 = np.pad(s1,((0,max_len - s1.shape[0]),(0,0)),mode='constant',constant_values=0)
        s2 = np.pad(s2,((0,max_len - s2.shape[0]),(0,0)),mode='constant',constant_values=0)
        s1 = np.pad(
            s1, ((0, max_len - s1.shape[0]), (0, 0)), mode="constant", constant_values=0
        )
        s2 = np.pad(
            s2, ((0, max_len - s2.shape[0]), (0, 0)), mode="constant", constant_values=0
        )
    elif s1.shape != s2.shape:
        print(
            f"file size in samples: file 1 = {s1.shape[0]},",
@@ -149,13 +154,23 @@ def cmp_pcm(
                32767,
            ).astype(np.int16)

        pqeval_output = pqevalaudio_wrapper(odg_files[odg_input], odg_files[odg_ref], 48000)
        pqeval_output = pqevalaudio_wrapper(
            odg_files[odg_input], odg_files[odg_ref], 48000
        )
        match_odg = re.search(ODG_PATTERN_PQEVALAUDIO, pqeval_output)
        try:
            odg_ref = float(match_odg.groups()[0])
        except AttributeError:
            raise OdgParsingFailed("Could not get Odg for ref signal")

        pqeval_output = pqevalaudio_wrapper(odg_files[odg_input], odg_files[odg_test], 48000)
        pqeval_output = pqevalaudio_wrapper(
            odg_files[odg_input], odg_files[odg_test], 48000
        )
        match_odg = re.search(ODG_PATTERN_PQEVALAUDIO, pqeval_output)
        try:
            odg_test = float(match_odg.groups()[0])
        except AttributeError:
            raise OdgParsingFailed("Could not get Odg for test signal")

        odg = odg_test - odg_ref  # Todo: store both rather than difference?

@@ -166,6 +181,10 @@ def cmp_pcm(
    return output_differs, reason


class OdgParsingFailed(Exception):
    pass


def pqevalaudio_wrapper(
    ref_sig: np.ndarray,
    eval_sig: np.ndarray,