Commit dffc9b8b authored by emerit's avatar emerit
Browse files

merge tests/renderer script with main

parent ee20a500
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -200,7 +200,9 @@ HR_TRAJECTORIES_TO_TEST = [
    "rotate_yaw_pitch_roll1",
]

CONFIG_FILES_TO_TEST = ["just_reverb"]
CONFIG_FILES_TO_TEST = [
    "just_reverb"
]

""" Per-testcase xfail SNR thresholds (dB) """
pass_snr = dict()  # not relevant for tests anymore, should be deprecated soon
+40 −81
Original line number Diff line number Diff line
@@ -61,38 +61,37 @@ def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
@pytest.mark.parametrize("config_file", CONFIG_FILES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
def test_ambisonics_binaural_headrotation_defaultrenderconfig(
    test_info, in_fmt, out_fmt, config_file
):
def test_ambisonics_binaural_headrotation_defaultrenderconfig(test_info, in_fmt, out_fmt, config_file):
    compare_renderer_args(
        test_info,
        in_fmt,
        out_fmt,
        ref_kwargs={"name_extension": "defaultrenderconfig"},
        cut_kwargs={"config_file": TESTV_DIR.joinpath(f"{config_file}.cfg")},
        ref_kwargs={
            "name_extension": "defaultrenderconfig"
        },
        cut_kwargs={
            "config_file": TESTV_DIR.joinpath(f"{config_file}.cfg")
        }
    )


# Test compares rendering with just a trajectory file against rendering with a trajectory file + a zero ref rotation.
# These should be binary equivalent.
@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)
def test_ambisonics_binaural_headrotation_refrotzero(
    test_info, in_fmt, out_fmt, trj_file
):
def test_ambisonics_binaural_headrotation_refrotzero(test_info, in_fmt, out_fmt, trj_file):
    compare_renderer_args(
        test_info,
        in_fmt,
        out_fmt,
        ref_kwargs={
            "name_extension": "refrotzero",
            "trj_file": HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
            "trj_file": HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv")
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
            "refrot_file": HR_TRAJECTORY_DIR.joinpath("const000.csv"),
        },
            "refrot_file": HR_TRAJECTORY_DIR.joinpath("const000.csv")
        }
    )


@@ -110,16 +109,11 @@ def test_ambisonics_binaural_headrotation_refrotequal(test_info, in_fmt, out_fmt
            "name_extension": "refrotequal",
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath(
                "azi_plus_2-ele_plus_2-every-100-frames.csv"
            ),
            "refrot_file": HR_TRAJECTORY_DIR.joinpath(
                "azi_plus_2-ele_plus_2-every-25-rows.csv"
            ),
        },
            "trj_file": HR_TRAJECTORY_DIR.joinpath("azi_plus_2-ele_plus_2-every-100-frames.csv"),
            "refrot_file": HR_TRAJECTORY_DIR.joinpath("azi_plus_2-ele_plus_2-every-25-rows.csv")
        }
    )


# This test compares rendering with:
#   ref: head rotation trajectory file (OTR=NONE)
#   cut: identical head rotation trajectory file as ref but in addition a constant
@@ -127,24 +121,21 @@ def test_ambisonics_binaural_headrotation_refrotequal(test_info, in_fmt, out_fmt
@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)
def test_ambisonics_binaural_headrotation_refveczero(
    test_info, in_fmt, out_fmt, trj_file
):
def test_ambisonics_binaural_headrotation_refveczero(test_info, in_fmt, out_fmt, trj_file):
    compare_renderer_args(
        test_info,
        in_fmt,
        out_fmt,
        ref_kwargs={
            "name_extension": "refveczero",
            "trj_file": HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
            "trj_file": HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv")
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("const000-Vector3.csv"),
        },
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("const000-Vector3.csv")
        }
    )


# This test compares rendering with:
#   ref: no head rotation (OTR=NONE)
#   cut: rendering with head rotation and a ref vector which moves in the
@@ -160,16 +151,11 @@ def test_ambisonics_binaural_headrotation_refvecequal(test_info, in_fmt, out_fmt
            "name_extension": "refvecequal",
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s.csv"
            ),
            "refvec_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s-Vector3.csv"
            ),
        },
            "trj_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s.csv"),
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s-Vector3.csv")
        }
    )


# This test compares rendering with:
#   ref: a head rotation trajectory with elevation (OTR=NONE)
#   cut: a static head rotation and a reference position trajectory which moves
@@ -183,19 +169,14 @@ def test_ambisonics_binaural_headrotation_refvec_rotating(test_info, in_fmt, out
        out_fmt,
        ref_kwargs={
            "name_extension": "refvec_rotating",
            "trj_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s.csv"
            ),
            "trj_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s.csv"),
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath("const000.csv"),
            "refvec_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s-ccw-Vector3.csv"
            ),
        },
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s-ccw-Vector3.csv")
        }
    )


# This test compares rendering with:
#   ref: a head rotation trajectory with elevation (OTR=NONE)
#   cut: a static head rotation and a reference position trajectory which moves
@@ -204,28 +185,21 @@ def test_ambisonics_binaural_headrotation_refvec_rotating(test_info, in_fmt, out
#        gets compensated in the REF_VEV OTR modes)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI)
def test_ambisonics_binaural_headrotation_refvec_rotating_fixed_pos_offset(
    test_info, in_fmt, out_fmt
):
def test_ambisonics_binaural_headrotation_refvec_rotating_fixed_pos_offset(test_info, in_fmt, out_fmt):
    compare_renderer_args(
        test_info,
        in_fmt,
        out_fmt,
        ref_kwargs={
            "name_extension": "refvec_rotating",
            "trj_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s-ccw.csv"
            ),
            "trj_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s-ccw.csv"),
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath("const000.csv"),
            "refvec_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s-fixed-pos-offset-Vector3.csv"
            ),
        },
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s-fixed-pos-offset-Vector3.csv")
        }
    )


# This test compares rendering with:
#   ref: a reference position trajectory with elevation and REF_VEC_LEV OTR mode (OTR=REF_VEC_LEV)
#   cut: a reference position trajectory without the elevation and REF_VEC OTR mode (OTR=REF_VEC)
@@ -233,9 +207,7 @@ def test_ambisonics_binaural_headrotation_refvec_rotating_fixed_pos_offset(
# the height difference in positions, the output must be binary equivalent.
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI)
def test_ambisonics_binaural_headrotation_refveclev_vs_refvec(
    test_info, in_fmt, out_fmt
):
def test_ambisonics_binaural_headrotation_refveclev_vs_refvec(test_info, in_fmt, out_fmt):
    compare_renderer_args(
        test_info,
        in_fmt,
@@ -243,14 +215,12 @@ def test_ambisonics_binaural_headrotation_refveclev_vs_refvec(
        ref_kwargs={
            "name_extension": "refveclevel",
            "trj_file": HR_TRAJECTORY_DIR.joinpath("const000.csv"),
            "refveclev_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s-Vector3.csv"
            ),
            "refveclev_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s-Vector3.csv"),
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath("const000.csv"),
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("full-circle-4s-Vector3.csv"),
        },
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("full-circle-4s-Vector3.csv")
        }
    )


@@ -292,7 +262,6 @@ def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file
            trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
        )


# This test compares rendering with:
#   ref: a head rotation trajectory with elevation (OTR=NONE)
#   cut: a static head rotation and a reference position trajectory which moves
@@ -309,16 +278,12 @@ def test_multichannel_binaural_headrotation_refvec_rotating(test_info, in_fmt, o
        out_fmt,
        ref_kwargs={
            "name_extension": "refvec_rotating",
            "trj_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s.csv"
            ),
            "trj_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s.csv"),
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath("const000.csv"),
            "refvec_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s-ccw-Vector3.csv"
            ),
        },
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s-ccw-Vector3.csv")
        }
    )


@@ -369,7 +334,6 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
            in_meta_files=in_meta_files,
        )


# This test compares rendering with:
#   ref: a head rotation trajectory with elevation (OTR=NONE)
#   cut: a static head rotation and a reference position trajectory which moves
@@ -388,21 +352,16 @@ def test_ism_binaural_headrotation_refvec_rotating(test_info, in_fmt, out_fmt):
        out_fmt,
        ref_kwargs={
            "name_extension": "refvec_rotating",
            "trj_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s.csv"
            ),
            "in_meta_files": in_meta_files,
            "trj_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s.csv"),
            "in_meta_files": in_meta_files
        },
        cut_kwargs={
            "trj_file": HR_TRAJECTORY_DIR.joinpath("const000.csv"),
            "refvec_file": HR_TRAJECTORY_DIR.joinpath(
                "full-circle-with-up-and-down-4s-ccw-Vector3.csv"
            ),
            "in_meta_files": in_meta_files,
        },
            "refvec_file": HR_TRAJECTORY_DIR.joinpath("full-circle-with-up-and-down-4s-ccw-Vector3.csv"),
            "in_meta_files": in_meta_files
        }
    )


""" MASA """


+3 −12
Original line number Diff line number Diff line
@@ -146,10 +146,7 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST)
def test_custom_ls_input(test_info, in_layout, out_fmt):
    compare_renderer_vs_mergetarget(
        test_info,
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"),
        out_fmt,
        is_comparetest=True,
        test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, is_comparetest=True
    )


@@ -157,10 +154,7 @@ def test_custom_ls_input(test_info, in_layout, out_fmt):
@pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS)
def test_custom_ls_output(test_info, in_fmt, out_fmt):
    compare_renderer_vs_mergetarget(
        test_info,
        in_fmt,
        CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"),
        is_comparetest=True,
        test_info, in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), is_comparetest=True
    )


@@ -179,10 +173,7 @@ def test_custom_ls_input_output(test_info, in_fmt, out_fmt):
@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST)
def test_custom_ls_input_binaural(test_info, in_layout, out_fmt):
    compare_renderer_vs_mergetarget(
        test_info,
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"),
        out_fmt,
        is_comparetest=True,
        test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, is_comparetest=True
    )


+5 −6
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ from .constants import *
sys.path.append(SCRIPTS_DIR)
import pyaudio3dtools


# fixture returns test information, enabling per-testcase SNR
@pytest.fixture
def test_info(request):
@@ -66,6 +65,7 @@ def check_BE(
    cut: np.ndarray,
    cut_fs: int,
):

    if ref is None or np.array_equal(ref, np.zeros_like(ref)):
        pytest.fail("REF signal does not exist or is zero!")

@@ -141,6 +141,8 @@ def run_renderer(
    else:
        config_name = ""



    if not isinstance(out_fmt, str):
        out_name = f"{out_fmt.stem}"
    else:
@@ -219,10 +221,7 @@ def compare_renderer_vs_pyscripts(test_info, in_fmt, out_fmt, **kwargs):
    cut, cut_fs = run_renderer(in_fmt, out_fmt, **kwargs)
    check_BE(test_info, ref, ref_fs, cut, cut_fs)


def compare_renderer_args(
    test_info, in_fmt, out_fmt, ref_kwargs: Dict, cut_kwargs: Dict
):
def compare_renderer_args(test_info, in_fmt, out_fmt, ref_kwargs: Dict, cut_kwargs: Dict):
    ref, ref_fs = run_renderer(in_fmt, out_fmt, **ref_kwargs)
    cut, cut_fs = run_renderer(in_fmt, out_fmt, **cut_kwargs)
    check_BE(test_info, ref, ref_fs, cut, cut_fs)
 No newline at end of file