Loading tests/binaural/constants.py +2 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ DEC_ROM_DIR = TESTS_DIR.joinpath("dec_out_rom") HRTF_BINARY_DIR = SCRIPTS_DIR.joinpath("binauralRenderer_interface", "bin") DEC_BINARY_DIR = TESTS_DIR.joinpath("dec_out_bin") ENCODER_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_cod")) ] Loading @@ -52,8 +51,9 @@ DECODER_CMD = [ HRTF_BINARY_FILE = "default_rom_{}kHz.bin" SAMPLE_RATE = ["16", "32", "48"] FORMATS_MC = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] FORMATS_MC = ["MONO", "STEREO", "5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] OUTPUT_FORMATS_BINAURAL = ["BINAURAL", "BINAURAL_ROOM_IR"] # "BINAURAL_ROOM_REVERB" HR_TRAJECTORIES_TO_TEST = ["headrot_case00_3000_q"] FORMAT_TO_FILE_WOEXT = { "5_1": "stv51MC{}c", Loading tests/binaural/test_binaural.py +24 −3 Original line number Diff line number Diff line Loading @@ -33,15 +33,36 @@ import pytest from .utils import * """ Multi-channel """ """ Multichannel """ @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("out_fs", SAMPLE_RATE) @pytest.mark.parametrize("in_fmt", FORMATS_MC) def test_mc_binaural(test_info, in_fmt, out_fmt, out_fs): compare_mc_rom_vs_binary( 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") compare_multichannel_rom_vs_binary( test_info, in_fmt, out_fmt, out_fs ) @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("out_fs", SAMPLE_RATE) @pytest.mark.parametrize("in_fmt", FORMATS_MC) 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") compare_multichannel_rom_vs_binary( test_info, in_fmt, out_fmt, out_fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) ) No newline at end of file tests/binaural/utils.py +21 −5 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ def run_cmd(cmd, env=None): f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}" ) def check_BE( test_info, afrom: np.ndarray, Loading Loading @@ -88,6 +89,7 @@ def check_BE( f"Signal from binary not BE to ROM! SNR : {snr:3.2f} dB, Gain : {gain_b:1.3f}, Max Diff = {int(max_diff)}" ) def run_encoder( bitrate: int, sampling_rate: int, Loading Loading @@ -133,12 +135,13 @@ def run_encoder( run_cmd(cmd) def run_decoder( output_config: str, output_sampling_rate: int, input_bitstream_path: Path, output_path: Path, quiet_mode: Optional[bool] = False, quiet_mode: Optional[bool] = True, plc_file: Optional[Path] = None, add_option_list: Optional[list] = None, ): Loading Loading @@ -169,8 +172,14 @@ def run_decoder( run_cmd(cmd) def compare_mc_rom_vs_binary(test_info, in_fmt, out_fmt, out_fs): def compare_multichannel_rom_vs_binary( test_info, in_fmt, out_fmt, out_fs, trj_file: Optional[str] = None ): in_fs = 48 encoding_bitrate = 512000 Loading @@ -180,11 +189,18 @@ def compare_mc_rom_vs_binary(test_info, in_fmt, out_fmt, out_fs): run_encoder(encoding_bitrate, in_fs, input_path, bitstream_path, add_option_list=option_list) out_rom_path = DEC_ROM_DIR.joinpath(FORMAT_TO_FILE_WOEXT[in_fmt].format(in_fs)).with_suffix(".wav") run_decoder(out_fmt, out_fs, bitstream_path, out_rom_path) if trj_file is not None: option_list = ["-t", trj_file] else : option_list = None run_decoder(out_fmt, out_fs, bitstream_path, out_rom_path, add_option_list=option_list) out_rom, out_rom_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) out_bin_path = DEC_BINARY_DIR.joinpath(FORMAT_TO_FILE_WOEXT[in_fmt].format(in_fs)).with_suffix(".wav") hrtf_file = HRTF_BINARY_FILE.format(out_fs) if trj_file is not None: option_list.extend(["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))]) else : option_list = ["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))] run_decoder(out_fmt, out_fs, bitstream_path, out_bin_path, add_option_list=option_list) out_bin, out_bin_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) Loading Loading
tests/binaural/constants.py +2 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ DEC_ROM_DIR = TESTS_DIR.joinpath("dec_out_rom") HRTF_BINARY_DIR = SCRIPTS_DIR.joinpath("binauralRenderer_interface", "bin") DEC_BINARY_DIR = TESTS_DIR.joinpath("dec_out_bin") ENCODER_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_cod")) ] Loading @@ -52,8 +51,9 @@ DECODER_CMD = [ HRTF_BINARY_FILE = "default_rom_{}kHz.bin" SAMPLE_RATE = ["16", "32", "48"] FORMATS_MC = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] FORMATS_MC = ["MONO", "STEREO", "5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] OUTPUT_FORMATS_BINAURAL = ["BINAURAL", "BINAURAL_ROOM_IR"] # "BINAURAL_ROOM_REVERB" HR_TRAJECTORIES_TO_TEST = ["headrot_case00_3000_q"] FORMAT_TO_FILE_WOEXT = { "5_1": "stv51MC{}c", Loading
tests/binaural/test_binaural.py +24 −3 Original line number Diff line number Diff line Loading @@ -33,15 +33,36 @@ import pytest from .utils import * """ Multi-channel """ """ Multichannel """ @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("out_fs", SAMPLE_RATE) @pytest.mark.parametrize("in_fmt", FORMATS_MC) def test_mc_binaural(test_info, in_fmt, out_fmt, out_fs): compare_mc_rom_vs_binary( 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") compare_multichannel_rom_vs_binary( test_info, in_fmt, out_fmt, out_fs ) @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("out_fs", SAMPLE_RATE) @pytest.mark.parametrize("in_fmt", FORMATS_MC) 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") compare_multichannel_rom_vs_binary( test_info, in_fmt, out_fmt, out_fs, trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")) ) No newline at end of file
tests/binaural/utils.py +21 −5 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ def run_cmd(cmd, env=None): f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}" ) def check_BE( test_info, afrom: np.ndarray, Loading Loading @@ -88,6 +89,7 @@ def check_BE( f"Signal from binary not BE to ROM! SNR : {snr:3.2f} dB, Gain : {gain_b:1.3f}, Max Diff = {int(max_diff)}" ) def run_encoder( bitrate: int, sampling_rate: int, Loading Loading @@ -133,12 +135,13 @@ def run_encoder( run_cmd(cmd) def run_decoder( output_config: str, output_sampling_rate: int, input_bitstream_path: Path, output_path: Path, quiet_mode: Optional[bool] = False, quiet_mode: Optional[bool] = True, plc_file: Optional[Path] = None, add_option_list: Optional[list] = None, ): Loading Loading @@ -169,8 +172,14 @@ def run_decoder( run_cmd(cmd) def compare_mc_rom_vs_binary(test_info, in_fmt, out_fmt, out_fs): def compare_multichannel_rom_vs_binary( test_info, in_fmt, out_fmt, out_fs, trj_file: Optional[str] = None ): in_fs = 48 encoding_bitrate = 512000 Loading @@ -180,11 +189,18 @@ def compare_mc_rom_vs_binary(test_info, in_fmt, out_fmt, out_fs): run_encoder(encoding_bitrate, in_fs, input_path, bitstream_path, add_option_list=option_list) out_rom_path = DEC_ROM_DIR.joinpath(FORMAT_TO_FILE_WOEXT[in_fmt].format(in_fs)).with_suffix(".wav") run_decoder(out_fmt, out_fs, bitstream_path, out_rom_path) if trj_file is not None: option_list = ["-t", trj_file] else : option_list = None run_decoder(out_fmt, out_fs, bitstream_path, out_rom_path, add_option_list=option_list) out_rom, out_rom_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) out_bin_path = DEC_BINARY_DIR.joinpath(FORMAT_TO_FILE_WOEXT[in_fmt].format(in_fs)).with_suffix(".wav") hrtf_file = HRTF_BINARY_FILE.format(out_fs) if trj_file is not None: option_list.extend(["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))]) else : option_list = ["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))] run_decoder(out_fmt, out_fs, bitstream_path, out_bin_path, add_option_list=option_list) out_bin, out_bin_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) Loading