Commit 306455c3 authored by Jan Kiene's avatar Jan Kiene
Browse files

add mld_playback_level argument

parent efe53129
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -248,7 +248,8 @@ def compare(
    test_start_offset_ms: int = 0,
    ref_jbm_tf: Optional[Union[Path, str]] = None,
    test_jbm_tf: Optional[Union[Path, str]] = None,
    handle_differing_lengths: HandleDifferingLengths = "fail",
    handle_differing_lengths: HandleDifferingLengths = HandleDifferingLengths.FAIL,
    mld_playback_level: float = 92.0,
) -> dict:
    """Compare two audio arrays

@@ -390,6 +391,8 @@ def compare(
                # wav-diff return code is 1 if differences are found which
                # would cause parse_wav_diff to raise an Exception on these cases
                "--no-fail",
                "--mld-playback-level",
                f"{mld_playback_level}",
                str(tmpfile_ref),
                str(tmpfile_test),
            ]
+8 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ def cmp_pcm(
    cut_jbm_tf: Optional[Path] = None,
    quiet: Optional[bool] = False,
    scalefac: int = 1,
    mld_playback_level: float = 92.0,
    split_idx: np.ndarray = np.empty(0),
) -> tuple[List[int], List[str]]:
    """
@@ -111,6 +112,7 @@ def cmp_pcm(
            ref_jbm_tf=ref_jbm_tf,
            test_jbm_tf=cut_jbm_tf,
            handle_differing_lengths=handle_differing_lengths,
            mld_playback_level=mld_playback_level,
        )

        output_differs = 0
@@ -277,6 +279,12 @@ if __name__ == "__main__":
        dest="scalefac",
        help="Scale factor to be applied before comparing the output. Useful when input scaling has been applied.",
    )
    parser.add_argument(
        "--mld-playback-level",
        type=float,
        help="Playback level arg for MLD in wav-diff",
        default=92.0,
    )
    parser.add_argument("--quiet", action="store_true")
    args = vars(parser.parse_args())

+4 −5
Original line number Diff line number Diff line
@@ -639,7 +639,7 @@ def run_test(
            odg_ref=odg_ref,
            ref_jbm_tf=ref_tracefile_dec,
            cut_jbm_tf=dut_tracefile_dec,
            scalefac=test_info.config.option.scalefac,
            mld_playback_level=test_info.config.option.mld_playback_level,
            split_idx=split_idx,
        )

@@ -669,7 +669,7 @@ def run_test(
                odg_ref=odg_ref,
                ref_jbm_tf=ref_tracefile_dec,
                cut_jbm_tf=dut_tracefile_dec,
                scalefac=test_info.config.option.scalefac,
                mld_playback_level=test_info.config.option.mld_playback_level,
                split_idx=split_idx,
            )
            output_differs_parts += output_differs_splits
@@ -725,9 +725,8 @@ def run_test(
            if this_meta_differs == False:
                if dut_metadata_file.suffix == ".met":
                    this_meta_differs = check_masa_meta_diff(
                        ref=ref_metadata_file,
                        dut=dut_metadata_file,
                        print_stdout=True)
                        ref=ref_metadata_file, dut=dut_metadata_file, print_stdout=True
                    )
                else:
                    if not filecmp.cmp(dut_metadata_file, ref_metadata_file):
                        print("Output metadata differs for file: " + md_file)
+2 −2
Original line number Diff line number Diff line
@@ -1348,7 +1348,7 @@ def sba_dec(
            odg_input=odg_input,
            odg_test=odg_test,
            odg_ref=odg_ref,
            scalefac=test_info.config.option.scalefac,
            mld_playback_level=test_info.config.option.mld_playback_level,
            split_idx=split_idx,
        )

@@ -1376,7 +1376,7 @@ def sba_dec(
                odg_input=odg_input,
                odg_test=odg_test,
                odg_ref=odg_ref,
                scalefac=test_info.config.option.scalefac,
                mld_playback_level=test_info.config.option.mld_playback_level,
                split_idx=split_idx,
            )
            output_differs_parts += output_differs_splits
+11 −0
Original line number Diff line number Diff line
@@ -317,6 +317,14 @@ def pytest_addoption(parser):
        default=1,
    )

    parser.addoption(
        "--mld-playback-level",
        action="store",
        help="Playback level arg for MLD calulcation.",
        type=float,
        default=92.0,
    )

    parser.addoption(
        "--split-comparison",
        action="store_true",
@@ -449,6 +457,7 @@ def test_info(request):
    if hasattr(request, "error"):
        pytest.fail(request.error)


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    # Use hook to catch exceptions
@@ -464,6 +473,7 @@ def pytest_runtest_makereport(item, call):
            # Capture exception in test_info
            test_info.error = str(call.excinfo.value)


@pytest.fixture(scope="session")
def split_comparison(request):
    return request.config.option.split_comparison
@@ -1265,6 +1275,7 @@ def compare_dmx_signals(ref_dmx_files, dut_dmx_files, fs) -> dict:
                in_fs=fs * 1000,
            )

            # TODO: needs mld-playback-level
            dmx_differs, reason = cmp_pcm(
                dmx_file_ref_tmp.name,
                dmx_file_dut_tmp.name,
Loading