Commit 5912615a authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[tests] Enable testing against TD Object Renderer Standalone

- Fix crash by correctly setting Opt_Headrotation in
  renderer_standalone.c
- Instead of testing against pyaudio3dtools as reference, generate it
  with TD Standalone instead for corresponding paths
parent 0633f4a8
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -310,12 +310,17 @@ int main( int argc, char *argv[] )

    if ( f_quat_traj != NULL )
    {
        st_ivas->hDecoderConfig->Opt_Headrotation = 1;
        if ( ( st_ivas->hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) count_malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL )
        {
            fprintf( stderr, "Can not allocate memory for head-tracking\n" );
            exit( -1 );
        }
    }
    else
    {
        st_ivas->hDecoderConfig->Opt_Headrotation = 0;
    }

    /* Init limiter */
    st_ivas->hLimiter = ivas_limiter_open( nChannels, st_ivas->hDecoderConfig->output_Fs );
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ RENDERER_CMD = [
""" TD Object Renderer commandline template """
TDRENDERER_CMD = [
    str(
        TESTS_DIR.parent.joinpath("td_object_renderer")
        SCRIPTS_DIR.joinpath("td_object_renderer")
        .joinpath("object_renderer_standalone")
        .joinpath("renderer_standalone")
    ),
+39 −50
Original line number Diff line number Diff line
@@ -67,6 +67,10 @@ def check_BE(
    else:
        snr_min = np.inf

    # TODO temporary fix to pad TD Object Renderer Standalone output
    if ref.shape != cut.shape:
        ref = np.pad(ref, [(0, cut.shape[0] - ref.shape[0]), (0, 0)])

    # check max_diff as well, since compare_audio_arrays will try to adjust for small delay differences
    if not np.allclose(ref, cut, rtol=0, atol=2) and max_diff > 2:
        if snr >= snr_min:
@@ -203,7 +207,7 @@ def run_crend_unittest(
        in_name = in_fmt

    out_file = str(
        OUTPUT_PATH_CUT.joinpath(f"{in_name}_to_{out_name}{trj_name}_crend.wav")
        OUTPUT_PATH_REF.joinpath(f"{in_name}_to_{out_name}{trj_name}_crend.wav")
    )

    cmd = RENDERER_CREND_CMD[:]
@@ -258,7 +262,7 @@ def run_td_standalone(
        in_file = FORMAT_TO_FILE[in_fmt]
        in_name = in_fmt

    out_file = str(OUTPUT_PATH_CUT.joinpath(f"{in_name}_to_{out_name}{trj_name}.pcm"))
    out_file = str(OUTPUT_PATH_REF.joinpath(f"{in_name}_to_{out_name}{trj_name}.pcm"))

    in_spfmt = pyaudio3dtools.spatialaudioformat.Format(in_fmt)

@@ -449,12 +453,11 @@ def test_ism_binaural_static(test_info, in_fmt, out_fmt):
    except:
        in_meta_files = None

    if out_fmt == "BINAURAL":
        ref, ref_fs = run_td_standalone(in_fmt, out_fmt, in_meta_files=in_meta_files)
    else:
        ref, ref_fs = run_pyscripts(in_fmt, out_fmt, in_meta_files=in_meta_files)

    # if out_fmt == "BINAURAL":
    #     cut, cut_fs = run_td_standalone(in_fmt, out_fmt, in_meta_files=in_meta_files)
    # else:
    #     cut, cut_fs = run_renderer(in_fmt, out_fmt, in_meta_files=in_meta_files)
    cut, cut_fs = run_renderer(in_fmt, out_fmt, in_meta_files=in_meta_files)

    check_BE(test_info, ref, ref_fs, cut, cut_fs)
@@ -470,17 +473,15 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt):
    check_BE(test_info, ref, ref_fs, cut, cut_fs)


@pytest.mark.skip(
    "Skip CREND unit test comparison until ASAN issues and copying binaries is fixed"
)
@pytest.mark.skip("Skip CREND unit test comparison until ASAN issues are fixed")
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:])
def test_multichannel_binaural_static_vs_crend_unittest(test_info, in_fmt, out_fmt):

    cut, cut_fs = run_renderer(in_fmt, out_fmt)

    crend, crend_fs = run_crend_unittest(in_fmt, out_fmt)

    cut, cut_fs = run_renderer(in_fmt, out_fmt)

    check_BE(test_info, cut, cut_fs, crend, crend_fs)


@@ -513,6 +514,14 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
    except:
        in_meta_files = None

    if out_fmt == "BINAURAL":
        ref, ref_fs = run_td_standalone(
            in_fmt,
            out_fmt,
            trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
            in_meta_files=in_meta_files,
        )
    else:
        ref, ref_fs = run_pyscripts(
            in_fmt,
            out_fmt,
@@ -520,21 +529,6 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
            in_meta_files=in_meta_files,
        )

    # if out_fmt == "BINAURAL":
    #     cut, cut_fs = run_td_standalone(
    #         in_fmt,
    #         out_fmt,
    #         trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
    #         in_meta_files=in_meta_files,
    #     )
    # else:
    #     cut, cut_fs = run_renderer(
    #         in_fmt,
    #         out_fmt,
    #         trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
    #         in_meta_files=in_meta_files,
    #     )

    cut, cut_fs = run_renderer(
        in_fmt,
        out_fmt,
@@ -549,25 +543,20 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:])
def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):

    if (in_fmt == "5_1" or in_fmt == "7_1") and out_fmt == "BINAURAL":
        ref, ref_fs = run_td_standalone(
            in_fmt,
            out_fmt,
            trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
        )
    else:
        ref, ref_fs = run_pyscripts(
            in_fmt,
            out_fmt,
            trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
        )

    # if (in_fmt == "5_1" or in_fmt == "7_1") and out_fmt == "BINAURAL":
    #     cut, cut_fs = run_td_standalone(
    #         in_fmt,
    #         out_fmt,
    #         trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
    #     )
    # else:
    #     cut, cut_fs = run_renderer(
    #         in_fmt,
    #         out_fmt,
    #         trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"),
    #     )

    cut, cut_fs = run_renderer(
        in_fmt,
        out_fmt,