Loading tests/binaural/constants.py +100 −54 Original line number Diff line number Diff line Loading @@ -30,32 +30,29 @@ the United Nations Convention on Contracts on the International Sales of Goods. """ from pathlib import Path import re from pathlib import Path from tests.renderer.constants import ( TESTS_DIR, OUTPUT_FORMATS_BINAURAL, SCRIPTS_DIR, TEST_VECTOR_DIR, TESTS_DIR, TESTV_DIR, OUTPUT_FORMATS_BINAURAL ) BITSTREAM_DIR = TESTS_DIR.joinpath("bitstream") DEC_ROM_DIR = TESTS_DIR.joinpath("dec_out_rom") HRTF_BINARY_DIR = SCRIPTS_DIR.joinpath("binauralRenderer_interface", "binaural_renderers_hrtf_data") HRTF_BINARY_DIR = SCRIPTS_DIR.joinpath( "binauralRenderer_interface", "binaural_renderers_hrtf_data" ) DEC_BINARY_DIR = TESTS_DIR.joinpath("dec_out_bin") ENCODER_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_cod")) ] ENCODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_cod"))] DECODER_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_dec")) ] DECODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_dec"))] RENDERER_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_rend")) ] RENDERER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_rend"))] HRTF_BINARY_FILE = "ivas_binaural_{}kHz.bin" SAMPLE_RATE = ["16", "32", "48"] Loading @@ -63,10 +60,7 @@ SAMPLE_RATE = ["16", "32", "48"] INPUT_FORMATS_MC = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] # "MONO", "STEREO", INPUT_FORMATS_SBA = ["1", "2", "3"] INPUT_FORMATS_ISM = ["1", "2", "3", "4"] INPUT_FORMATS_MASA = { "tc" : ["1", "2"], "dir" : ["1", "2"] } INPUT_FORMATS_MASA = {"tc": ["1", "2"], "dir": ["1", "2"]} FORMAT_TO_FILE_MC_WOEXT = { "5_1": "stv51MC{}c", Loading @@ -90,23 +84,21 @@ BITRATE_ISM = { "4": 512000, } FORMAT_TO_METADATA_FILES = { "MASA" : "stv{}MASA{}TC{}c.met", "ISM" : "stvISM{}.csv" } FORMAT_TO_METADATA_FILES = {"MASA": "stv{}MASA{}TC{}c.met", "ISM": "stvISM{}.csv"} HR_TRAJECTORIES_TO_TEST = ["headrot_case00_3000_q", "headrot"] with open(str(TESTS_DIR.parent.parent.joinpath("lib_com")) + "/ivas_cnst.h", "r") as ivas_cnst_file: with open( str(TESTS_DIR.parent.parent.joinpath("lib_com")) + "/ivas_cnst.h", "r" ) as ivas_cnst_file: ivas_cnst = ivas_cnst_file.read() # Declare renderer_types rtid = ivas_cnst.find('RENDERER_TYPE;') rtid = ivas_cnst.find("RENDERER_TYPE;") rte_c = ivas_cnst[ivas_cnst[:rtid].rfind("{") : ivas_cnst[:rtid].rfind("}")] enumid = 0 for rtid1 in [m.start() for m in re.finditer('RENDERER_', rte_c)] : for rtid1 in [m.start() for m in re.finditer("RENDERER_", rte_c)]: rtid2 = rte_c[rtid1:].find(",") if rtid2 == -1: rtid2 = rte_c[rtid1:].find(" ") Loading @@ -114,10 +106,12 @@ with open(str(TESTS_DIR.parent.parent.joinpath("lib_com")) + "/ivas_cnst.h", "r" enumid += 1 # Declare binaural_input_audio_config biacid = ivas_cnst.find('BINAURAL_INPUT_AUDIO_CONFIG;') biacid = ivas_cnst.find("BINAURAL_INPUT_AUDIO_CONFIG;") biace_c = ivas_cnst[ivas_cnst[:biacid].rfind("{") : ivas_cnst[:biacid].rfind("}")] enumid = 0 for biacid1 in [m.start() for m in re.finditer('BINAURAL_INPUT_AUDIO_CONFIG_', biace_c)] : for biacid1 in [ m.start() for m in re.finditer("BINAURAL_INPUT_AUDIO_CONFIG_", biace_c) ]: biacid2 = biace_c[biacid1:].find(",") if biacid2 == -1: biacid2 = biace_c[biacid1:].find(" ") Loading @@ -142,17 +136,69 @@ BINAURAL_INPUT_AUDIO_CONFIG_FOA = 4 BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED = 5 REQ_HRTF_CONFIG = [ {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_HOA3, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_HOA2, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_FOA, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_HOA3, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_HOA2, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_FOA, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_REVERB_ALL, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency" : -1}, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA3, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA2, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_FOA, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA3, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA2, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_FOA, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_REVERB_ALL, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency": -1, }, ] tests/binaural/test_binaural.py +68 −47 Original line number Diff line number Diff line Loading @@ -35,18 +35,19 @@ from tests.binaural.utils import * """ Binary file """ @pytest.mark.parametrize("out_fs", SAMPLE_RATE) def test_binary_file(test_info, out_fs): check_binary_file(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") Loading @@ -68,12 +69,14 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs): out_fs, ) @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) def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, out_fs, trj_file): def test_multichannel_binaural_headrotation( test_info, in_fmt, out_fmt, out_fs, trj_file ): # if in_fmt in ["MONO", "STEREO"]: # pytest.skip("MONO or STEREO to Binaural rendering unsupported") Loading @@ -93,16 +96,17 @@ def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, out_fs, in_fs, out_fmt, out_fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) """ Ambisonics """ @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_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) Loading @@ -120,12 +124,12 @@ def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt): fs, ) @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) Loading @@ -141,23 +145,26 @@ def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file): fs, out_fmt, fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) """ MASA """ @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) @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 bitrate = 256000 metadata_file=str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs))) metadata_file = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs)) ) option_list = ["-masa", in_tc, metadata_file] in_file = FORMAT_TO_FILE_MASA_WOEXT.format(in_dir, in_tc, fs) Loading @@ -171,19 +178,21 @@ def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt): fs, ) @pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[1]]) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) @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 bitrate = 256000 metadata_file=str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs))) metadata_file = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs)) ) option_list = ["-masa", in_tc, metadata_file] in_file = FORMAT_TO_FILE_MASA_WOEXT.format(in_dir, in_tc, fs) Loading @@ -195,16 +204,17 @@ def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_f fs, out_fmt, fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) """ ISM """ @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 Loading @@ -214,7 +224,9 @@ def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt): option_list = ["-ism", in_fmt] metadata_file_list = [] for n in range(int(in_fmt)): test = str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n+1, in_fs))) test = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) ) metadata_file_list.append(test) option_list.extend(metadata_file_list) in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) Loading @@ -229,12 +241,12 @@ def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt): out_fs, ) @pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[0]]) @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 Loading @@ -244,7 +256,9 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file) option_list = ["-ism", in_fmt] metadata_file_list = [] for n in range(int(in_fmt)): test = str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n+1, in_fs))) test = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) ) metadata_file_list.append(test) option_list.extend(metadata_file_list) in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) Loading @@ -257,16 +271,17 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file) in_fs, out_fmt, out_fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) """ ISM - Room Reverb """ @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 Loading @@ -276,7 +291,9 @@ def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt): option_list = ["-ism", in_fmt] metadata_file_list = [] for n in range(int(in_fmt)): test = str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n+1, in_fs))) test = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) ) metadata_file_list.append(test) option_list.extend(metadata_file_list) in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) Loading @@ -291,12 +308,14 @@ def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt): out_fs, ) @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_ISM) def test_ism_binaural_roomreverb_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file): def test_ism_binaural_roomreverb_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 Loading @@ -306,7 +325,9 @@ def test_ism_binaural_roomreverb_headrotation(test_info, in_fmt, out_fs, out_fmt option_list = ["-ism", in_fmt] metadata_file_list = [] for n in range(int(in_fmt)): test = str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n+1, in_fs))) test = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) ) metadata_file_list.append(test) option_list.extend(metadata_file_list) in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) Loading @@ -319,5 +340,5 @@ def test_ism_binaural_roomreverb_headrotation(test_info, in_fmt, out_fs, out_fmt in_fs, out_fmt, out_fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) tests/binaural/utils.py +116 −73 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
tests/binaural/constants.py +100 −54 Original line number Diff line number Diff line Loading @@ -30,32 +30,29 @@ the United Nations Convention on Contracts on the International Sales of Goods. """ from pathlib import Path import re from pathlib import Path from tests.renderer.constants import ( TESTS_DIR, OUTPUT_FORMATS_BINAURAL, SCRIPTS_DIR, TEST_VECTOR_DIR, TESTS_DIR, TESTV_DIR, OUTPUT_FORMATS_BINAURAL ) BITSTREAM_DIR = TESTS_DIR.joinpath("bitstream") DEC_ROM_DIR = TESTS_DIR.joinpath("dec_out_rom") HRTF_BINARY_DIR = SCRIPTS_DIR.joinpath("binauralRenderer_interface", "binaural_renderers_hrtf_data") HRTF_BINARY_DIR = SCRIPTS_DIR.joinpath( "binauralRenderer_interface", "binaural_renderers_hrtf_data" ) DEC_BINARY_DIR = TESTS_DIR.joinpath("dec_out_bin") ENCODER_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_cod")) ] ENCODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_cod"))] DECODER_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_dec")) ] DECODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_dec"))] RENDERER_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_rend")) ] RENDERER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_rend"))] HRTF_BINARY_FILE = "ivas_binaural_{}kHz.bin" SAMPLE_RATE = ["16", "32", "48"] Loading @@ -63,10 +60,7 @@ SAMPLE_RATE = ["16", "32", "48"] INPUT_FORMATS_MC = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] # "MONO", "STEREO", INPUT_FORMATS_SBA = ["1", "2", "3"] INPUT_FORMATS_ISM = ["1", "2", "3", "4"] INPUT_FORMATS_MASA = { "tc" : ["1", "2"], "dir" : ["1", "2"] } INPUT_FORMATS_MASA = {"tc": ["1", "2"], "dir": ["1", "2"]} FORMAT_TO_FILE_MC_WOEXT = { "5_1": "stv51MC{}c", Loading @@ -90,23 +84,21 @@ BITRATE_ISM = { "4": 512000, } FORMAT_TO_METADATA_FILES = { "MASA" : "stv{}MASA{}TC{}c.met", "ISM" : "stvISM{}.csv" } FORMAT_TO_METADATA_FILES = {"MASA": "stv{}MASA{}TC{}c.met", "ISM": "stvISM{}.csv"} HR_TRAJECTORIES_TO_TEST = ["headrot_case00_3000_q", "headrot"] with open(str(TESTS_DIR.parent.parent.joinpath("lib_com")) + "/ivas_cnst.h", "r") as ivas_cnst_file: with open( str(TESTS_DIR.parent.parent.joinpath("lib_com")) + "/ivas_cnst.h", "r" ) as ivas_cnst_file: ivas_cnst = ivas_cnst_file.read() # Declare renderer_types rtid = ivas_cnst.find('RENDERER_TYPE;') rtid = ivas_cnst.find("RENDERER_TYPE;") rte_c = ivas_cnst[ivas_cnst[:rtid].rfind("{") : ivas_cnst[:rtid].rfind("}")] enumid = 0 for rtid1 in [m.start() for m in re.finditer('RENDERER_', rte_c)] : for rtid1 in [m.start() for m in re.finditer("RENDERER_", rte_c)]: rtid2 = rte_c[rtid1:].find(",") if rtid2 == -1: rtid2 = rte_c[rtid1:].find(" ") Loading @@ -114,10 +106,12 @@ with open(str(TESTS_DIR.parent.parent.joinpath("lib_com")) + "/ivas_cnst.h", "r" enumid += 1 # Declare binaural_input_audio_config biacid = ivas_cnst.find('BINAURAL_INPUT_AUDIO_CONFIG;') biacid = ivas_cnst.find("BINAURAL_INPUT_AUDIO_CONFIG;") biace_c = ivas_cnst[ivas_cnst[:biacid].rfind("{") : ivas_cnst[:biacid].rfind("}")] enumid = 0 for biacid1 in [m.start() for m in re.finditer('BINAURAL_INPUT_AUDIO_CONFIG_', biace_c)] : for biacid1 in [ m.start() for m in re.finditer("BINAURAL_INPUT_AUDIO_CONFIG_", biace_c) ]: biacid2 = biace_c[biacid1:].find(",") if biacid2 == -1: biacid2 = biace_c[biacid1:].find(" ") Loading @@ -142,17 +136,69 @@ BINAURAL_INPUT_AUDIO_CONFIG_FOA = 4 BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED = 5 REQ_HRTF_CONFIG = [ {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_HOA3, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_HOA2, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_FOA, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency" : 48000}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_HOA3, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_HOA2, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_FOA, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency" : -1}, {"renderer_type": HRTF_READER_RENDERER_BINAURAL_REVERB_ALL, "input_configuration" : BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency" : -1}, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA3, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA2, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_FOA, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency": 48000, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA3, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA2, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_FOA, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, "sampling_frequency": -1, }, { "renderer_type": HRTF_READER_RENDERER_BINAURAL_REVERB_ALL, "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, "sampling_frequency": -1, }, ]
tests/binaural/test_binaural.py +68 −47 Original line number Diff line number Diff line Loading @@ -35,18 +35,19 @@ from tests.binaural.utils import * """ Binary file """ @pytest.mark.parametrize("out_fs", SAMPLE_RATE) def test_binary_file(test_info, out_fs): check_binary_file(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") Loading @@ -68,12 +69,14 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs): out_fs, ) @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) def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, out_fs, trj_file): def test_multichannel_binaural_headrotation( test_info, in_fmt, out_fmt, out_fs, trj_file ): # if in_fmt in ["MONO", "STEREO"]: # pytest.skip("MONO or STEREO to Binaural rendering unsupported") Loading @@ -93,16 +96,17 @@ def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, out_fs, in_fs, out_fmt, out_fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) """ Ambisonics """ @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_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) Loading @@ -120,12 +124,12 @@ def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt): fs, ) @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) Loading @@ -141,23 +145,26 @@ def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file): fs, out_fmt, fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) """ MASA """ @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) @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 bitrate = 256000 metadata_file=str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs))) metadata_file = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs)) ) option_list = ["-masa", in_tc, metadata_file] in_file = FORMAT_TO_FILE_MASA_WOEXT.format(in_dir, in_tc, fs) Loading @@ -171,19 +178,21 @@ def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt): fs, ) @pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[1]]) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) @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 bitrate = 256000 metadata_file=str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs))) metadata_file = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs)) ) option_list = ["-masa", in_tc, metadata_file] in_file = FORMAT_TO_FILE_MASA_WOEXT.format(in_dir, in_tc, fs) Loading @@ -195,16 +204,17 @@ def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_f fs, out_fmt, fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) """ ISM """ @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 Loading @@ -214,7 +224,9 @@ def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt): option_list = ["-ism", in_fmt] metadata_file_list = [] for n in range(int(in_fmt)): test = str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n+1, in_fs))) test = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) ) metadata_file_list.append(test) option_list.extend(metadata_file_list) in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) Loading @@ -229,12 +241,12 @@ def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt): out_fs, ) @pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[0]]) @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 Loading @@ -244,7 +256,9 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file) option_list = ["-ism", in_fmt] metadata_file_list = [] for n in range(int(in_fmt)): test = str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n+1, in_fs))) test = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) ) metadata_file_list.append(test) option_list.extend(metadata_file_list) in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) Loading @@ -257,16 +271,17 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file) in_fs, out_fmt, out_fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), ) """ ISM - Room Reverb """ @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 Loading @@ -276,7 +291,9 @@ def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt): option_list = ["-ism", in_fmt] metadata_file_list = [] for n in range(int(in_fmt)): test = str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n+1, in_fs))) test = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) ) metadata_file_list.append(test) option_list.extend(metadata_file_list) in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) Loading @@ -291,12 +308,14 @@ def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt): out_fs, ) @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_ISM) def test_ism_binaural_roomreverb_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file): def test_ism_binaural_roomreverb_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 Loading @@ -306,7 +325,9 @@ def test_ism_binaural_roomreverb_headrotation(test_info, in_fmt, out_fs, out_fmt option_list = ["-ism", in_fmt] metadata_file_list = [] for n in range(int(in_fmt)): test = str(TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n+1, in_fs))) test = str( TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) ) metadata_file_list.append(test) option_list.extend(metadata_file_list) in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) Loading @@ -319,5 +340,5 @@ def test_ism_binaural_roomreverb_headrotation(test_info, in_fmt, out_fs, out_fmt in_fs, out_fmt, out_fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), )
tests/binaural/utils.py +116 −73 File changed.Preview size limit exceeded, changes collapsed. Show changes