Commit 0861c7d6 authored by norvell's avatar norvell
Browse files

Update test_renderer.py to use MLD and also mark with create_ref to be bundled with other tests

parent 3cbe209b
Loading
Loading
Loading
Loading
Loading
+42 −22
Original line number Diff line number Diff line
@@ -42,11 +42,11 @@ from .utils import *
##############################################################################
""" Ambisonics """


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_ambisonics(test_info, in_fmt, out_fmt, frame_size):
def test_ambisonics(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        in_fmt,
@@ -55,10 +55,11 @@ def test_ambisonics(test_info, in_fmt, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt, frame_size):
def test_ambisonics_binaural_static(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        in_fmt,
@@ -67,12 +68,13 @@ def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_ambisonics_binaural_headrotation(
    test_info, in_fmt, out_fmt, trj_file, frame_size
    record_property, test_info, in_fmt, out_fmt, trj_file, frame_size, get_mld, get_mld_lim
):
    run_renderer(
        test_info,
@@ -86,10 +88,11 @@ def test_ambisonics_binaural_headrotation(
""" Multichannel """


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_multichannel(test_info, in_fmt, out_fmt, frame_size):
def test_multichannel(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        in_fmt,
@@ -98,10 +101,11 @@ def test_multichannel(test_info, in_fmt, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, frame_size):
def test_multichannel_binaural_static(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")

@@ -113,12 +117,13 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_multichannel_binaural_headrotation(
    test_info, in_fmt, out_fmt, trj_file, frame_size
    record_property, test_info, in_fmt, out_fmt, trj_file, frame_size, get_mld, get_mld_lim
):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")
@@ -135,10 +140,11 @@ def test_multichannel_binaural_headrotation(
""" ISM """


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_ism(test_info, in_fmt, out_fmt, frame_size):
def test_ism(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        in_fmt,
@@ -148,10 +154,11 @@ def test_ism(test_info, in_fmt, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_ism_binaural_static(test_info, in_fmt, out_fmt, frame_size):
def test_ism_binaural_static(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    try:
        in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt]
    except KeyError:
@@ -166,11 +173,12 @@ def test_ism_binaural_static(test_info, in_fmt, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file, frame_size):
def test_ism_binaural_headrotation(record_property, test_info, in_fmt, out_fmt, trj_file, frame_size, get_mld, get_mld_lim):
    try:
        in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt]
    except KeyError:
@@ -189,10 +197,11 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file, frame_s
""" MASA """


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_masa(test_info, in_fmt, out_fmt, frame_size):
def test_masa(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        in_fmt,
@@ -202,10 +211,11 @@ def test_masa(test_info, in_fmt, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_masa_binaural_static(test_info, in_fmt, out_fmt, frame_size):
def test_masa_binaural_static(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]:
        pytest.skip("Skipping binaural room outputs for MASA as unimplemented.")

@@ -218,11 +228,12 @@ def test_masa_binaural_static(test_info, in_fmt, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_masa_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file, frame_size):
def test_masa_binaural_headrotation(record_property, test_info, in_fmt, out_fmt, trj_file, frame_size, get_mld, get_mld_lim):
    if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]:
        pytest.skip("Skipping binaural room outputs for MASA as unimplemented.")

@@ -236,8 +247,9 @@ def test_masa_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file, frame_
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST_MASA_PREREND)
def test_masa_prerend(test_info, in_fmt):
def test_masa_prerend(record_property, test_info, in_fmt, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        "META",
@@ -249,10 +261,11 @@ def test_masa_prerend(test_info, in_fmt):
""" Custom loudspeaker layouts """


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS)
@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_custom_ls_input(test_info, in_layout, out_fmt, frame_size):
def test_custom_ls_input(record_property, test_info, in_layout, out_fmt, frame_size, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"),
@@ -261,9 +274,10 @@ def test_custom_ls_input(test_info, in_layout, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST)
@pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS)
def test_custom_ls_output(test_info, in_fmt, out_fmt):
def test_custom_ls_output(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        in_fmt,
@@ -271,9 +285,10 @@ def test_custom_ls_output(test_info, in_fmt, out_fmt):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST)
@pytest.mark.parametrize("in_fmt", CUSTOM_LS_TO_TEST)
def test_custom_ls_input_output(test_info, in_fmt, out_fmt):
def test_custom_ls_input_output(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_fmt}.txt"),
@@ -281,10 +296,11 @@ def test_custom_ls_input_output(test_info, in_fmt, out_fmt):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_custom_ls_input_binaural(test_info, in_layout, out_fmt, frame_size):
def test_custom_ls_input_binaural(record_property, test_info, in_layout, out_fmt, frame_size, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"),
@@ -293,12 +309,13 @@ def test_custom_ls_input_binaural(test_info, in_layout, out_fmt, frame_size):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_custom_ls_input_binaural_headrotation(
    test_info, in_layout, out_fmt, trj_file, frame_size
    record_property, test_info, in_layout, out_fmt, trj_file, frame_size, get_mld, get_mld_lim
):
    run_renderer(
        test_info,
@@ -312,10 +329,11 @@ def test_custom_ls_input_binaural_headrotation(
""" Metadata / scene description input """


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS)
@pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST)
@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST)
def test_metadata(test_info, in_fmt, out_fmt, frame_size):
def test_metadata(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        "META",
@@ -328,10 +346,11 @@ def test_metadata(test_info, in_fmt, out_fmt, frame_size):
""" non diegetic pan """


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", ["STEREO"])
@pytest.mark.parametrize("in_fmt", ["MONO"])
@pytest.mark.parametrize("non_diegetic_pan", ["0", "-30", "45", "90", "-90"])
def test_non_diegetic_pan_static(test_info, in_fmt, out_fmt, non_diegetic_pan):
def test_non_diegetic_pan_static(record_property, test_info, in_fmt, out_fmt, non_diegetic_pan, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        in_fmt,
@@ -340,10 +359,11 @@ def test_non_diegetic_pan_static(test_info, in_fmt, out_fmt, non_diegetic_pan):
    )


@pytest.mark.create_ref
@pytest.mark.parametrize("out_fmt", ["STEREO"])
@pytest.mark.parametrize("in_fmt", ["ISM1"])
@pytest.mark.parametrize("non_diegetic_pan", ["0", "-30", "45", "90", "-90"])
def test_non_diegetic_pan_ism_static(test_info, in_fmt, out_fmt, non_diegetic_pan):
def test_non_diegetic_pan_ism_static(record_property, test_info, in_fmt, out_fmt, non_diegetic_pan, get_mld, get_mld_lim):
    run_renderer(
        test_info,
        in_fmt,
+21 −8
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ def check_BE(


def run_renderer(
    record_property,
    test_info,
    in_fmt: str,
    out_fmt: str,
@@ -109,6 +110,8 @@ def run_renderer(
    binary_suffix: str = "",
    frame_size: Optional[str] = "20ms",
    hrtf_file: Optional[str] = None,
    get_mld = False, 
    mld_lim = 0,
) -> str:
    # prepare arguments and filepaths
    if trj_file is not None:
@@ -226,6 +229,16 @@ def run_renderer(
        # CUT creation mode will run a comparison with REF
        out_file_ref = str(OUTPUT_PATH_REF.joinpath(out_file_stem))

        if get_mld:
            output_differs, reason = cmp_pcm(out_file, out_file_ref, out_fmt, ref_fs, get_mld=get_mld, mld_lim=get_mld_lim)
            mld = 0
            if "MLD" in reason:
                mld = float(reason.split(':')[1].split()[0])
            record_property("MLD",mld)
            if output_differs:
                pytest.fail(f"Output differs: ({reason})")
        )
        else:
            try:
                ref, ref_fs = readfile(out_file_ref)
            except FileNotFoundError: