Loading tests/test_be_for_jbm_neutral_dly_profile.py +85 −7 Original line number Diff line number Diff line import pytest import pathlib import sys import re from tempfile import TemporaryDirectory from .constants import TESTV_DIR, SCRIPTS_DIR Loading @@ -11,19 +12,94 @@ from pyaudio3dtools import audiofile, audioarray TESTCASES = [ ["stereo", 32000, "EXT"], ["stereo", 48000, "EXT"], ["stereo", 48000, "7_1_4"], ["ISM4", 48000, "BINAURAL"], ["ISM3", 64000, "BINAURAL"], ["MASA1TC", 24400, "BINAURAL"], ["MASA2TC", 80000, "BINAURAL"], ["MC_5_1", 128000, "BINAURAL"], ["MC_5_1_4", 48000, "BINAURAL"], ["MC_7_1", 96000, "BINAURAL"], ["MC_7_1_4", 160000, "7_1_4"], ["HOA3", 64000, "BINAURAL"], ["FOA", 256000, "BINAURAL"], ["OMASA_ISM1", 512000, "BINAURAL"], ["OMASA_ISM2", 24400, "MONO"], ["OMASA_ISM3", 80000, "7_1_4"], ["OMASA_ISM4", 64000, "HOA3"], ["OSBA_ISM2_HOA2", 64000, "BINAURAL"], ["OSBA_ISM4_HOA2", 512000, "BINAURAL"], ] DLY_PROFILE = SCRIPTS_DIR.joinpath("dly_error_profiles/dly_error_profile_0.dat") def get_options(in_format): def get_options(in_format, bitrate): options = list() SBA_FORMATS = ["FOA", "HOA2", "HOA3"] if in_format == "stereo": options.append("-dtx") options.append("-stereo") elif (match := re.fullmatch(r"ISM(\d)", in_format)) is not None: n_ism = int(match.groups()[0]) options.append("-dtx") options.extend(f"-ism {n_ism}".split()) for i in range(1, n_ism + 1): options.append(str(TESTV_DIR.joinpath(f"stvISM{i}.csv"))) elif (match := re.fullmatch(r"MASA(\d)TC", in_format)) is not None: n_tcs = int(match.groups()[0]) options.append("-dtx") options.extend(f"-masa {n_tcs}".split()) options.append(str(TESTV_DIR.joinpath(f"stv2MASA{n_tcs}TC48c.met"))) elif (match := re.fullmatch(r"MC_(.*)", in_format)) is not None: mc_format = match.groups()[0] options.extend(f"-mc {mc_format}".split()) elif in_format in SBA_FORMATS: if bitrate <= 80000: options.append("-dtx") options.extend(f"-sba {SBA_FORMATS.index(in_format) + 1}".split()) elif (match := re.fullmatch(r"OMASA_ISM(\d)", in_format)) is not None: n_ism = int(match.groups()[0]) n_tcs = 1 options.extend(f"-ism_masa {n_ism} {n_tcs}".split()) for i in range(1, n_ism + 1): options.append(str(TESTV_DIR.joinpath(f"stvISM{i}.csv"))) options.append( str(TESTV_DIR.joinpath(f"stvOMASA_{n_ism}ISM_1MASA{n_tcs}TC48c.met")) ) elif (match := re.fullmatch(r"OSBA_ISM(\d)_(.*)", in_format)) is not None: n_ism = int(match.groups()[0]) # NOTE: this will break if FOA is used in the future n_sba = int(match.groups()[1][-1]) options.extend(f"-ism_sba {n_ism}, -{n_sba}".split()) for i in range(1, n_ism + 1): options.append(str(TESTV_DIR.joinpath(f"stvISM{i}.csv"))) return options INPUT_FILES = { "stereo": "stvST48n.wav", "ISM3": "stv3ISM48s.wav", "ISM4": "stv4ISM48n.wav", "MASA1TC": "stv2MASA1TC48c.wav", "MASA2TC": "stv2MASA2TC48c.wav", "MC_5_1": "stv51MC48c.wav", "MC_5_1_4": "stv514MC48c.wav", "MC_7_1": "stv71MC48c.wav", "MC_7_1_4": "stv714MC48c.wav", "FOA": "stvFOA48c.wav", "HOA2": "stv2OA48c.wav", "HOA3": "stv3OA48c.wav", "OMASA_ISM1": "stvOMASA_1ISM_2MASA1TC48c.wav", "OMASA_ISM2": "stvOMASA_2ISM_2MASA1TC48c.wav", "OMASA_ISM3": "stvOMASA_3ISM_2MASA1TC48c.wav", "OMASA_ISM4": "stvOMASA_24SM_2MASA1TC48c.wav", "OSBA_ISM2_HOA2": "stvOSBA_2ISM_2OA48c.wav", "OSBA_ISM4_HOA2": "stvOSBA_4ISM_2OA48c.wav", } @pytest.mark.parametrize("in_format,bitrate,out_format", TESTCASES) def test_be_for_jbm_neutral_dly_profile( in_format, bitrate, out_format, dut_encoder_frontend, dut_decoder_frontend Loading @@ -34,9 +110,8 @@ def test_be_for_jbm_neutral_dly_profile( # run encoder bitstream_file = tmp_dir.joinpath(f"{in_format}.192").absolute() sampling_rate_khz = 48 inp_file = "stvST48c.wav" input_file = TESTV_DIR.joinpath(inp_file) options = get_options(in_format) input_file = TESTV_DIR.joinpath(INPUT_FILES[in_format]) options = get_options(in_format, bitrate) dut_encoder_frontend.run( bitrate, sampling_rate_khz, Loading @@ -63,12 +138,15 @@ def test_be_for_jbm_neutral_dly_profile( # compare no-jbm and jbm output x, _ = audiofile.readfile(output) x_jbm, _ = audiofile.readfile(output_jbm) delay = x_jbm.shape[0] - x.shape[0] print(delay) print(x_jbm[delay:, :]) print(x_jbm[delay:, :].shape) cmp_result = audioarray.compare( x, x_jbm, x_jbm[delay:, :], fs=sampling_rate_khz * 1000, per_frame=False, test_start_offset_ms=60, ) if not cmp_result["bitexact"]: pytest.fail("Difference between no jbm and zero-delay jbm decoding!") Loading
tests/test_be_for_jbm_neutral_dly_profile.py +85 −7 Original line number Diff line number Diff line import pytest import pathlib import sys import re from tempfile import TemporaryDirectory from .constants import TESTV_DIR, SCRIPTS_DIR Loading @@ -11,19 +12,94 @@ from pyaudio3dtools import audiofile, audioarray TESTCASES = [ ["stereo", 32000, "EXT"], ["stereo", 48000, "EXT"], ["stereo", 48000, "7_1_4"], ["ISM4", 48000, "BINAURAL"], ["ISM3", 64000, "BINAURAL"], ["MASA1TC", 24400, "BINAURAL"], ["MASA2TC", 80000, "BINAURAL"], ["MC_5_1", 128000, "BINAURAL"], ["MC_5_1_4", 48000, "BINAURAL"], ["MC_7_1", 96000, "BINAURAL"], ["MC_7_1_4", 160000, "7_1_4"], ["HOA3", 64000, "BINAURAL"], ["FOA", 256000, "BINAURAL"], ["OMASA_ISM1", 512000, "BINAURAL"], ["OMASA_ISM2", 24400, "MONO"], ["OMASA_ISM3", 80000, "7_1_4"], ["OMASA_ISM4", 64000, "HOA3"], ["OSBA_ISM2_HOA2", 64000, "BINAURAL"], ["OSBA_ISM4_HOA2", 512000, "BINAURAL"], ] DLY_PROFILE = SCRIPTS_DIR.joinpath("dly_error_profiles/dly_error_profile_0.dat") def get_options(in_format): def get_options(in_format, bitrate): options = list() SBA_FORMATS = ["FOA", "HOA2", "HOA3"] if in_format == "stereo": options.append("-dtx") options.append("-stereo") elif (match := re.fullmatch(r"ISM(\d)", in_format)) is not None: n_ism = int(match.groups()[0]) options.append("-dtx") options.extend(f"-ism {n_ism}".split()) for i in range(1, n_ism + 1): options.append(str(TESTV_DIR.joinpath(f"stvISM{i}.csv"))) elif (match := re.fullmatch(r"MASA(\d)TC", in_format)) is not None: n_tcs = int(match.groups()[0]) options.append("-dtx") options.extend(f"-masa {n_tcs}".split()) options.append(str(TESTV_DIR.joinpath(f"stv2MASA{n_tcs}TC48c.met"))) elif (match := re.fullmatch(r"MC_(.*)", in_format)) is not None: mc_format = match.groups()[0] options.extend(f"-mc {mc_format}".split()) elif in_format in SBA_FORMATS: if bitrate <= 80000: options.append("-dtx") options.extend(f"-sba {SBA_FORMATS.index(in_format) + 1}".split()) elif (match := re.fullmatch(r"OMASA_ISM(\d)", in_format)) is not None: n_ism = int(match.groups()[0]) n_tcs = 1 options.extend(f"-ism_masa {n_ism} {n_tcs}".split()) for i in range(1, n_ism + 1): options.append(str(TESTV_DIR.joinpath(f"stvISM{i}.csv"))) options.append( str(TESTV_DIR.joinpath(f"stvOMASA_{n_ism}ISM_1MASA{n_tcs}TC48c.met")) ) elif (match := re.fullmatch(r"OSBA_ISM(\d)_(.*)", in_format)) is not None: n_ism = int(match.groups()[0]) # NOTE: this will break if FOA is used in the future n_sba = int(match.groups()[1][-1]) options.extend(f"-ism_sba {n_ism}, -{n_sba}".split()) for i in range(1, n_ism + 1): options.append(str(TESTV_DIR.joinpath(f"stvISM{i}.csv"))) return options INPUT_FILES = { "stereo": "stvST48n.wav", "ISM3": "stv3ISM48s.wav", "ISM4": "stv4ISM48n.wav", "MASA1TC": "stv2MASA1TC48c.wav", "MASA2TC": "stv2MASA2TC48c.wav", "MC_5_1": "stv51MC48c.wav", "MC_5_1_4": "stv514MC48c.wav", "MC_7_1": "stv71MC48c.wav", "MC_7_1_4": "stv714MC48c.wav", "FOA": "stvFOA48c.wav", "HOA2": "stv2OA48c.wav", "HOA3": "stv3OA48c.wav", "OMASA_ISM1": "stvOMASA_1ISM_2MASA1TC48c.wav", "OMASA_ISM2": "stvOMASA_2ISM_2MASA1TC48c.wav", "OMASA_ISM3": "stvOMASA_3ISM_2MASA1TC48c.wav", "OMASA_ISM4": "stvOMASA_24SM_2MASA1TC48c.wav", "OSBA_ISM2_HOA2": "stvOSBA_2ISM_2OA48c.wav", "OSBA_ISM4_HOA2": "stvOSBA_4ISM_2OA48c.wav", } @pytest.mark.parametrize("in_format,bitrate,out_format", TESTCASES) def test_be_for_jbm_neutral_dly_profile( in_format, bitrate, out_format, dut_encoder_frontend, dut_decoder_frontend Loading @@ -34,9 +110,8 @@ def test_be_for_jbm_neutral_dly_profile( # run encoder bitstream_file = tmp_dir.joinpath(f"{in_format}.192").absolute() sampling_rate_khz = 48 inp_file = "stvST48c.wav" input_file = TESTV_DIR.joinpath(inp_file) options = get_options(in_format) input_file = TESTV_DIR.joinpath(INPUT_FILES[in_format]) options = get_options(in_format, bitrate) dut_encoder_frontend.run( bitrate, sampling_rate_khz, Loading @@ -63,12 +138,15 @@ def test_be_for_jbm_neutral_dly_profile( # compare no-jbm and jbm output x, _ = audiofile.readfile(output) x_jbm, _ = audiofile.readfile(output_jbm) delay = x_jbm.shape[0] - x.shape[0] print(delay) print(x_jbm[delay:, :]) print(x_jbm[delay:, :].shape) cmp_result = audioarray.compare( x, x_jbm, x_jbm[delay:, :], fs=sampling_rate_khz * 1000, per_frame=False, test_start_offset_ms=60, ) if not cmp_result["bitexact"]: pytest.fail("Difference between no jbm and zero-delay jbm decoding!")