Commit af502fb0 authored by emerit's avatar emerit
Browse files

add renderer tests

parent fe96f565
Loading
Loading
Loading
Loading
+91 −0
Original line number Diff line number Diff line
@@ -55,6 +55,14 @@ def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt, framing_5ms):
        is_comparetest=True,
    )
    
    compare_renderer_vs_renderer_with_binary_hrtf(
        test_info,
        in_fmt,
        out_fmt,
        framing_5ms=(framing_5ms == "5ms"),
        is_comparetest=True,
    )


@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@@ -72,6 +80,16 @@ def test_ambisonics_binaural_headrotation(
        is_comparetest=True,
    )
    
    compare_renderer_vs_renderer_with_binary_hrtf(
        test_info,
        in_fmt,
        out_fmt,
        trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
        framing_5ms=(framing_5ms == "5ms"),
        is_comparetest=True,
    )



""" Multichannel """

@@ -97,6 +115,14 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, framing_5ms):
        is_comparetest=True,
    )
    
    compare_renderer_vs_renderer_with_binary_hrtf(
        test_info,
        in_fmt,
        out_fmt,
        framing_5ms=(framing_5ms == "5ms"),
        is_comparetest=True,
    )


@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@@ -117,6 +143,15 @@ def test_multichannel_binaural_headrotation(
        is_comparetest=True,
    )
    
    compare_renderer_vs_renderer_with_binary_hrtf(
        test_info,
        in_fmt,
        out_fmt,
        trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
        framing_5ms=(framing_5ms == "5ms"),
        is_comparetest=True,
    )


""" ISM """

@@ -148,6 +183,17 @@ def test_ism_binaural_static(test_info, in_fmt, out_fmt, framing_5ms):
        is_comparetest=True,
    )
    
    if (out_fmt != OUTPUT_FORMATS_BINAURAL[2] ):
        compare_renderer_vs_renderer_with_binary_hrtf(
            test_info,
            in_fmt,
            out_fmt,
            in_meta_files=in_meta_files,
            framing_5ms=(framing_5ms == "5ms"),
            is_comparetest=True,
        )



@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@@ -170,6 +216,17 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file, framing
        is_comparetest=True,
    )
    
    if (out_fmt != OUTPUT_FORMATS_BINAURAL[2] ):
        compare_renderer_vs_renderer_with_binary_hrtf(
            test_info,
            in_fmt,
            out_fmt,
            trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
            in_meta_files=in_meta_files,
            framing_5ms=(framing_5ms == "5ms"),
            is_comparetest=True,
        )


""" MASA """

@@ -197,6 +254,14 @@ def test_masa_binaural_static(test_info, in_fmt, out_fmt, framing_5ms):
        framing_5ms=(framing_5ms == "5ms"),
    )
    
    compare_renderer_vs_renderer_with_binary_hrtf(
        test_info,
        in_fmt,
        out_fmt,
        in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt],
        framing_5ms=(framing_5ms == "5ms"),
    )


@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@@ -215,6 +280,15 @@ def test_masa_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file, framin
        framing_5ms=(framing_5ms == "5ms"),
    )
    
    compare_renderer_vs_renderer_with_binary_hrtf(
        test_info,
        in_fmt,
        out_fmt,
        trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
        in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt],
        framing_5ms=(framing_5ms == "5ms"),
    )


""" Custom loudspeaker layouts """

@@ -264,6 +338,14 @@ def test_custom_ls_input_binaural(test_info, in_layout, out_fmt, framing_5ms):
        is_comparetest=True,
    )
    
    compare_renderer_vs_renderer_with_binary_hrtf(
        test_info,
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"),
        out_fmt,
        framing_5ms=(framing_5ms == "5ms"),
        is_comparetest=True,
    )


@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@@ -281,6 +363,15 @@ def test_custom_ls_input_binaural_headrotation(
        is_comparetest=True,
    )
    
    compare_renderer_vs_renderer_with_binary_hrtf(
        test_info,
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"),
        out_fmt,
        trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
        framing_5ms=(framing_5ms == "5ms"),
        is_comparetest=True,
    )


""" Metadata / scene description input """

+22 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ def run_renderer(
    is_comparetest: Optional[bool] = False,
    framing_5ms: Optional[bool] = False,
    test_case_name: Optional[str] = None,
    hrtf_file: Optional[str] = None,
) -> Tuple[np.ndarray, int]:
    """CuT creation with standalone renderer"""
    if trj_file is not None:
@@ -185,6 +186,7 @@ def run_renderer(

    if non_diegetic_pan is not None:
        cmd.extend(["-non_diegetic_pan", str(non_diegetic_pan)])

    if refrot_file is not None:
        cmd.extend(["-rf", str(refrot_file)])
        cmd.extend(["-otr", "ref"])
@@ -203,6 +205,9 @@ def run_renderer(
    if framing_5ms:
        cmd.extend(["-fr5"])

    if hrtf_file is not None:
        cmd.extend(["-hrtf", str(hrtf_file)])

    # Set env variables for UBSAN
    env = os.environ.copy()
    if test_case_name and "UBSAN_OPTIONS" in env.keys():
@@ -248,3 +253,20 @@ def compare_renderer_args(
        in_fmt, out_fmt, test_case_name=test_info.node.name, **cut_kwargs
    )
    check_BE(test_info, ref, ref_fs, cut, cut_fs)

def compare_renderer_vs_renderer_with_binary_hrtf(test_info, in_fmt, out_fmt, **kwargs):
    
    hrtf_file = "./scripts/binauralRenderer_Interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin"
    ref, ref_fs = run_renderer(
        in_fmt,
        out_fmt,
        test_case_name=test_info.node.name,
        output_path_base=OUTPUT_PATH_REF,
        hrtf_file = hrtf_file,
        **kwargs,
    )
    cut, cut_fs = run_renderer(
        in_fmt, out_fmt, test_case_name=test_info.node.name, **kwargs
    )
    check_BE(test_info, ref, ref_fs, cut, cut_fs)