Commit 96568b04 authored by emerit's avatar emerit
Browse files

test compare fix and float renderer

parent 6ad5703c
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -77,6 +77,16 @@ def test_ambisonics_binaural_static_with_binary_hrir(
        test_info, in_fmt, out_fmt, hrtf_tag, frame_size=frame_size
    )

@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_fix_with_float(
    test_info, in_fmt, out_fmt, frame_size
):
    compare_renderer_vs_renderer_float(
        test_info, in_fmt, out_fmt, frame_size=frame_size
    )


@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST_RENDERER)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@@ -113,6 +123,19 @@ def test_multichannel_binaural_static_with_binary_hrir(
        test_info, in_fmt, out_fmt, hrtf_tag, frame_size=frame_size
    )

@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_fix_with_float(
    test_info, in_fmt, out_fmt, frame_size
):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")

    compare_renderer_vs_renderer_float(
        test_info, in_fmt, out_fmt, frame_size=frame_size
    )


@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST_RENDERER)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
+75 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ from typing import Optional

import pytest

from tests.renderer.utils import check_BE, run_cmd, run_renderer, test_info
from tests.renderer.utils import check_BE, run_cmd, run_renderer, test_info, BIN_SUFFIX_MERGETARGET

from .constants import *

@@ -438,6 +438,80 @@ def compare_renderer_vs_renderer_with_binary_hrir(
            os.remove(ref_out)
            os.remove(cut_out)

def compare_renderer_vs_renderer_float(
    test_info,
    in_fmt,
    out_fmt,
    metadata_input: Optional[str] = None,
    in_meta_files: Optional[list] = None,
    trj_file: Optional[str] = None,
    non_diegetic_pan: Optional[str] = None,
    name_extension: Optional[str] = uuid.uuid1(),
    refrot_file: Optional[str] = None,
    refvec_file: Optional[str] = None,
    refveclev_file: Optional[str] = None,
    config_file: Optional[str] = None,
    frame_size: Optional[str] = "20ms",
    keep_file="if failed",
):
    ref_out = run_renderer(
        None,
        list(),
        test_info,
        in_fmt,
        out_fmt,
        metadata_input,
        in_meta_files,
        trj_file,
        non_diegetic_pan,
        name_extension,
        refrot_file,
        refvec_file,
        refveclev_file,
        config_file,
        frame_size=frame_size,
        binary_suffix=BIN_SUFFIX_MERGETARGET
    )
    cut_out = run_renderer(
        None,
        list(),
        test_info,
        in_fmt,
        out_fmt,
        metadata_input,
        in_meta_files,
        trj_file,
        non_diegetic_pan,
        name_extension,
        refrot_file,
        refvec_file,
        refveclev_file,
        config_file,
        frame_size=frame_size,
    )

    ref, ref_fs = pyaudio3dtools.audiofile.readfile(ref_out)
    cut, cut_fs = pyaudio3dtools.audiofile.readfile(cut_out)

    [diff_found, snr, gain_b, max_diff] = check_BE(
        test_info, ref, ref_fs, cut, cut_fs, 2
    )
    if keep_file == "no":
        os.remove(ref_out)
        os.remove(cut_out)

    if diff_found:
        if keep_file != "if failed":
            os.remove(ref_out)
            os.remove(cut_out)
        pytest.fail(
            f"CuT not BE to REF! SNR : {snr:3.2f} dB, Gain CuT: {gain_b:1.3f}, Max Diff = {int(max_diff)}"
        )
    else:
        if keep_file == "if failed":
            os.remove(ref_out)
            os.remove(cut_out)


def compare_renderer_with_binary_fix_vs_with_binary_float(
    test_info,
+6 −3
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ from .constants import (
    FORMAT_TO_FILE_LTV,
    FORMAT_TO_FILE_SMOKETEST,
    RENDERER_CMD,
    RENDERER_REF_CMD,
    BIN_SUFFIX_MERGETARGET,
)

@@ -122,7 +123,7 @@ def check_BE(
    ref_fs: int,
    cut: np.ndarray,
    cut_fs: int,
    atol: int = 2,
    atol: int = 0,
) -> tuple:
    if ref is None or np.array_equal(ref, np.zeros_like(ref)):
        pytest.fail("REF signal does not exist or is zero!")
@@ -223,6 +224,9 @@ def run_renderer(

    if test_info.config.option.create_ref:
        output_path_base = OUTPUT_PATH_REF
    else:
        if binary_suffix == BIN_SUFFIX_MERGETARGET:
            output_path_base = OUTPUT_PATH_REF
        else:
            output_path_base = OUTPUT_PATH_CUT

@@ -341,7 +345,6 @@ def run_renderer(

    return out_file


def compare_renderer_args(
    record_property,
    props_to_record,