diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e4af2b332146c829dff672a14d7771f89df64fd..87f503a314a9b45d2a55b632fb559692c3547861 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1046,6 +1046,29 @@ lc3plus-ensure-no-code-changes: - modified_files=$(git status -s) - if [[ $modified_files ]]; then printf 'LC3plus codebase was modified!\n\n'"$modified_files"'\n\n'; exit $EXIT_CODE_FAIL; fi +check-bitexactness-hrtf-rom-and-file: + extends: + - .test-job-linux + - .rules-merge-request + stage: test + needs: ["build-codec-linux-cmake"] + timeout: "5 minutes" + script: + - *print-common-info + - cmake . + - make -j + - python3 tests/create_short_testvectors.py --which all --cut_len 1.0 + - python3 -m pytest tests/hrtf_binary_loading --html=report.html --junit-xml=report-junit.xml --self-contained-html + artifacts: + paths: + - report.html + - report-junit.xml + when: always + name: "$CI_JOB_NAME--$CI_MERGE_REQUEST_ID--sha-$CI_COMMIT_SHA--hrtf-loading" + expose_as: "logs-hrtf-loading" + expire_in: "5 days" + + # --------------------------------------------------------------- # Test jobs for main branch # --------------------------------------------------------------- diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_16kHz.bin b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_16kHz.bin new file mode 100644 index 0000000000000000000000000000000000000000..20c688d2da51b9bdcbfed510f0c86503dfc4bde6 --- /dev/null +++ b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_16kHz.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c839dcbdcfb7de23b725325770a07de3fe0144dc56f0ba7b4a9627bc912c2547 +size 1771166 diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_32kHz.bin b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_32kHz.bin new file mode 100644 index 0000000000000000000000000000000000000000..c92f4c2af0b29bee7ce6e66ac3b30bda3ee3f39e --- /dev/null +++ b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_32kHz.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c88daaf248bb36ac11d0aa320b18ce87019ef6ad9fab6ac2b7f064b27048aac +size 2107682 diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_48kHz.bin b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_48kHz.bin new file mode 100644 index 0000000000000000000000000000000000000000..61f226bca4ba61441e73905206a3a2b4e9f0741c --- /dev/null +++ b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_51_brir-lc_48kHz.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed7e4b9f3306e7aecd2edf19b7ca9fb62240031fa248b26ad7c606fef36a20fe +size 2343650 diff --git a/scripts/binauralRenderer_interface/generate_ivas_binauralizer_tables_from_sofa.m b/scripts/binauralRenderer_interface/generate_ivas_binauralizer_tables_from_sofa.m index ec454511d7509834ff57894668653e1e0c0c043d..491062b1aa6a9c6d98a5e5b58e593e8375be181c 100644 --- a/scripts/binauralRenderer_interface/generate_ivas_binauralizer_tables_from_sofa.m +++ b/scripts/binauralRenderer_interface/generate_ivas_binauralizer_tables_from_sofa.m @@ -48,14 +48,22 @@ addpath(genpath('../td_object_renderer/modeling_tool/')); writeRomFileOutput = true; %% generation of rom files if true writeBinaryOutput = true; %% generation of binary files if true. Always true for TD renderer writeEachRendererBinaryOutput = true; %% generation of binary split files each containing binary data for individual renderer - +normalizeSofaInputData = false; %% if true SOFA IR are nomalized %% Set ivas root path ivas_path = ['..' filesep '..' filesep]; +generateCustomBinaryFile = false; + %% Set input files -%hrir_file_name = 'D1_48K_24bit_256tap_FIR_SOFA.sofa'; -%hrir_file_name = 'HRIR_128_Meth5_IRC_51_Q10_symL_Itrp1_48000.sofa'; -hrir_file_name = 'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa'; +if generateCustomBinaryFile + hrir_file_name_init = 'HRIR_128_Meth5_IRC_51_Q10_symL_Itrp1_48000.sofa'; + hrir_file_name = 'HRIR_128_Meth5_IRC_51_Q10_symL_Itrp1_48000_norm.sofa'; + output_bin_name = 'ivas_binaural_51_brir-lc'; +else + hrir_file_name_init = 'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa'; + hrir_file_name = 'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000_norm.sofa'; + output_bin_name = 'ivas_binaural'; +end brir_file_name = 'IIS_BRIR_officialMPEG_Combined.sofa'; hrir_path = fullfile ('.','HRIRs_sofa'); brir_path = fullfile ('.','BRIRs_sofa'); @@ -63,14 +71,23 @@ brir_path = fullfile ('.','BRIRs_sofa'); rom_path = [ivas_path 'lib_rend']; binary_path = fullfile ('.','binaural_renderers_hrtf_data'); binary_name = [erase(hrir_file_name,'.sofa') '+' erase(brir_file_name, '.sofa') ]; -output_bin_name = 'ivas_binaural'; if ~(exist(binary_path, 'dir')) mkdir(binary_path); end +hrir_file_init = fullfile( hrir_path, hrir_file_name_init); hrir_file = fullfile( hrir_path, hrir_file_name); brir_file = fullfile( brir_path, brir_file_name); +%% normalize input HRTF + +if (normalizeSofaInputData) + SOFA_normalize(hrir_file_init,hrir_file); +else + hrir_file_name = hrir_file_name_init; + hrir_file = hrir_file_init; +end + %% generate td binauralizer rom or binary values dataSpec.dataBase = 'IVAS'; @@ -100,6 +117,12 @@ if writeBinaryOutput == true ]; end +if generateCustomBinaryFile + command = [command ... + ' -brir_optim_config_path' ... + ' brir_low_complexity_optim.cfg ' ... + ] +end command = [command ... ' -compute_reverb_rom ' ... erase(hrir_file,'.sofa') '.mat ' ... diff --git a/scripts/binauralRenderer_interface/matlab_hrir_generation_scripts/SOFA_save.m b/scripts/binauralRenderer_interface/matlab_hrir_generation_scripts/SOFA_save.m index f1f8743250374851824928fd547a9227afe33d1a..85e5e81f0edb3c4826866bd9e90f939af9f24913 100644 --- a/scripts/binauralRenderer_interface/matlab_hrir_generation_scripts/SOFA_save.m +++ b/scripts/binauralRenderer_interface/matlab_hrir_generation_scripts/SOFA_save.m @@ -35,6 +35,16 @@ function [outputArg1] = SOFA_save(IR,fs,latency_s, inputSofaTemplatePath,outputS % Detailed explanation goes here outputArg1 = false; inputAsLatencys = false; +outputFormatIsHOA = 0; +if (size(IR,3) == 4) + outputFormatIsHOA = 1; +end +if (size(IR,3) == 9) + outputFormatIsHOA = 1; +end +if (size(IR,3) == 16) + outputFormatIsHOA = 1; +end if isfile(inputSofaTemplatePath) if isfile(outputSofaPath) @@ -92,7 +102,11 @@ if isfile(inputSofaTemplatePath) varId = netcdf.inqVarID(ncid_in,sofa_data.Variables(indVar).Name); [name,xtype,dimids,natts] = netcdf.inqVar(ncid_in,varId); netcdf.defVar(ncid, name , xtype, dimids); - data = zeros(sofa_data.Variables(indVar).Size); + if (outputFormatIsHOA == 0) + data = netcdf.getVar(ncid_in,varId); + else + data = zeros(sofa_data.Variables(indVar).Size); + end netcdf.putVar(ncid, varId, data); if (strcmp(name, 'Data.IR')) netcdf.putVar(ncid, varId, IR); @@ -120,6 +134,10 @@ if isfile(inputSofaTemplatePath) ncwriteatt(outputSofaPath,'/', 'ListenerShortName',ncreadatt(inputSofaTemplatePath,'/','ListenerShortName')); ncwriteatt(outputSofaPath,'/', 'DatabaseName',ncreadatt(inputSofaTemplatePath,'/','DatabaseName')); ncwriteatt(outputSofaPath,'/','Title' ,ncreadatt(inputSofaTemplatePath,'/','Title')); - ncwriteatt(outputSofaPath,'/', 'SOFAConventions', 'AmbisonicsBRIR'); + if (outputFormatIsHOA == 0) + ncwriteatt(outputSofaPath,'/', 'SOFAConventions', 'AmbisonicsBRIR'); + else + ncwriteatt(outputSofaPath,'/', 'SOFAConventions', ncreadatt(inputSofaTemplatePath,'/','SOFAConventions')); + end end \ No newline at end of file diff --git a/tests/codec_be_on_mr_nonselection/test_param_file.py b/tests/codec_be_on_mr_nonselection/test_param_file.py index 92d1f29f6ca3e7dee3164d2e830ff9ff6001d7d0..824608066c1f24ae317525e66b08ade8441b1f25 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -439,9 +439,7 @@ def pre_proc_input(testv_file, fs): elif "stv3OA" in testv_file: num_channel = "16" cut_file = testv_file.replace(".wav", num_channel + "chn_" + cut_gain + ".wav") - cut_samples( - testv_file, cut_file, num_channel, fs + "000", cut_from, cut_len, cut_gain - ) + cut_samples(testv_file, cut_file, num_channel, cut_from, cut_len, cut_gain) return cut_file diff --git a/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py b/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py index f08e031d21ba066439d38f0c1b1b168e007cb660..11a8aeca04baf683bfdc67ee5f25f278e77f2b6b 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py +++ b/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py @@ -152,7 +152,6 @@ def sba_dec_plc( get_mld=False, get_mld_lim=0, ): - # ------------ run cmd ------------ tag_out = f"{tag}_ivasbr{ivas_br[:-3]}k_DTX{dtx}" diff --git a/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py b/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py index 897bc134b6677e0bc8ffaa1a45b4d0f649674300..3f394b0c2ac792d999cfa4191b49edb96cf75c94 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py +++ b/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py @@ -187,7 +187,6 @@ def test_sba_enc_system( get_mld, get_mld_lim, ): - if dtx == "1" and ivas_br not in ["13200", "16400", "24400", "32000", "64000"]: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() @@ -563,10 +562,10 @@ def sba_enc( input_path, cut_file, num_channels, - sampling_rate + "000", cut_from, cut_len, cut_gain, + sample_rate=sampling_rate + "000", ) input_path = cut_file diff --git a/tests/conftest.py b/tests/conftest.py index 0525bbf628acd6c09a518ad90978dcdb9c301f1a..d667a43fea92bcf644a29569636882827e36363d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -460,7 +460,6 @@ class DecoderFrontend: command.extend(["-q"]) if plc_file is not None: - system = platform.system() if system == "Windows": diff --git a/tests/create_short_testvectors.py b/tests/create_short_testvectors.py index 0b8ee79c8133fe8fbbbef9494e6728bd15ab6e8e..d80a328c14ff8b85dd5946c598796efc333f164d 100755 --- a/tests/create_short_testvectors.py +++ b/tests/create_short_testvectors.py @@ -34,38 +34,73 @@ __doc__ = """ Create short (5sec) testvectors. """ +import argparse import sys from pathlib import Path from cut_pcm import cut_samples HERE = Path(__file__).parent.resolve() -TEST_VECTOR_DIR = str(HERE.joinpath("../scripts/testv").resolve()) +TEST_VECTOR_DIR = HERE.joinpath("../scripts/testv").resolve() NUM_CHANNELS = "4" # currently only FOA CUT_FROM = "0.0" -CUT_LEN = "5.0" - - -def create_short_testvectors(): - for fs in ["48", "32", "16"]: - in_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c.wav" - cut_gain = "1.0" - cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut.wav" - cut_samples( - in_file, cut_file, NUM_CHANNELS, fs + "000", CUT_FROM, CUT_LEN, cut_gain - ) - cut_gain = "16.0" - cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut_{cut_gain}.wav" - cut_samples( - in_file, cut_file, NUM_CHANNELS, fs + "000", CUT_FROM, CUT_LEN, cut_gain - ) - cut_gain = ".004" - cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut_{cut_gain}.wav" - cut_samples( - in_file, cut_file, NUM_CHANNELS, fs + "000", CUT_FROM, CUT_LEN, cut_gain - ) + +FILE_IDS = [ + "stvFOA", + "stv2OA", + "stv3OA", + "stv51MC", + "stv71MC", + "stv512MC", + "stv514MC", + "stv714MC", + "ISM", + "MASA", +] +GAINS = ["1.0", "16.0", ".004"] + + +def collect_files(file_ids): + files = [ + f.absolute() + for f in TEST_VECTOR_DIR.iterdir() + if f.suffix == ".wav" + and any([id in f.name for id in file_ids]) + and not "_cut" in f.name + ] + return files + + +def create_short_testvectors(which="foa", cut_len=5.0): + file_ids = [] + if which == "all": + file_ids = FILE_IDS + elif which == "foa": + file_ids = FILE_IDS[:1] + + for f in collect_files(file_ids): + for g in GAINS: + suffix = "_cut" + if g != "1.0": + suffix += f"_{g}" + + out_file = f.parent.joinpath(f.stem + suffix + f.suffix) + cut_samples(f, out_file, NUM_CHANNELS, CUT_FROM, f"{cut_len}", g) if __name__ == "__main__": - sys.exit(create_short_testvectors()) + parser = argparse.ArgumentParser() + parser.add_argument("--which", choices=["foa", "all"], default="foa") + + def positive_float(x: str) -> float: + x = float(x) + if x < 0.0: + raise ValueError("Value for cut_len needs to be positive!") + return x + + parser.add_argument("--cut_len", type=positive_float, default=5.0) + args = parser.parse_args() + which = args.which + cut_len = args.cut_len + sys.exit(create_short_testvectors(which=args.which, cut_len=cut_len)) diff --git a/tests/cut_pcm.py b/tests/cut_pcm.py index 60bac699cbb06c637cf71779ed6407e76123842f..644a2ba1bcddf774441a94b1ebe1f8b80974eaff 100755 --- a/tests/cut_pcm.py +++ b/tests/cut_pcm.py @@ -61,7 +61,13 @@ def usage(): def cut_samples( - in_file, out_file, num_channels, sample_rate, start, duration, gain="1.0" + in_file, + out_file, + num_channels, + start, + duration, + gain="1.0", + sample_rate=None, ): """ Function to cut samples from an audio file (wav or pcm) @@ -74,6 +80,12 @@ def cut_samples( + platform.python_version() ) + if sample_rate is None and not str(in_file).endswith(".wav"): + raise ValueError(f"For non-wav files, samplerate must be explicitly given") + elif sample_rate is None: + # set to default of pyaudio3dtools.audiofile.readfile -> for wav files it will be ignored anyway + sample_rate = 48000 + # all input parameters are strings - convert some fs = int(sample_rate) start_sec = float(start) @@ -85,10 +97,9 @@ def cut_samples( num_in_samples = s.shape[0] num_samples_to_skip = int(start_sec * fs) dur_samples = int(dur_sec * fs) - if num_samples_to_skip + dur_samples > num_in_samples: - sys.exit( - f"requested too many samples ({num_samples_to_skip}+{dur_samples})" - + f" - input is too short ({num_in_samples})" + if num_samples_to_skip > dur_samples: + raise ValueError( + f"Requested to skip {num_samples_to_skip}, but file only has {dur_samples} samples" ) s_out = s[num_samples_to_skip : num_samples_to_skip + dur_samples, :] * gain_f diff --git a/tests/hrtf_binary_loading/conftest.py b/tests/hrtf_binary_loading/conftest.py deleted file mode 100644 index c4c8b05174bac7a0d5fb5208afbc947502799c62..0000000000000000000000000000000000000000 --- a/tests/hrtf_binary_loading/conftest.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 - -""" - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. -""" - - -def pytest_addoption(parser): - parser.addoption( - "--create_ref", - action="store_true", - default=False, - ) - parser.addoption( - "--create_cut", - action="store_true", - default=False, - ) diff --git a/tests/hrtf_binary_loading/constants.py b/tests/hrtf_binary_loading/constants.py index ab5ae13fe252836b3cf4459fa4328bd3cad1e8b1..1524e9bf57edc72a71b434bde9c7245311c000a8 100644 --- a/tests/hrtf_binary_loading/constants.py +++ b/tests/hrtf_binary_loading/constants.py @@ -50,7 +50,15 @@ DECODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_dec"))] RENDERER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_rend"))] -HRTF_BINARY_FILE = "ivas_binaural_{}kHz.bin" +HRTF_BINARY_FILE_SAME_AS_ROM = "ivas_binaural_{}kHz.bin" +HRTF_BINARY_FILE_DIFF_FROM_ROM = "ivas_binaural_51_brir-lc_{}kHz.bin" +HRTF_FILES = [HRTF_BINARY_FILE_SAME_AS_ROM, HRTF_BINARY_FILE_DIFF_FROM_ROM] + +HRTF_TAG_SAME_AS_ROM = "hrtf_same_as_rom" +HRTF_TAG_DIFF_FROM_ROM = "hrtf_diff_from_rom" +HRTF_TAGS = [HRTF_TAG_SAME_AS_ROM, HRTF_TAG_DIFF_FROM_ROM] +HRTF_FILE_FOR_TAG = dict(zip(HRTF_TAGS, HRTF_FILES)) + SAMPLE_RATE = ["16", "32", "48"] INPUT_FORMATS_MC = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] # "MONO", "STEREO", @@ -59,27 +67,35 @@ INPUT_FORMATS_ISM = ["1", "2", "3", "4"] INPUT_FORMATS_MASA = {"tc": ["1", "2"], "dir": ["1", "2"]} INPUT_FORMATS_MASA_RENDERER = ["MASA1", "MASA2"] +MC_BITRATE_FOR_FORMAT = { + "5_1": 96000, + "5_1_2": 32000, + "5_1_4": 512000, + "7_1": 512000, + "7_1_4": 160000, +} + FORMAT_TO_FILE_MC_WOEXT = { - "5_1": "stv51MC{}c", - "7_1": "stv71MC{}c", - "5_1_2": "stv512MC{}c", - "5_1_4": "stv514MC{}c", - "7_1_4": "stv714MC{}c", + "5_1": "stv51MC{}c_cut", + "7_1": "stv71MC{}c_cut", + "5_1_2": "stv512MC{}c_cut", + "5_1_4": "stv514MC{}c_cut", + "7_1_4": "stv714MC{}c_cut", } FORMAT_TO_FILE_SBA_WOEXT = { - "1": "stvFOA{}c", - "2": "stv2OA{}c", - "3": "stv3OA{}c", + "1": "stvFOA{}c_cut", + "2": "stv2OA{}c_cut", + "3": "stv3OA{}c_cut", } -FORMAT_TO_FILE_ISM_WOEXT = "stv{}ISM{}s" -FORMAT_TO_FILE_MASA_WOEXT = "stv{}MASA{}TC{}c" +FORMAT_TO_FILE_ISM_WOEXT = "stv{}ISM{}s_cut" +FORMAT_TO_FILE_MASA_WOEXT = "stv{}MASA{}TC{}c_cut" BITRATE_ISM = { "1": 96000, "2": 160000, "3": 384000, - "4": 512000, + "4": 32000, } FORMAT_TO_METADATA_FILES = {"MASA": "stv{}MASA{}TC{}c.met", "ISM": "stvISM{}.csv"} diff --git a/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py b/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py index 7c3c3afc6e1112bdea95e746ede03a45b738ee5c..c66792c65323b29d20fd73312e7651ccfb52fb7e 100644 --- a/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py +++ b/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py @@ -30,31 +30,45 @@ the United Nations Convention on Contracts on the International Sales of Goods. """ import pytest +import itertools from tests.hrtf_binary_loading.utils import * +from .constants import ( + HRTF_TAGS, + MC_BITRATE_FOR_FORMAT, + HRTF_TAG_DIFF_FROM_ROM, + HRTF_TAG_SAME_AS_ROM, +) + """ Binary file """ @pytest.mark.parametrize("out_fs", SAMPLE_RATE) -def test_binary_file(test_info, out_fs): - check_binary_file(out_fs) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_binary_file(test_info, hrtf_tag, out_fs): + check_binary_file(hrtf_tag, out_fs) """ Multichannel """ -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) -@pytest.mark.parametrize("out_fs", SAMPLE_RATE) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) -def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs): - # if in_fmt in ["MONO", "STEREO"]: - # pytest.skip("MONO or STEREO to Binaural rendering unsupported") - - # -mc InputConf : Multi-channel format - # where InputConf specifies the channel configuration (5_1, 7_1, 5_1_2, 5_1_4, 7_1_4) - - bitrate = 512000 +@pytest.mark.parametrize( + ("hrtf_tag", "in_fmt", "bitrate", "out_fs", "out_fmt"), + [ + (x[0], x[1], MC_BITRATE_FOR_FORMAT[x[1]], x[2], x[3]) + for x in itertools.product( + HRTF_TAGS, INPUT_FORMATS_MC, SAMPLE_RATE, OUTPUT_FORMATS_BINAURAL[:-1] + ) + ], +) +def test_multichannel_binaural_static( + test_info, in_fmt, out_fmt, out_fs, hrtf_tag, bitrate +): + if bitrate == 32000 and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") + if bitrate == 160000 and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipped until reason for non-BE in FastConv is clarified") in_fs = 48 option_list = ["-mc", in_fmt] in_file = FORMAT_TO_FILE_MC_WOEXT[in_fmt].format(in_fs) @@ -67,23 +81,30 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs): in_fs, out_fmt, out_fs, + hrtf_tag, ) -@pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[0]]) -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) -@pytest.mark.parametrize("out_fs", SAMPLE_RATE) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) +@pytest.mark.parametrize( + ("hrtf_tag", "in_fmt", "bitrate", "out_fs", "out_fmt", "trj_file"), + [ + (x[0], x[1], MC_BITRATE_FOR_FORMAT[x[1]], x[2], x[3], x[4]) + for x in itertools.product( + HRTF_TAGS, + INPUT_FORMATS_MC, + SAMPLE_RATE, + OUTPUT_FORMATS_BINAURAL[:-1], + [HR_TRAJECTORIES_TO_TEST[0]], + ) + ], +) def test_multichannel_binaural_headrotation( - test_info, in_fmt, out_fmt, out_fs, trj_file + test_info, in_fmt, out_fmt, out_fs, trj_file, hrtf_tag, bitrate ): - # if in_fmt in ["MONO", "STEREO"]: - # pytest.skip("MONO or STEREO to Binaural rendering unsupported") - - # -mc InputConf : Multi-channel format - # where InputConf specifies the channel configuration (5_1, 7_1, 5_1_2, 5_1_4, 7_1_4) - - bitrate = 512000 + if bitrate == 32000 and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") + if bitrate == 160000 and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipped until reason for non-BE in FastConv is clarified") in_fs = 48 option_list = ["-mc", in_fmt] in_file = FORMAT_TO_FILE_MC_WOEXT[in_fmt].format(in_fs) @@ -96,6 +117,7 @@ def test_multichannel_binaural_headrotation( in_fs, out_fmt, out_fs, + hrtf_tag, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) @@ -104,13 +126,15 @@ def test_multichannel_binaural_headrotation( @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) +@pytest.mark.parametrize("bitrate", [256000, 64000]) @pytest.mark.parametrize("fs", SAMPLE_RATE[1:]) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_SBA) -def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt): - # -sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D) - # where Order specifies the Ambisionics order (1-3) - - bitrate = 256000 +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_sba_binaural_static(test_info, bitrate, in_fmt, fs, out_fmt, hrtf_tag): + if bitrate == 64000 and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") + if bitrate == 256000 and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipped until reason for non-BE in FastConv is clarified") option_list = ["-sba", in_fmt] in_file = FORMAT_TO_FILE_SBA_WOEXT[in_fmt].format(fs) @@ -122,18 +146,23 @@ def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt): fs, out_fmt, fs, + hrtf_tag, ) +@pytest.mark.parametrize("bitrate", [256000, 64000]) @pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[0]]) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) @pytest.mark.parametrize("fs", SAMPLE_RATE[1:]) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_SBA) -def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file): - # -sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D) - # where Order specifies the Ambisionics order (1-3) - - bitrate = 256000 +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_sba_binaural_headrotation( + test_info, bitrate, in_fmt, fs, out_fmt, trj_file, hrtf_tag +): + if bitrate == 64000 and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") + if bitrate == 256000 and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipped until reason for non-BE in FastConv is clarified") option_list = ["-sba", in_fmt] in_file = FORMAT_TO_FILE_SBA_WOEXT[in_fmt].format(fs) @@ -145,6 +174,7 @@ def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file): fs, out_fmt, fs, + hrtf_tag, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) @@ -156,11 +186,11 @@ def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file): @pytest.mark.parametrize("fs", SAMPLE_RATE[-1:]) @pytest.mark.parametrize("in_dir", INPUT_FORMATS_MASA["dir"]) @pytest.mark.parametrize("in_tc", INPUT_FORMATS_MASA["tc"]) -def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt): - # -masa Ch File : MASA format - # where Ch specifies the number of MASA input/transport channels (1 or 2) - # and File specifies input file containing parametric MASA metadata - +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt, hrtf_tag): + # TODO: remove once fixed + if hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") bitrate = 256000 metadata_file = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs)) @@ -176,6 +206,7 @@ def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt): fs, out_fmt, fs, + hrtf_tag, ) @@ -184,11 +215,13 @@ def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt): @pytest.mark.parametrize("fs", SAMPLE_RATE[-1:]) @pytest.mark.parametrize("in_dir", INPUT_FORMATS_MASA["dir"]) @pytest.mark.parametrize("in_tc", INPUT_FORMATS_MASA["tc"]) -def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_file): - # -masa Ch File : MASA format - # where Ch specifies the number of MASA input/transport channels (1 or 2) - # and File specifies input file containing parametric MASA metadata - +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_masa_binaural_headrotation( + test_info, in_tc, in_dir, fs, out_fmt, trj_file, hrtf_tag +): + # TODO: remove once fixed + if hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") bitrate = 256000 metadata_file = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs)) @@ -204,6 +237,7 @@ def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_f fs, out_fmt, fs, + hrtf_tag, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) @@ -214,10 +248,10 @@ def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_f @pytest.mark.parametrize("out_fmt", [OUTPUT_FORMATS_BINAURAL[0]]) @pytest.mark.parametrize("out_fs", SAMPLE_RATE) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt): - # -ism [+]Ch Files : ISM format - # where Ch specifies the number of ISMs (1-4) - # and Files specify input files containing metadata, one file per object +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt, hrtf_tag): + if in_fmt == "4" and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") in_fs = 48 bitrate = BITRATE_ISM[in_fmt] @@ -239,6 +273,7 @@ def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt): in_fs, out_fmt, out_fs, + hrtf_tag, ) @@ -246,10 +281,12 @@ def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt): @pytest.mark.parametrize("out_fmt", [OUTPUT_FORMATS_BINAURAL[0]]) @pytest.mark.parametrize("out_fs", SAMPLE_RATE) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file): - # -ism [+]Ch Files : ISM format - # where Ch specifies the number of ISMs (1-4) - # and Files specify input files containing metadata, one file per object +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_ism_binaural_headrotation( + test_info, in_fmt, out_fs, out_fmt, trj_file, hrtf_tag +): + if in_fmt == "4" and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") in_fs = 48 bitrate = BITRATE_ISM[in_fmt] @@ -271,6 +308,7 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file) in_fs, out_fmt, out_fs, + hrtf_tag, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) @@ -281,10 +319,10 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[-1:]) @pytest.mark.parametrize("out_fs", SAMPLE_RATE) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt): - # -ism [+]Ch Files : ISM format - # where Ch specifies the number of ISMs (1-4) - # and Files specify input files containing metadata, one file per object +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt, hrtf_tag): + if in_fmt == "4" and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") in_fs = 48 bitrate = BITRATE_ISM[in_fmt] @@ -306,6 +344,7 @@ def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt): in_fs, out_fmt, out_fs, + hrtf_tag, ) @@ -313,12 +352,12 @@ def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt): @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[-1:]) @pytest.mark.parametrize("out_fs", SAMPLE_RATE) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_ism_binaural_roomreverb_headrotation( - test_info, in_fmt, out_fs, out_fmt, trj_file + test_info, in_fmt, out_fs, out_fmt, trj_file, hrtf_tag ): - # -ism [+]Ch Files : ISM format - # where Ch specifies the number of ISMs (1-4) - # and Files specify input files containing metadata, one file per object + if in_fmt == "4" and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") in_fs = 48 bitrate = BITRATE_ISM[in_fmt] @@ -340,5 +379,6 @@ def test_ism_binaural_roomreverb_headrotation( in_fs, out_fmt, out_fs, + hrtf_tag, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) diff --git a/tests/hrtf_binary_loading/test_renderer_ROM_vs_file.py b/tests/hrtf_binary_loading/test_renderer_ROM_vs_file.py index 5adcc5ae732df91ae0b284f0c0dec90177f29a2e..10595b63a839fb59bcd3d94b0710f588830b6b69 100644 --- a/tests/hrtf_binary_loading/test_renderer_ROM_vs_file.py +++ b/tests/hrtf_binary_loading/test_renderer_ROM_vs_file.py @@ -43,17 +43,20 @@ from tests.renderer.constants import ( INPUT_FORMATS_MC, ) +from .constants import HRTF_TAGS + """ Ambisonics """ @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_ambisonics_binaural_static_with_binary_hrir( - test_info, in_fmt, out_fmt, frame_size + test_info, in_fmt, out_fmt, frame_size, hrtf_tag ): compare_renderer_vs_renderer_with_binary_hrir( - test_info, in_fmt, out_fmt, frame_size=frame_size + test_info, in_fmt, out_fmt, hrtf_tag, frame_size=frame_size ) @@ -61,13 +64,15 @@ def test_ambisonics_binaural_static_with_binary_hrir( @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_ambisonics_binaural_headrotation_with_binary_hrir( - test_info, in_fmt, out_fmt, trj_file, frame_size + test_info, in_fmt, out_fmt, trj_file, frame_size, hrtf_tag ): compare_renderer_vs_renderer_with_binary_hrir( test_info, in_fmt, out_fmt, + hrtf_tag, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), frame_size=frame_size, ) @@ -79,14 +84,15 @@ def test_ambisonics_binaural_headrotation_with_binary_hrir( @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_multichannel_binaural_static_with_binary_hrir( - test_info, in_fmt, out_fmt, frame_size + test_info, in_fmt, out_fmt, frame_size, hrtf_tag ): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") compare_renderer_vs_renderer_with_binary_hrir( - test_info, in_fmt, out_fmt, frame_size=frame_size + test_info, in_fmt, out_fmt, hrtf_tag, frame_size=frame_size ) @@ -94,8 +100,9 @@ def test_multichannel_binaural_static_with_binary_hrir( @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_multichannel_binaural_headrotation_with_binary_hrir( - test_info, in_fmt, out_fmt, trj_file, frame_size + test_info, in_fmt, out_fmt, trj_file, frame_size, hrtf_tag ): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") @@ -104,6 +111,7 @@ def test_multichannel_binaural_headrotation_with_binary_hrir( test_info, in_fmt, out_fmt, + hrtf_tag, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), frame_size=frame_size, ) @@ -115,14 +123,25 @@ def test_multichannel_binaural_headrotation_with_binary_hrir( @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_with_binary_hrir(test_info, in_fmt, out_fmt, frame_size): +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_ism_binaural_static_with_binary_hrir( + test_info, in_fmt, out_fmt, frame_size, hrtf_tag +): + if in_fmt == "4" and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") + try: in_meta_files = FORMAT_TO_METADATA_FILES_RENDERER[in_fmt] except: in_meta_files = None compare_renderer_vs_renderer_with_binary_hrir( - test_info, in_fmt, out_fmt, in_meta_files=in_meta_files, frame_size=frame_size + test_info, + in_fmt, + out_fmt, + hrtf_tag, + in_meta_files=in_meta_files, + frame_size=frame_size, ) @@ -130,9 +149,13 @@ def test_ism_binaural_static_with_binary_hrir(test_info, in_fmt, out_fmt, frame_ @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_ism_binaural_headrotation_with_binary_hrir( - test_info, in_fmt, out_fmt, trj_file, frame_size + test_info, in_fmt, out_fmt, trj_file, frame_size, hrtf_tag ): + if in_fmt == "4" and hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") + try: in_meta_files = FORMAT_TO_METADATA_FILES_RENDERER[in_fmt] except: @@ -142,6 +165,7 @@ def test_ism_binaural_headrotation_with_binary_hrir( test_info, in_fmt, out_fmt, + hrtf_tag, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), in_meta_files=in_meta_files, frame_size=frame_size, @@ -154,14 +178,20 @@ def test_ism_binaural_headrotation_with_binary_hrir( @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA_RENDERER) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_masa_binaural_static_with_binary_hrir(test_info, in_fmt, out_fmt, frame_size): +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) +def test_masa_binaural_static_with_binary_hrir( + test_info, in_fmt, out_fmt, frame_size, hrtf_tag +): if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]: pytest.skip("Skipping binaural room outputs for MASA as unimplemented.") + if hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") compare_renderer_vs_renderer_with_binary_hrir( test_info, in_fmt, out_fmt, + hrtf_tag, in_meta_files=FORMAT_TO_METADATA_FILES_RENDERER[in_fmt], ) @@ -170,16 +200,20 @@ def test_masa_binaural_static_with_binary_hrir(test_info, in_fmt, out_fmt, frame @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA_RENDERER) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_masa_binaural_headrotation_with_binary_hrir( - test_info, in_fmt, out_fmt, trj_file, frame_size + test_info, in_fmt, out_fmt, trj_file, frame_size, hrtf_tag ): if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]: pytest.skip("Skipping binaural room outputs for MASA as unimplemented.") + if hrtf_tag == HRTF_TAG_SAME_AS_ROM: + pytest.skip("Skipping ParamBin until binary and ROM contain same data") compare_renderer_vs_renderer_with_binary_hrir( test_info, in_fmt, out_fmt, + hrtf_tag, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), in_meta_files=FORMAT_TO_METADATA_FILES_RENDERER[in_fmt], ) @@ -191,13 +225,15 @@ def test_masa_binaural_headrotation_with_binary_hrir( @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) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_custom_ls_input_binaural_with_binary_hrir( - test_info, in_layout, out_fmt, frame_size + test_info, in_layout, out_fmt, frame_size, hrtf_tag ): compare_renderer_vs_renderer_with_binary_hrir( test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, + hrtf_tag, frame_size=frame_size, ) @@ -206,13 +242,15 @@ def test_custom_ls_input_binaural_with_binary_hrir( @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) +@pytest.mark.parametrize("hrtf_tag", HRTF_TAGS) def test_custom_ls_input_binaural_headrotation_with_binary_hrir( - test_info, in_layout, out_fmt, trj_file, frame_size + test_info, in_layout, out_fmt, trj_file, frame_size, hrtf_tag ): compare_renderer_vs_renderer_with_binary_hrir( test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, + hrtf_tag, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), frame_size=frame_size, ) diff --git a/tests/hrtf_binary_loading/utils.py b/tests/hrtf_binary_loading/utils.py index 3ce3702d8d1d089c37fe2c118cd2f72af38740c6..85d55a34d3702a935f709af3ad70b51925279fe6 100644 --- a/tests/hrtf_binary_loading/utils.py +++ b/tests/hrtf_binary_loading/utils.py @@ -140,10 +140,9 @@ def get_option_list_str(option_list): return option_list_str -def check_binary_file(out_fs): - with open( - str(HRTF_BINARY_DIR.joinpath(HRTF_BINARY_FILE.format(out_fs))), "rb" - ) as file: +def check_binary_file(hrtf_tag, out_fs): + hrtf_file = HRTF_FILE_FOR_TAG[hrtf_tag] + with open(str(HRTF_BINARY_DIR.joinpath(hrtf_file.format(out_fs))), "rb") as file: binary_data = file.read() # [Declaration of the binary file] @@ -153,7 +152,7 @@ def check_binary_file(out_fs): # Max length of HRTF data (4 bytes) binary_file_size = os.path.getsize( - str(HRTF_BINARY_DIR.joinpath(HRTF_BINARY_FILE.format(out_fs))) + str(HRTF_BINARY_DIR.joinpath(hrtf_file.format(out_fs))) ) if binary_file_size < 18: pytest.fail("HRTF binary file not compliant (size of file header)") @@ -286,13 +285,16 @@ def compare_rom_vs_binary( in_fs, out_fmt, out_fs, + hrtf_tag: str, keep_file: Optional[bool] = False, trj_file: Optional[str] = None, ): option_str = "_".join(get_option_list_str(option_list_enc)) - file_ext = f"_{option_str or ''}_{bitrate or ''}_{in_fs or ''}-{out_fs or ''}_{out_fmt or ''}-{uuid.uuid1()} " + file_ext = f"_{option_str or ''}_{bitrate or ''}_{in_fs or ''}-{out_fs or ''}_{out_fmt or ''}-{uuid.uuid1()}" - # check_binary_file(out_fs) + hrtf_file = HRTF_FILE_FOR_TAG[hrtf_tag] + + xfail = hrtf_file == HRTF_BINARY_FILE_DIFF_FROM_ROM input_path = TESTV_DIR.joinpath(in_file).with_suffix(".wav") bitstream_path = BITSTREAM_DIR.joinpath(in_file + file_ext) @@ -311,18 +313,19 @@ def compare_rom_vs_binary( ) out_rom, out_rom_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) - hrtf_file = HRTF_BINARY_FILE.format(out_fs) + hrtf_file = hrtf_file.format(out_fs) if trj_file is not None: option_list_dec.extend(["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))]) else: option_list_dec = ["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))] + out_bin_path = DEC_BINARY_DIR.joinpath(in_file + file_ext).with_suffix(".wav") run_decoder( out_fmt, out_fs, bitstream_path, out_bin_path, add_option_list=option_list_dec ) - out_bin, out_bin_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) + out_bin, out_bin_fs = pyaudio3dtools.audiofile.readfile(out_bin_path) - check_BE(test_info, out_rom, out_rom_fs, out_bin, out_bin_fs) + check_BE(test_info, out_rom, out_rom_fs, out_bin, out_bin_fs, xfail, 0) if keep_file == False: os.remove(bitstream_path) os.remove(out_rom_path) @@ -333,6 +336,7 @@ def compare_renderer_vs_renderer_with_binary_hrir( test_info, in_fmt, out_fmt, + hrtf_tag, metadata_input: Optional[str] = None, in_meta_files: Optional[list] = None, trj_file: Optional[str] = None, @@ -343,14 +347,17 @@ def compare_renderer_vs_renderer_with_binary_hrir( refveclev_file: Optional[str] = None, config_file: Optional[str] = None, frame_size: Optional[str] = "20ms", - hrir_name="ivas_binaural_48kHz.bin", keep_file=False, ): + hrtf_file = HRTF_FILE_FOR_TAG[hrtf_tag] + xfail = hrtf_file == HRTF_BINARY_FILE_DIFF_FROM_ROM + hrtf_file_dir = SCRIPTS_DIR.joinpath( "binauralRenderer_interface/binaural_renderers_hrtf_data" ) - hrtf_file_path = hrtf_file_dir.joinpath(hrir_name) + hrtf_file_path = hrtf_file_dir.joinpath(hrtf_file.format(48)) ref_out = run_renderer( + None, test_info, in_fmt, out_fmt, @@ -366,6 +373,7 @@ def compare_renderer_vs_renderer_with_binary_hrir( frame_size=frame_size, ) cut_out = run_renderer( + None, test_info, in_fmt, out_fmt, @@ -385,7 +393,7 @@ def compare_renderer_vs_renderer_with_binary_hrir( ref, ref_fs = pyaudio3dtools.audiofile.readfile(ref_out) cut, cut_fs = pyaudio3dtools.audiofile.readfile(cut_out) - check_BE(test_info, ref, ref_fs, cut, cut_fs) + check_BE(test_info, ref, ref_fs, cut, cut_fs, xfail, 0) if keep_file == False: os.remove(ref_out) os.remove(cut_out) diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 82847599b3c936263be834fc497623d6dbebf568..52d1ccf19ec1288a7e81d65457dcc877e5fd2c35 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -55,6 +55,7 @@ def test_info(request): def run_cmd(cmd, env=None): logging.info(f"\nRunning command\n{' '.join(cmd)}\n") + cmdJoin = " ".join(cmd) try: sp.run(cmd, check=True, capture_output=True, text=True, env=env) except sp.CalledProcessError as e: @@ -69,6 +70,8 @@ def check_BE( ref_fs: int, cut: np.ndarray, cut_fs: int, + xfail: bool = False, + atol: int = 2 ): if ref is None or np.array_equal(ref, np.zeros_like(ref)): pytest.fail("REF signal does not exist or is zero!") @@ -87,10 +90,13 @@ def check_BE( cut = np.pad(cut, [(0, ref.shape[0] - cut.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: + diff_found = not np.allclose(ref, cut, rtol=0, atol=atol) and max_diff > atol + if diff_found and not xfail: pytest.fail( f"CuT not BE to REF! SNR : {snr:3.2f} dB, Gain CuT: {gain_b:1.3f}, Max Diff = {int(max_diff)}" ) + elif not diff_found and xfail: + pytest.fail("Difference expected, but none found.") def run_renderer( @@ -195,6 +201,9 @@ def run_renderer( if trj_file is not None: cmd.extend(["-T", str(trj_file)]) + if hrtf_file is not None: + cmd.extend(["-hrtf", str(hrtf_file)]) + if non_diegetic_pan is not None: cmd.extend(["-non_diegetic_pan", str(non_diegetic_pan)]) if refrot_file is not None: diff --git a/tests/scale_pcm.py b/tests/scale_pcm.py index 7b6d7f1ec79573cc33eab627a997c2ced78acd98..614e8cef3f65cbaa0839b36b96fc796a00bbf43c 100755 --- a/tests/scale_pcm.py +++ b/tests/scale_pcm.py @@ -16,7 +16,6 @@ import pyivastest def scale_folder(folder, factor): - files = list(folder.glob("*.wav")) with concurrent.futures.ThreadPoolExecutor() as executor: executor.map(scale_file, files, files, [factor] * len(files)) diff --git a/tests/test_26444.py b/tests/test_26444.py index 2d1771e6a0575c9c61b5f22f144aa882e5ea10fd..3bcef2567a6a1e8c36f87a4f7e91a7ee1848b6f5 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -74,7 +74,6 @@ for s in scripts: @pytest.mark.parametrize("test_tag", list(test_dict.keys())) def test_evs_26444(test_tag): - enc_opts, dec_opts, diff_opts = test_dict[test_tag] if enc_opts: diff --git a/tests/test_param_file_ltv.py b/tests/test_param_file_ltv.py index 46bdd0dcb3947b4e93f9e19a5b67818bed15c493..44c6a388f807633e1970877abdc2ced4c0002184 100644 --- a/tests/test_param_file_ltv.py +++ b/tests/test_param_file_ltv.py @@ -438,9 +438,7 @@ def pre_proc_input(testv_file, fs): elif "stv3OA" in testv_file: num_channel = "16" cut_file = testv_file.replace(".wav", num_channel + "chn_" + cut_gain + ".wav") - cut_samples( - testv_file, cut_file, num_channel, fs + "000", cut_from, cut_len, cut_gain - ) + cut_samples(testv_file, cut_file, num_channel, cut_from, cut_len, cut_gain) return cut_file