From 2a00a7d1093b0eeb9c216b82c7851c4a17fe58ba Mon Sep 17 00:00:00 2001 From: Treffehn Date: Tue, 25 Apr 2023 17:32:43 +0200 Subject: [PATCH 1/8] started adding preprocessing for background noise --- ivas_processing_scripts/__init__.py | 7 +++++++ .../processing/preprocessing_2.py | 3 ++- ivas_processing_scripts/processing/processing.py | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py index 036ddd6b..424458a9 100755 --- a/ivas_processing_scripts/__init__.py +++ b/ivas_processing_scripts/__init__.py @@ -48,6 +48,7 @@ from ivas_processing_scripts.processing.processing import ( process_item, reorder_items_list, reverse_process_2, + preprocess_background_noise, ) from ivas_processing_scripts.utils import DirManager, apply_func_parallel @@ -127,12 +128,18 @@ def main(args): # run preprocessing only once if hasattr(cfg, "preprocessing"): + # save process info for background noise + cfg.pre = cfg.proc_chains[0]["processes"][0] preprocess(cfg, logger) # preprocessing on whole signal(s) if hasattr(cfg, "preprocessing_2"): # save process info to revert it later cfg.pre2 = cfg.proc_chains[0]["processes"][0] + # preprocess background noise + if hasattr(cfg, "preprocessing") and hasattr(cfg.pre2, "background_noise"): + preprocess_background_noise(cfg) + # preprocess 2 preprocess_2(cfg, logger) # run conditions diff --git a/ivas_processing_scripts/processing/preprocessing_2.py b/ivas_processing_scripts/processing/preprocessing_2.py index 425dbd23..1d96d533 100644 --- a/ivas_processing_scripts/processing/preprocessing_2.py +++ b/ivas_processing_scripts/processing/preprocessing_2.py @@ -49,6 +49,7 @@ from ivas_processing_scripts.audiotools.wrappers.bs1770 import ( ) from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed from ivas_processing_scripts.processing.processing import Processing +from ivas_processing_scripts.audiotools.convert.__init__ import convert class Preprocessing2(Processing): @@ -115,7 +116,7 @@ class Preprocessing2(Processing): if len(noise_object.audio) < len(audio_object.audio): raise ValueError("Background noise too short for audio signal") if len(noise_object.audio) - range_delay[1] < len(audio_object.audio): - warn( + raise ValueError( "Background noise may be to short for audio signal when considering the random delay" ) diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 4b367606..88279107 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -59,6 +59,7 @@ from ivas_processing_scripts.audiotools.wrappers.bs1770 import scale_files from ivas_processing_scripts.constants import LOGGER_DATEFMT, LOGGER_FORMAT from ivas_processing_scripts.processing.config import TestConfig from ivas_processing_scripts.utils import apply_func_parallel, list_audio, pairwise +from ivas_processing_scripts.audiotools.convert.__init__ import convert class Processing(ABC): @@ -453,3 +454,18 @@ def remove_preamble(cfg): write(path_input, x, fs) return + + +def preprocess_background_noise(cfg): + # TODO + # set values + out_format = # if preprocessing formt else input format + out_fs = # if preprocessing fs else input fs + + # create audio objects + input_audio = audio.fromfile(cfg.input["fmt"], cfg.pre.background_noise["background_noise_path"], fs=cfg.input.get("fs", None)) + output_audio = audio.fromtype(cfg.out_fmt) + + # only consider format conversion, resampling and high-pass filtering + convert(input=input_audio, output=output_audio, in_fs=cfg.input.get("fmt", None), out_fs=0, in_hp50=0) + return -- GitLab From f5038c0c6a5c319fedb0544a51a44faa25a4b18a Mon Sep 17 00:00:00 2001 From: Treffehn Date: Tue, 25 Apr 2023 17:33:19 +0200 Subject: [PATCH 2/8] fixed syntax error --- ivas_processing_scripts/processing/processing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 88279107..4859c55c 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -459,13 +459,13 @@ def remove_preamble(cfg): def preprocess_background_noise(cfg): # TODO # set values - out_format = # if preprocessing formt else input format - out_fs = # if preprocessing fs else input fs + #out_format = # if preprocessing formt else input format + #out_fs = # if preprocessing fs else input fs # create audio objects input_audio = audio.fromfile(cfg.input["fmt"], cfg.pre.background_noise["background_noise_path"], fs=cfg.input.get("fs", None)) output_audio = audio.fromtype(cfg.out_fmt) - + # only consider format conversion, resampling and high-pass filtering convert(input=input_audio, output=output_audio, in_fs=cfg.input.get("fmt", None), out_fs=0, in_hp50=0) return -- GitLab From 5796a0e6cc1275622201b1968d5fdf6110b03a14 Mon Sep 17 00:00:00 2001 From: Treffehn Date: Wed, 26 Apr 2023 10:53:17 +0200 Subject: [PATCH 3/8] preprocessing background noise --- ivas_processing_scripts/processing/chains.py | 1 + .../processing/preprocessing_2.py | 7 +----- .../processing/processing.py | 24 +++++++++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ivas_processing_scripts/processing/chains.py b/ivas_processing_scripts/processing/chains.py index f830a18b..2971d2d7 100755 --- a/ivas_processing_scripts/processing/chains.py +++ b/ivas_processing_scripts/processing/chains.py @@ -139,6 +139,7 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: "seed_delay": background_cfg.get("seed_delay", 0), "master_seed": cfg.master_seed, "output_fmt": cfg.postprocessing["fmt"], + "background_object": None, } else: background = None diff --git a/ivas_processing_scripts/processing/preprocessing_2.py b/ivas_processing_scripts/processing/preprocessing_2.py index 1d96d533..0050f2e6 100644 --- a/ivas_processing_scripts/processing/preprocessing_2.py +++ b/ivas_processing_scripts/processing/preprocessing_2.py @@ -105,12 +105,7 @@ class Preprocessing2(Processing): range_delay = (1, 2400000) # load background noise - noise_object = audio.fromfile( - self.in_fmt, - self.background_noise["background_noise_path"], - fs=self.in_fs, - in_meta=in_meta, - ) + noise_object = self.background_noise["background_object"] # if noise is too short raise error if len(noise_object.audio) < len(audio_object.audio): diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 4859c55c..15d87d5b 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -457,15 +457,25 @@ def remove_preamble(cfg): def preprocess_background_noise(cfg): - # TODO - # set values - #out_format = # if preprocessing formt else input format - #out_fs = # if preprocessing fs else input fs + # TODO: add checks and errors for sampling rate and number channels compared to input signals # create audio objects - input_audio = audio.fromfile(cfg.input["fmt"], cfg.pre.background_noise["background_noise_path"], fs=cfg.input.get("fs", None)) - output_audio = audio.fromtype(cfg.out_fmt) + input_audio = audio.fromfile(cfg.input["fmt"], cfg.pre2.background_noise["background_noise_path"], fs=cfg.input.get("fs", None)) + output_audio = audio.fromtype(cfg.pre.out_fmt) + output_audio.fs = input_audio.fs + if cfg.pre.out_fs is None: + out_fs = input_audio.fs + else: + out_fs = cfg.pre.out_fs # only consider format conversion, resampling and high-pass filtering - convert(input=input_audio, output=output_audio, in_fs=cfg.input.get("fmt", None), out_fs=0, in_hp50=0) + convert(input=input_audio, output=output_audio, in_fs=input_audio.fs, out_fs=out_fs, in_hp50=cfg.pre.in_hp50) + + # save result in cfg + # cfg.preprocessing_2["background_noise"].update({"background_object": output_audio}) + cfg.proc_chains[0]["processes"][0].background_noise["background_object"] = output_audio + return + + + -- GitLab From 5d441afa0d0d1d39b12416df9f8cd5b321530669 Mon Sep 17 00:00:00 2001 From: Treffehn Date: Wed, 26 Apr 2023 11:00:21 +0200 Subject: [PATCH 4/8] restored functionality without preprocessing --- ivas_processing_scripts/processing/preprocessing_2.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ivas_processing_scripts/processing/preprocessing_2.py b/ivas_processing_scripts/processing/preprocessing_2.py index 0050f2e6..3214958c 100644 --- a/ivas_processing_scripts/processing/preprocessing_2.py +++ b/ivas_processing_scripts/processing/preprocessing_2.py @@ -105,7 +105,15 @@ class Preprocessing2(Processing): range_delay = (1, 2400000) # load background noise - noise_object = self.background_noise["background_object"] + if self.background_noise["background_object"] is not None: + noise_object = self.background_noise["background_object"] + else: + noise_object = audio.fromfile( + self.in_fmt, + self.background_noise["background_noise_path"], + fs=self.in_fs, + in_meta=in_meta, + ) # if noise is too short raise error if len(noise_object.audio) < len(audio_object.audio): -- GitLab From a67b7c947408bf4218af385d9d726b54476eab71 Mon Sep 17 00:00:00 2001 From: Treffehn Date: Wed, 26 Apr 2023 11:10:23 +0200 Subject: [PATCH 5/8] updated readme and yml --- README.md | 49 ++++++++++++++++++++++++++++++++++--------- examples/TEMPLATE.yml | 2 +- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d6fa9456..f24755fc 100755 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ conditions_to_generate: bin: ~/git/ivas-codec/IVAS_dec postprocessing: fmt: "BINAURAL" + fs: 48000 ``` @@ -126,6 +127,8 @@ postprocessing: ### Deletion of temporary directories containing ### intermediate processing files, bitstreams etc.; default = false # delete_tmp: true +### Master seed for random processes like bitstream error pattern generation; default = 0 +# master_seed: 5 ### Any relative paths will be interpreted relative to the working directory the script is called from! ### Usage of absolute paths is recommended. @@ -156,13 +159,6 @@ output_path: "./tmp_output" ### searches for the specified substring in found filenames; default = null # input_select: # - "48kHz" - -### Horizontally concatenate input items into one long file; default = false -# concatenate_input: true -### Specify preamble duration in ms; default = 0 -# preamble: 40 -### Flag wheter to use noise (amplitude +-4) for the preamble or silence; default = false (silence) -# pad_noise_preamble: true ``` @@ -216,6 +212,37 @@ input: +### Optional pre-processing on whole signal(s) + +
+Click to expand + +```yaml +# preprocessing_2: + ### Options for processing of the concatenated item (concatenate_input: true) or + ### the individual items (concatenate_input: false) after previous pre-processing step + ### Horizontally concatenate input items into one long file; default = false + # concatenate_input: true + ### Specify the concatenation order in a list of strings. If not specified, the concatenation order would be + ### as per the filesystem on the users' device + ### Should only be used if concatenate_input = true + # concatenation_order: [] + ### Specify preamble duration in ms; default = 0 + # preamble: 10000 + ### Flag wheter to use noise (amplitude +-4) for the preamble or silence; default = false (silence) + # preamble_noise: true + ### Additive background noise + # background_noise: + ### REQUIRED: SNR for background noise in dB + # snr: 10 + ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s) + # background_noise_path: ".../noise.wav" + ### Seed for delay offest; default = 0 + # seed_delay: 10 +``` + +
+ ### Bitstream processing
@@ -244,6 +271,8 @@ input: # error_pattern: "path/pattern.192" ### Error rate in percent # error_rate: 5 + ### Additional seed to specify number of preruns; default = 0 + # prerun_seed: 2 ```
@@ -337,7 +366,7 @@ conditions_to_generate: ### Path to decoder binary; default search for IVAS_dec in bin folder (primary) and PATH (secondary) bin: ~/git/ivas-codec/IVAS_dec ### Decoder output format; default = postprocessing fmt - fmt: "CICP19" + fmt: "7_1_4" ### Decoder output sampling rate; default = null (same as input) # fs: 48000 ### Additional commandline options; default = null @@ -378,8 +407,8 @@ conditions_to_generate: postprocessing: ### REQUIRED: Target format for output fmt: "BINAURAL" - ### Target sampling rate in Hz for resampling; default = null (no resampling) - # fs: 16000 + ### REQUIRED: Target sampling rate in Hz for resampling; default = null (no resampling) + fs: 48000 ### Low-pass cut-off frequency in Hz; default = null (no filtering) # lp_cutoff: 24000 ### Target loudness in LKFS; default = null (no loudness change applied) diff --git a/examples/TEMPLATE.yml b/examples/TEMPLATE.yml index 8c5fdd8e..e1210f79 100755 --- a/examples/TEMPLATE.yml +++ b/examples/TEMPLATE.yml @@ -104,7 +104,7 @@ input: # background_noise: ### REQUIRED: SNR for background noise in dB # snr: 10 - ### REQUIRED: Path to background noise + ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s) # background_noise_path: ".../noise.wav" ### Seed for delay offest; default = 0 # seed_delay: 10 -- GitLab From d985aec8a5c323db434161b3dff1c39743499f01 Mon Sep 17 00:00:00 2001 From: Treffehn Date: Wed, 26 Apr 2023 11:15:42 +0200 Subject: [PATCH 6/8] formatting --- ivas_processing_scripts/__init__.py | 2 +- ivas_processing_scripts/__main__.py | 3 +- ivas_processing_scripts/audiotools/EFAP.py | 9 +- .../audiotools/__init__.py | 6 +- .../audiotools/audioarray.py | 42 ++------- .../audiotools/audiofile.py | 23 ++--- .../binaural_datasets/binaural_dataset.py | 14 +-- .../audiotools/binauralobjectrenderer.py | 16 ++-- .../audiotools/constants.py | 87 ++++--------------- .../audiotools/convert/binaural.py | 5 +- .../audiotools/convert/channelbased.py | 9 +- .../audiotools/convert/masa.py | 10 +-- .../audiotools/convert/objectbased.py | 24 ++--- .../audiotools/convert/scenebased.py | 24 ++--- .../audiotools/metadata.py | 17 +--- .../audiotools/rotation.py | 55 ++---------- .../audiotools/wrappers/bs1770.py | 3 +- .../audiotools/wrappers/eid_xor.py | 3 +- .../audiotools/wrappers/filter.py | 14 +-- .../audiotools/wrappers/masaRenderer.py | 5 +- .../audiotools/wrappers/p50fbmnru.py | 5 +- ivas_processing_scripts/constants.py | 21 ++--- ivas_processing_scripts/processing/evs.py | 19 +--- ivas_processing_scripts/processing/ivas.py | 9 +- .../processing/preprocessing_2.py | 2 - .../processing/processing.py | 28 +++--- tests/constants.py | 9 +- tests/test_audiotools_convert.py | 14 +-- 28 files changed, 118 insertions(+), 360 deletions(-) diff --git a/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py index 424458a9..b4d9c07b 100755 --- a/ivas_processing_scripts/__init__.py +++ b/ivas_processing_scripts/__init__.py @@ -45,10 +45,10 @@ from ivas_processing_scripts.processing import chains, config from ivas_processing_scripts.processing.processing import ( preprocess, preprocess_2, + preprocess_background_noise, process_item, reorder_items_list, reverse_process_2, - preprocess_background_noise, ) from ivas_processing_scripts.utils import DirManager, apply_func_parallel diff --git a/ivas_processing_scripts/__main__.py b/ivas_processing_scripts/__main__.py index 6d793205..05352bbe 100755 --- a/ivas_processing_scripts/__main__.py +++ b/ivas_processing_scripts/__main__.py @@ -39,8 +39,7 @@ if __name__ == "__main__": description="IVAS Processing scripts for setting up listening tests. Please refer to README.md for usage." ) parser.add_argument( - "config", - help="YAML configuration file", + "config", help="YAML configuration file", ) parser.add_argument( "--debug", help="Set logging level to debug", action="store_true", default=False diff --git a/ivas_processing_scripts/audiotools/EFAP.py b/ivas_processing_scripts/audiotools/EFAP.py index b83d57e6..5dc60a0a 100755 --- a/ivas_processing_scripts/audiotools/EFAP.py +++ b/ivas_processing_scripts/audiotools/EFAP.py @@ -40,9 +40,7 @@ import numpy as np def wrap_angles( - azi: float, - ele: float, - clip_ele: Optional[bool] = False, + azi: float, ele: float, clip_ele: Optional[bool] = False, ) -> Tuple[float, float]: """ Wrap angles to (-180, 180] azimuth and [-90, 90] elevation @@ -809,10 +807,7 @@ class EFAP: for poly, mod in found_polys: surface = self.verts[poly] d = self._point_plane_dist( - surface[0].pos, - surface[1].pos, - surface[2].pos, - point_pos, + surface[0].pos, surface[1].pos, surface[2].pos, point_pos, ) if d >= 0: dist.append(d) diff --git a/ivas_processing_scripts/audiotools/__init__.py b/ivas_processing_scripts/audiotools/__init__.py index b7ceb7d1..2547618f 100755 --- a/ivas_processing_scripts/audiotools/__init__.py +++ b/ivas_processing_scripts/audiotools/__init__.py @@ -184,11 +184,7 @@ def get_args(): default=None, ) output_parser.add_argument( - "-mnru", - "--mnru_q", - type=float, - help="Flag for MNRU processing", - default=None, + "-mnru", "--mnru_q", type=float, help="Flag for MNRU processing", default=None, ) output_parser.add_argument( "-esdru", diff --git a/ivas_processing_scripts/audiotools/audioarray.py b/ivas_processing_scripts/audiotools/audioarray.py index c0909c4c..74947c65 100755 --- a/ivas_processing_scripts/audiotools/audioarray.py +++ b/ivas_processing_scripts/audiotools/audioarray.py @@ -115,9 +115,7 @@ def trim( def window( - x: np.ndarray, - fs: Optional[int] = 48000, - len_ms: Optional[float] = 100, + x: np.ndarray, fs: Optional[int] = 48000, len_ms: Optional[float] = 100, ) -> np.ndarray: """ Apply windowing to the start and end @@ -243,10 +241,7 @@ def delay( return x -def limiter( - x: np.ndarray, - fs: int, -) -> np.ndarray: +def limiter(x: np.ndarray, fs: int,) -> np.ndarray: """ Apply limiting to an audio signal @@ -319,7 +314,7 @@ def limiter( fac = attack_constant ** (np.arange(1, framesize + 1, dtype=np.float32)) else: release_constant = 0.01 ** ( - 1.0 / (0.005 * (200.0**release_heuristic) * fs) + 1.0 / (0.005 * (200.0 ** release_heuristic) * fs) ) fac = release_constant ** ( np.arange(1, framesize + 1, dtype=np.float32) @@ -347,9 +342,7 @@ def limiter( def get_framewise( - x: np.ndarray, - chunk_size: int, - zero_pad: Optional[bool] = False, + x: np.ndarray, chunk_size: int, zero_pad: Optional[bool] = False, ) -> Iterator: """ Generator to yield a signal frame by frame @@ -417,11 +410,7 @@ def framewise_io( """Deprecated functions (partly replaced by ITU binaries)""" -def resample( - x: np.ndarray, - in_freq: int, - out_freq: int, -) -> np.ndarray: +def resample(x: np.ndarray, in_freq: int, out_freq: int,) -> np.ndarray: """ Resample a multi-channel audio array @@ -456,11 +445,7 @@ def resample( return y -def lpfilter( - x: np.ndarray, - fc: int, - fs: int, -) -> np.ndarray: +def lpfilter(x: np.ndarray, fc: int, fs: int,) -> np.ndarray: """ Low-pass filter a multi-channel audio array @@ -493,10 +478,7 @@ def lpfilter( return y -def cut( - x: np.ndarray, - limits: Optional[Tuple[int, int]], -) -> np.ndarray: +def cut(x: np.ndarray, limits: Optional[Tuple[int, int]],) -> np.ndarray: """ Cut an audio array @@ -542,10 +524,7 @@ def cut( def compare( - ref: np.ndarray, - test: np.ndarray, - fs: int, - per_frame: bool = False, + ref: np.ndarray, test: np.ndarray, fs: int, per_frame: bool = False, ) -> dict: """ Compare two audio arrays @@ -633,10 +612,7 @@ def compare( return result -def getdelay( - x: np.ndarray, - y: np.ndarray, -) -> int: +def getdelay(x: np.ndarray, y: np.ndarray,) -> int: """ Get the delay between two audio signals diff --git a/ivas_processing_scripts/audiotools/audiofile.py b/ivas_processing_scripts/audiotools/audiofile.py index 954c91f8..f837d0b2 100755 --- a/ivas_processing_scripts/audiotools/audiofile.py +++ b/ivas_processing_scripts/audiotools/audiofile.py @@ -84,9 +84,7 @@ def read( ) elif data.dtype == np.float32: data = np.interp( - data, - (-1, 1), - (np.iinfo(np.int16).min, np.iinfo(np.int16).max), + data, (-1, 1), (np.iinfo(np.int16).min, np.iinfo(np.int16).max), ) x = np.array(data, dtype=outdtype) file_len = x.shape[0] @@ -107,9 +105,7 @@ def read( def write( - filename: Union[str, Path], - x: np.ndarray, - fs: Optional[int] = 48000, + filename: Union[str, Path], x: np.ndarray, fs: Optional[int] = 48000, ) -> None: """ Write audio file (.pcm, .wav or .raw) @@ -277,11 +273,7 @@ def split( return out_paths -def combine( - in_filenames: list, - out_file: str, - in_fs: Optional[int] = 48000, -) -> None: +def combine(in_filenames: list, out_file: str, in_fs: Optional[int] = 48000,) -> None: """ Combines audio files into one multi-channel file @@ -323,10 +315,7 @@ def combine( def split_channels( - in_file: str, - out_filenames: list, - in_nchans: int, - in_fs: Optional[int] = 48000, + in_file: str, out_filenames: list, in_nchans: int, in_fs: Optional[int] = 48000, ) -> None: """ Split multi-channel audio files into individual mono files @@ -366,9 +355,7 @@ def split_channels( write(out_file, y, fs=in_fs) -def parse_wave_header( - filename: str, -) -> dict: +def parse_wave_header(filename: str,) -> dict: """ Get the format information from a WAV file. Return a dictionary with the format information diff --git a/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py b/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py index e5d5ac95..1bb4cf58 100755 --- a/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py +++ b/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py @@ -46,9 +46,7 @@ from ivas_processing_scripts.audiotools.constants import ( from ivas_processing_scripts.audiotools.EFAP import wrap_angles -def load_hrtf( - filename: Union[str, Path], -) -> Tuple[np.ndarray, np.ndarray, int]: +def load_hrtf(filename: Union[str, Path],) -> Tuple[np.ndarray, np.ndarray, int]: """ Read HRTFs from Matlab dictionary file mat @@ -88,9 +86,7 @@ def load_hrtf( def load_ir( - in_fmt: str, - out_fmt: str, - dataset: Optional[str] = None, + in_fmt: str, out_fmt: str, dataset: Optional[str] = None, ) -> Tuple[np.ndarray, np.ndarray, int]: """ Load IRs for a specified rendering format @@ -244,11 +240,7 @@ def find_ir( return i_dir, dist_sort -def dist_on_sphere( - positions: np.ndarray, - azi: float, - ele: float, -) -> np.ndarray: +def dist_on_sphere(positions: np.ndarray, azi: float, ele: float,) -> np.ndarray: """ Compute great-circle distance diff --git a/ivas_processing_scripts/audiotools/binauralobjectrenderer.py b/ivas_processing_scripts/audiotools/binauralobjectrenderer.py index efc0bae7..529764a7 100755 --- a/ivas_processing_scripts/audiotools/binauralobjectrenderer.py +++ b/ivas_processing_scripts/audiotools/binauralobjectrenderer.py @@ -126,14 +126,14 @@ def barycentric_weights( v_1_plane = v_1 / v_1[2] v_2_plane = v_2 / v_2[2] v_3_plane = v_3 / v_3[2] - eps = 10**-10 + eps = 10 ** -10 # compute planar barycentric coordinates denom = (v_2_plane[1] - v_3_plane[1]) * (v_1_plane[0] - v_3_plane[0]) + ( v_3_plane[0] - v_2_plane[0] ) * (v_1_plane[1] - v_3_plane[1]) # denom is proportional to area of triangle -> when area is zero, use linear 1d interpolation - if abs(denom) <= 10**-15: + if abs(denom) <= 10 ** -15: interp_1d = True if not interp_1d: @@ -163,7 +163,7 @@ def barycentric_weights( dot[k] = np.dot(v_diff_norm[ind_i], v_diff_norm[ind_j]) k += 1 - margin = 10**-5 + margin = 10 ** -5 indices_minus_one = np.array(np.abs(dot + 1) < margin) if indices_minus_one.any(): # test if one entry is -1 v_ind = dot_v_ind[indices_minus_one] @@ -203,7 +203,7 @@ def barycentric_weights( W_3 = W_3_plane * np.dot(v_3, v_3_plane) # avoid rejection of triangles due to numerical errors since point lies on edge of tiangle - threshold_error = -1 * 10**-8 + threshold_error = -1 * 10 ** -8 if threshold_error < W_1 < 0: W_1 = 0 if threshold_error < W_2 < 0: @@ -215,8 +215,7 @@ def barycentric_weights( def get_tri_weights( - pos: np.ndarray, - SourcePosition: np.ndarray, + pos: np.ndarray, SourcePosition: np.ndarray, ) -> Tuple[np.ndarray, np.ndarray]: """ Finds suitable triangle of data points on surface in which the defined point lies @@ -341,7 +340,7 @@ def interpolate_2d( f"Sum of positive barycentric weights larger than expected: {W_1 +W_2 +W_3}" ) - threshold_error = -1 * 10**-10 + threshold_error = -1 * 10 ** -10 if W_1 < threshold_error or W_2 < threshold_error or W_3 < threshold_error: raise ValueError("Point lies outside of triangle! No interpolation possible") @@ -385,8 +384,7 @@ def interpolate_2d( def add_ghost_speaker_bary( - SourcePosition: np.ndarray, - IR: np.ndarray, + SourcePosition: np.ndarray, IR: np.ndarray, ) -> Tuple[list[bool], np.ndarray, np.ndarray]: """ Adds a ghost speaker at the poles if necessary and indicates result by bool values diff --git a/ivas_processing_scripts/audiotools/constants.py b/ivas_processing_scripts/audiotools/constants.py index c3af9d29..90a8b229 100755 --- a/ivas_processing_scripts/audiotools/constants.py +++ b/ivas_processing_scripts/audiotools/constants.py @@ -33,12 +33,8 @@ import numpy as np BINAURAL_AUDIO_FORMATS = { - "BINAURAL": { - "num_channels": 2, - }, - "BINAURAL_ROOM": { - "num_channels": 2, - }, + "BINAURAL": {"num_channels": 2,}, + "BINAURAL_ROOM": {"num_channels": 2,}, } BINAURAL_LFE_GAIN = 10 ** (5.5 / 20) @@ -241,66 +237,27 @@ CHANNEL_BASED_AUDIO_ALTNAMES = { } METADATA_ASSISTED_SPATIAL_AUDIO_FORMATS = { - "MASA1": { - "num_channels": 1, - }, - "MASA2": { - "num_channels": 2, - }, + "MASA1": {"num_channels": 1,}, + "MASA2": {"num_channels": 2,}, } OBJECT_BASED_AUDIO_FORMATS = { - "ISM1": { - "num_channels": 1, - }, - "ISM2": { - "num_channels": 2, - }, - "ISM3": { - "num_channels": 3, - }, - "ISM4": { - "num_channels": 4, - }, + "ISM1": {"num_channels": 1,}, + "ISM2": {"num_channels": 2,}, + "ISM3": {"num_channels": 3,}, + "ISM4": {"num_channels": 4,}, } SCENE_BASED_AUDIO_FORMATS = { - "FOA": { - "num_channels": 4, - "is_planar": False, - }, - "HOA2": { - "num_channels": 9, - "is_planar": False, - }, - "HOA3": { - "num_channels": 16, - "is_planar": False, - }, - "PLANARFOA": { - "num_channels": 4, - "is_planar": True, - }, - "PLANARHOA2": { - "num_channels": 9, - "is_planar": True, - }, - "PLANARHOA3": { - "num_channels": 16, - "is_planar": True, - }, - "SBA1": { - "num_channels": 4, - "is_planar": False, - }, - "SBA2": { - "num_channels": 9, - "is_planar": False, - }, - "SBA3": { - "num_channels": 16, - "is_planar": False, - }, + "FOA": {"num_channels": 4, "is_planar": False,}, + "HOA2": {"num_channels": 9, "is_planar": False,}, + "HOA3": {"num_channels": 16, "is_planar": False,}, + "PLANARFOA": {"num_channels": 4, "is_planar": True,}, + "PLANARHOA2": {"num_channels": 9, "is_planar": True,}, + "PLANARHOA3": {"num_channels": 16, "is_planar": True,}, + "SBA1": {"num_channels": 4, "is_planar": False,}, + "SBA2": {"num_channels": 9, "is_planar": False,}, + "SBA3": {"num_channels": 16, "is_planar": False,}, } SCENE_METADATA_FORMATS = {"META"} @@ -683,14 +640,8 @@ SEED_PADDING = 0 # delay in number of samples DELAY_COMPENSATION_FOR_FILTERING = { - "SHQ2": { - "up": 436, - "down": 218, - }, - "SHQ3": { - "up": 436, - "down": 145, - }, + "SHQ2": {"up": 436, "down": 218,}, + "SHQ3": {"up": 436, "down": 145,}, "MSIN": 92, "LP1p5": 322, "LP35": 232, diff --git a/ivas_processing_scripts/audiotools/convert/binaural.py b/ivas_processing_scripts/audiotools/convert/binaural.py index b23e69ee..4d600139 100755 --- a/ivas_processing_scripts/audiotools/convert/binaural.py +++ b/ivas_processing_scripts/audiotools/convert/binaural.py @@ -36,10 +36,7 @@ import numpy as np from scipy.signal import fftconvolve -def NS2SA( - fs: float, - x: float, -) -> int: +def NS2SA(fs: float, x: float,) -> int: """ Converts from nanoseconds to number of samples diff --git a/ivas_processing_scripts/audiotools/convert/channelbased.py b/ivas_processing_scripts/audiotools/convert/channelbased.py index 6bdd6b33..8f8d1a91 100755 --- a/ivas_processing_scripts/audiotools/convert/channelbased.py +++ b/ivas_processing_scripts/audiotools/convert/channelbased.py @@ -55,9 +55,7 @@ from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu def convert_channelbased( - cba: audio.ChannelBasedAudio, - out: audio.Audio, - **kwargs, + cba: audio.ChannelBasedAudio, out: audio.Audio, **kwargs, ) -> audio.Audio: """Convert channel-based audio to the requested output format""" # CBA -> Binaural @@ -280,10 +278,7 @@ def render_cba_to_sba(cba: audio.ChannelBasedAudio, sba: audio.SceneBasedAudio) scenebased.zero_vert_channels(sba) -def rotate_cba( - cba: audio.ChannelBasedAudio, - trajectory: str, -) -> np.ndarray: +def rotate_cba(cba: audio.ChannelBasedAudio, trajectory: str,) -> np.ndarray: """ Rotate MC signal by applying a rotation matrix calculated from the current quaternion in each subframe diff --git a/ivas_processing_scripts/audiotools/convert/masa.py b/ivas_processing_scripts/audiotools/convert/masa.py index c802a78b..5c39acbc 100755 --- a/ivas_processing_scripts/audiotools/convert/masa.py +++ b/ivas_processing_scripts/audiotools/convert/masa.py @@ -42,9 +42,7 @@ from ivas_processing_scripts.audiotools.wrappers.masaRenderer import masaRendere def convert_masa( - masa: audio.MetadataAssistedSpatialAudio, - out: audio.Audio, - **kwargs, + masa: audio.MetadataAssistedSpatialAudio, out: audio.Audio, **kwargs, ) -> audio.Audio: """Convert Metadata Assisted Spatial audio to the requested output format""" @@ -111,8 +109,7 @@ def render_masa_to_binaural( def render_masa_to_cba( - masa: audio.MetadataAssistedSpatialAudio, - cba: audio.ChannelBasedAudio, + masa: audio.MetadataAssistedSpatialAudio, cba: audio.ChannelBasedAudio, ) -> None: """ Rendering of MASA input signal to Channel-based format @@ -140,8 +137,7 @@ def render_masa_to_cba( def render_masa_to_sba( - masa: audio.MetadataAssistedSpatialAudio, - sba: audio.SceneBasedAudio, + masa: audio.MetadataAssistedSpatialAudio, sba: audio.SceneBasedAudio, ) -> None: """ Rendering of MASA input signal to SBA format diff --git a/ivas_processing_scripts/audiotools/convert/objectbased.py b/ivas_processing_scripts/audiotools/convert/objectbased.py index c6d0f114..c2c7a227 100755 --- a/ivas_processing_scripts/audiotools/convert/objectbased.py +++ b/ivas_processing_scripts/audiotools/convert/objectbased.py @@ -58,9 +58,7 @@ from ivas_processing_scripts.utils import apply_func_parallel def convert_objectbased( - oba: audio.ObjectBasedAudio, - out: audio.Audio, - **kwargs, + oba: audio.ObjectBasedAudio, out: audio.Audio, **kwargs, ) -> audio.Audio: """Convert an ISM signal to the requested output format""" @@ -150,8 +148,7 @@ def render_oba_to_binaural( def render_oba_to_cba( - oba: audio.ObjectBasedAudio, - cba: audio.ChannelBasedAudio, + oba: audio.ObjectBasedAudio, cba: audio.ChannelBasedAudio, ) -> None: """ Rendering of ISM input signal to channel-based format @@ -206,10 +203,7 @@ def render_oba_to_cba( gains_old = gains.copy() -def render_oba_to_sba( - oba: audio.ObjectBasedAudio, - sba: audio.SceneBasedAudio, -) -> None: +def render_oba_to_sba(oba: audio.ObjectBasedAudio, sba: audio.SceneBasedAudio,) -> None: """ Rendering of ISM input signal to SBA format @@ -257,9 +251,7 @@ def render_oba_to_sba( def rotate_oba( - azi: np.ndarray, - ele: np.ndarray, - trajectory: Optional[str] = None, + azi: np.ndarray, ele: np.ndarray, trajectory: Optional[str] = None, ) -> Tuple[np.ndarray, np.ndarray]: """ Application of head tracking trajectory @@ -342,11 +334,5 @@ def render_object( obj_audio = oba.audio[:, [obj_idx]] azi, ele = rotate_oba(azi, ele, trajectory) # convolve signal with HRIRs - result_audio = binaural_fftconv_framewise( - obj_audio, - IR, - SourcePosition, - azi, - ele, - ) + result_audio = binaural_fftconv_framewise(obj_audio, IR, SourcePosition, azi, ele,) return result_audio diff --git a/ivas_processing_scripts/audiotools/convert/scenebased.py b/ivas_processing_scripts/audiotools/convert/scenebased.py index b8295808..b27cf054 100755 --- a/ivas_processing_scripts/audiotools/convert/scenebased.py +++ b/ivas_processing_scripts/audiotools/convert/scenebased.py @@ -58,9 +58,7 @@ from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu def convert_scenebased( - sba: audio.SceneBasedAudio, - out: audio.Audio, - **kwargs, + sba: audio.SceneBasedAudio, out: audio.Audio, **kwargs, ) -> audio.Audio: """Convert scene-based audio to the requested output format""" @@ -132,8 +130,7 @@ def render_sba_to_binaural( def render_sba_to_cba( - sba: audio.SceneBasedAudio, - cba: audio.ChannelBasedAudio, + sba: audio.SceneBasedAudio, cba: audio.ChannelBasedAudio, ) -> None: """ Rendering of SBA input signal to channel-based format @@ -151,8 +148,7 @@ def render_sba_to_cba( def render_sba_to_sba( - sba_in: audio.SceneBasedAudio, - sba_out: audio.SceneBasedAudio, + sba_in: audio.SceneBasedAudio, sba_out: audio.SceneBasedAudio, ) -> None: """ Rendering of SBA input signal to SBA output format @@ -176,10 +172,7 @@ def render_sba_to_sba( zero_vert_channels(sba_out) -def rotate_sba( - sba: audio.SceneBasedAudio, - trajectory: str, -) -> np.ndarray: +def rotate_sba(sba: audio.SceneBasedAudio, trajectory: str,) -> np.ndarray: """ Rotate HOA signal by applying a rotation matrix calculated from the current quaternion in each subframe @@ -397,12 +390,7 @@ def get_allrad_mtx( hoa_dec[1, 0] = 0.5 hoa_dec[1, 1] = -0.5 else: - Y_td = getRSH( - T_DESIGN_11_AZI, - T_DESIGN_11_ELE, - ambi_order, - norm="ortho", - ) + Y_td = getRSH(T_DESIGN_11_AZI, T_DESIGN_11_ELE, ambi_order, norm="ortho",) Y_td *= np.sqrt(4 * np.pi) n_ls_woLFE = cba.num_channels - len(cba.lfe_index) @@ -421,7 +409,7 @@ def get_allrad_mtx( if rE_weight_bool: a_n = rE_weight(ambi_order) - nrg_pre = np.sqrt(len(n_ls_woLFE) / np.sum(a_n**2)) + nrg_pre = np.sqrt(len(n_ls_woLFE) / np.sum(a_n ** 2)) hoa_dec = hoa_dec @ np.diag(a_n) * nrg_pre hoa_dec = np.insert(hoa_dec, cba.lfe_index, np.zeros(n_harm), axis=0) diff --git a/ivas_processing_scripts/audiotools/metadata.py b/ivas_processing_scripts/audiotools/metadata.py index d0d44502..d5cbf167 100755 --- a/ivas_processing_scripts/audiotools/metadata.py +++ b/ivas_processing_scripts/audiotools/metadata.py @@ -454,10 +454,7 @@ def split_meta_in_file( def check_ISM_metadata( - in_meta: dict, - num_objects: int, - num_items: int, - item_names: Optional[list] = None, + in_meta: dict, num_objects: int, num_items: int, item_names: Optional[list] = None, ) -> list: """Find ISM metadata""" @@ -540,9 +537,7 @@ def metadata_search( def add_remove_preamble( - metadata, - preamble, - add: Optional[bool] = True, + metadata, preamble, add: Optional[bool] = True, ): preamble_frames = preamble / IVAS_FRAME_LEN_MS if not preamble_frames.is_integer(): @@ -554,18 +549,14 @@ def add_remove_preamble( if metadata is not None and metadata[obj_idx] is not None: if add: metadata[obj_idx] = trim( - metadata[obj_idx], - limits=(-int(preamble_frames), 0), - samples=True, + metadata[obj_idx], limits=(-int(preamble_frames), 0), samples=True, ) # add radius 1 metadata[obj_idx][: int(preamble_frames), 2] = 1 else: metadata[obj_idx] = trim( - metadata[obj_idx], - limits=(int(preamble_frames), 0), - samples=True, + metadata[obj_idx], limits=(int(preamble_frames), 0), samples=True, ) return metadata diff --git a/ivas_processing_scripts/audiotools/rotation.py b/ivas_processing_scripts/audiotools/rotation.py index 742548a8..30c6d442 100755 --- a/ivas_processing_scripts/audiotools/rotation.py +++ b/ivas_processing_scripts/audiotools/rotation.py @@ -43,12 +43,7 @@ translated from ivas_rotation.c def SHrot_p( - i: int, - l: int, - a: int, - b: int, - SHrotmat: np.ndarray, - R_lm1: np.ndarray, + i: int, l: int, a: int, b: int, SHrotmat: np.ndarray, R_lm1: np.ndarray, ) -> float: """Helper function to calculate the ps""" @@ -72,25 +67,13 @@ def SHrot_p( return p -def SHrot_u( - l: int, - m: int, - n: int, - SHrotmat: np.ndarray, - R_lm1: np.ndarray, -) -> float: +def SHrot_u(l: int, m: int, n: int, SHrotmat: np.ndarray, R_lm1: np.ndarray,) -> float: """Helper function to calculate the us""" return SHrot_p(0, l, m, n, SHrotmat, R_lm1) -def SHrot_v( - l: int, - m: int, - n: int, - SHrotmat: np.ndarray, - R_lm1: np.ndarray, -) -> float: +def SHrot_v(l: int, m: int, n: int, SHrotmat: np.ndarray, R_lm1: np.ndarray,) -> float: """Helper function to calculate the vs""" if m == 0: @@ -110,13 +93,7 @@ def SHrot_v( return p0 * (1.0 - d) + p1 * np.sqrt(1.0 + d) -def SHrot_w( - l: int, - m: int, - n: int, - SHrotmat: np.ndarray, - R_lm1: np.ndarray, -) -> float: +def SHrot_w(l: int, m: int, n: int, SHrotmat: np.ndarray, R_lm1: np.ndarray,) -> float: """Helper function to calculate the w""" if m == 0: @@ -132,10 +109,7 @@ def SHrot_w( return p0 - p1 -def SHrotmatgen( - R: np.ndarray, - order: Optional[int] = 3, -) -> np.ndarray: +def SHrotmatgen(R: np.ndarray, order: Optional[int] = 3,) -> np.ndarray: """ Calculate SHD rotation matrix from that in real space translated from ivas_rotation.c @@ -219,10 +193,7 @@ def SHrotmatgen( return SHrotmat -def Quat2Euler( - quat: np.ndarray, - degrees: bool = True, -) -> np.ndarray: +def Quat2Euler(quat: np.ndarray, degrees: bool = True,) -> np.ndarray: """Convert Quaternion to Euler angles""" sinr = +2.0 * (quat[..., 0] * quat[..., 1] + quat[..., 2] * quat[..., 3]) @@ -244,10 +215,7 @@ def Quat2Euler( return ypr -def Euler2Quat( - ypr: np.ndarray, - degrees: bool = True, -) -> np.ndarray: +def Euler2Quat(ypr: np.ndarray, degrees: bool = True,) -> np.ndarray: """Convert Euler angles to Quaternion""" if degrees: @@ -281,9 +249,7 @@ def Euler2Quat( return quat -def Quat2RotMat( - quat: np.ndarray, -) -> np.ndarray: +def Quat2RotMat(quat: np.ndarray,) -> np.ndarray: """Convert quaternion to rotation matrix""" R = np.zeros([3, 3]) @@ -352,10 +318,7 @@ def Quat2RotMat( def rotateAziEle( - azi: float, - ele: float, - R: np.ndarray, - is_planar: bool = False, + azi: float, ele: float, R: np.ndarray, is_planar: bool = False, ) -> Tuple[float, float]: """Rotate azimuth and elevation angles with rotation matrix""" diff --git a/ivas_processing_scripts/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index fe756c07..d65c12bd 100755 --- a/ivas_processing_scripts/audiotools/wrappers/bs1770.py +++ b/ivas_processing_scripts/audiotools/wrappers/bs1770.py @@ -50,8 +50,7 @@ logger.setLevel(logging.DEBUG) def bs1770demo( - input: audio.Audio, - target_loudness: Optional[float] = -26, + input: audio.Audio, target_loudness: Optional[float] = -26, ) -> Tuple[float, float]: """ Wrapper for ITU-R BS.1770-4, requires bs1770demo binary diff --git a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py index 86075b95..6cd371ed 100644 --- a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py +++ b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py @@ -150,8 +150,7 @@ def create_and_apply_error_pattern( def validate_error_pattern_application( - error_pattern: Optional[Union[Path, str]] = None, - error_rate: Optional[int] = None, + error_pattern: Optional[Union[Path, str]] = None, error_rate: Optional[int] = None, ) -> None: """ Validate settings for the network simulator diff --git a/ivas_processing_scripts/audiotools/wrappers/filter.py b/ivas_processing_scripts/audiotools/wrappers/filter.py index 9be95758..a9fdd5a4 100755 --- a/ivas_processing_scripts/audiotools/wrappers/filter.py +++ b/ivas_processing_scripts/audiotools/wrappers/filter.py @@ -184,10 +184,7 @@ def filter_itu( return output -def lpfilter_itu( - x: Audio, - fc: int, -) -> np.ndarray: +def lpfilter_itu(x: Audio, fc: int,) -> np.ndarray: """ Low-pass filter a multi-channel audio array @@ -237,9 +234,7 @@ def lpfilter_itu( return y -def hp50filter_itu( - x: Audio, -) -> np.ndarray: +def hp50filter_itu(x: Audio,) -> np.ndarray: """ High-pass 50Hz filter a multi-channel audio array @@ -291,10 +286,7 @@ def hp50filter_itu( return y -def resample_itu( - x: Audio, - fs_new: int, -) -> np.ndarray: +def resample_itu(x: Audio, fs_new: int,) -> np.ndarray: """ Resampling of multi-channel audio array diff --git a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py index ed0c3013..7e6d8419 100755 --- a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py +++ b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py @@ -42,10 +42,7 @@ from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES from ivas_processing_scripts.utils import find_binary, run -def masaRenderer( - masa: audio.MetadataAssistedSpatialAudio, - out_fmt: str, -) -> np.ndarray: +def masaRenderer(masa: audio.MetadataAssistedSpatialAudio, out_fmt: str,) -> np.ndarray: """ Wrapper for masaRenderer (from MASA reference software) diff --git a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py index 4bc6b046..92738b63 100755 --- a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py +++ b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py @@ -43,10 +43,7 @@ from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES from ivas_processing_scripts.utils import find_binary, run -def p50fbmnru( - input: audio.Audio, - q_db: float, -) -> np.ndarray: +def p50fbmnru(input: audio.Audio, q_db: float,) -> np.ndarray: """ Wrapper for P.50 Fullband MNRU (Modulated Noise Reference Unit), requires p50fbmnru binary The mode is M (Modulated Noise) as specified in section 5.2.1 of S4-141392 - EVS-7c Processing functions for characterization phase v110.doc diff --git a/ivas_processing_scripts/constants.py b/ivas_processing_scripts/constants.py index c2731016..907f1899 100755 --- a/ivas_processing_scripts/constants.py +++ b/ivas_processing_scripts/constants.py @@ -62,26 +62,15 @@ DEFAULT_CONFIG = { "master_seed": 0, "metadata_path": None, # postprocessing - "postprocessing": { - "hp50": False, - "limit": False, - }, + "postprocessing": {"hp50": False, "limit": False,}, } DEFAULT_CONFIG_EVS = { - "cod": { - "bin": find_binary("IVAS_cod", raise_error=False), - }, - "dec": { - "bin": find_binary("IVAS_dec", raise_error=False), - }, + "cod": {"bin": find_binary("IVAS_cod", raise_error=False),}, + "dec": {"bin": find_binary("IVAS_dec", raise_error=False),}, } DEFAULT_CONFIG_IVAS = { - "cod": { - "bin": find_binary("IVAS_cod", raise_error=False), - }, - "dec": { - "bin": find_binary("IVAS_dec", raise_error=False), - }, + "cod": {"bin": find_binary("IVAS_cod", raise_error=False),}, + "dec": {"bin": find_binary("IVAS_dec", raise_error=False),}, } DEFAULT_CONFIG_BINARIES = { diff --git a/ivas_processing_scripts/processing/evs.py b/ivas_processing_scripts/processing/evs.py index ebe6ebf0..8783a5cd 100755 --- a/ivas_processing_scripts/processing/evs.py +++ b/ivas_processing_scripts/processing/evs.py @@ -65,9 +65,7 @@ class EVS(Processing): self.in_fmt = audio.fromtype(self.in_fmt) self._validate() - def _validate( - self, - ): + def _validate(self,): if not self.cod_bin or not Path(self.cod_bin).exists(): if platform.system() == "Windows" and ( self.cod_bin and Path(self.cod_bin).with_suffix(".exe").exists() @@ -110,8 +108,7 @@ class EVS(Processing): ) elif self.tx.get("type", None) == "FER": validate_error_pattern_application( - self.tx["error_pattern"], - self.tx["error_rate"], + self.tx["error_pattern"], self.tx["error_rate"], ) def process( @@ -162,10 +159,7 @@ class EVS(Processing): ] split_channels( - in_file, - split_chan_files, - self.in_fmt.num_channels, - self.in_fs, + in_file, split_chan_files, self.in_fmt.num_channels, self.in_fs, ) # run processing @@ -256,12 +250,7 @@ class EVS(Processing): cmd.extend(self.cod_opts) cmd.extend( - [ - str(bitrate), - str(self.in_fs // 1000), - str(in_pcm_file), - str(bitstream), - ] + [str(bitrate), str(self.in_fs // 1000), str(in_pcm_file), str(bitstream),] ) run(cmd, logger=logger) diff --git a/ivas_processing_scripts/processing/ivas.py b/ivas_processing_scripts/processing/ivas.py index b2cae46b..ef7e4ce2 100755 --- a/ivas_processing_scripts/processing/ivas.py +++ b/ivas_processing_scripts/processing/ivas.py @@ -91,8 +91,7 @@ class IVAS(Processing): ) elif self.tx.get("type", None) == "FER": validate_error_pattern_application( - self.tx["error_pattern"], - self.tx["error_rate"], + self.tx["error_pattern"], self.tx["error_rate"], ) def process( @@ -292,11 +291,7 @@ class IVAS(Processing): if output_format == "": cmd.extend( - [ - str(self.out_fs // 1000), - str(bitstream), - str(out_file), - ] + [str(self.out_fs // 1000), str(bitstream), str(out_file),] ) else: cmd.extend( diff --git a/ivas_processing_scripts/processing/preprocessing_2.py b/ivas_processing_scripts/processing/preprocessing_2.py index 3214958c..0bacc8ee 100644 --- a/ivas_processing_scripts/processing/preprocessing_2.py +++ b/ivas_processing_scripts/processing/preprocessing_2.py @@ -32,7 +32,6 @@ import logging from pathlib import Path -from warnings import warn import numpy as np @@ -49,7 +48,6 @@ from ivas_processing_scripts.audiotools.wrappers.bs1770 import ( ) from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed from ivas_processing_scripts.processing.processing import Processing -from ivas_processing_scripts.audiotools.convert.__init__ import convert class Preprocessing2(Processing): diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 15d87d5b..0d87db1f 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -48,6 +48,7 @@ from ivas_processing_scripts.audiotools.audiofile import ( trim, write, ) +from ivas_processing_scripts.audiotools.convert.__init__ import convert from ivas_processing_scripts.audiotools.metadata import ( add_remove_preamble, concat_meta_from_file, @@ -59,7 +60,6 @@ from ivas_processing_scripts.audiotools.wrappers.bs1770 import scale_files from ivas_processing_scripts.constants import LOGGER_DATEFMT, LOGGER_FORMAT from ivas_processing_scripts.processing.config import TestConfig from ivas_processing_scripts.utils import apply_func_parallel, list_audio, pairwise -from ivas_processing_scripts.audiotools.convert.__init__ import convert class Processing(ABC): @@ -112,10 +112,7 @@ def concat_setup(cfg: TestConfig, chain, logger: logging.Logger): ) ) concat_meta_from_file( - cfg.items_list, - cfg.metadata_path, - cfg.concat_meta, - cfg.input["fmt"], + cfg.items_list, cfg.metadata_path, cfg.concat_meta, cfg.input["fmt"], ) # set input to the concatenated file we have just written to the output dir @@ -460,7 +457,11 @@ def preprocess_background_noise(cfg): # TODO: add checks and errors for sampling rate and number channels compared to input signals # create audio objects - input_audio = audio.fromfile(cfg.input["fmt"], cfg.pre2.background_noise["background_noise_path"], fs=cfg.input.get("fs", None)) + input_audio = audio.fromfile( + cfg.input["fmt"], + cfg.pre2.background_noise["background_noise_path"], + fs=cfg.input.get("fs", None), + ) output_audio = audio.fromtype(cfg.pre.out_fmt) output_audio.fs = input_audio.fs if cfg.pre.out_fs is None: @@ -469,13 +470,18 @@ def preprocess_background_noise(cfg): out_fs = cfg.pre.out_fs # only consider format conversion, resampling and high-pass filtering - convert(input=input_audio, output=output_audio, in_fs=input_audio.fs, out_fs=out_fs, in_hp50=cfg.pre.in_hp50) + convert( + input=input_audio, + output=output_audio, + in_fs=input_audio.fs, + out_fs=out_fs, + in_hp50=cfg.pre.in_hp50, + ) # save result in cfg # cfg.preprocessing_2["background_noise"].update({"background_object": output_audio}) - cfg.proc_chains[0]["processes"][0].background_noise["background_object"] = output_audio + cfg.proc_chains[0]["processes"][0].background_noise[ + "background_object" + ] = output_audio return - - - diff --git a/tests/constants.py b/tests/constants.py index 11c48dc2..16aa011a 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -175,14 +175,7 @@ METADATA_SCENES_TO_TEST_NO_BE = [SCENE_DESC_DIR.joinpath(s) for s in ["masa_scen """ Binaural rendering """ INPUT_FORMATS_BINAURAL = OUTPUT_FORMATS[2:] INPUT_FORMATS_BINAURAL.extend( - [ - "ISM1", - "ISM2", - "ISM3", - "ISM4", - "MASA1", - "MASA2", - ] + ["ISM1", "ISM2", "ISM3", "ISM4", "MASA1", "MASA2",] ) OUTPUT_FORMATS_BINAURAL = ["BINAURAL", "BINAURAL_ROOM"] HR_TRAJECTORIES_TO_TEST = [ diff --git a/tests/test_audiotools_convert.py b/tests/test_audiotools_convert.py index fa555319..d91f0b19 100644 --- a/tests/test_audiotools_convert.py +++ b/tests/test_audiotools_convert.py @@ -135,8 +135,7 @@ def test_mono_fail(out_fmt): @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input(in_layout, out_fmt): convert( - CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), - out_fmt, + CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, ) @@ -144,8 +143,7 @@ def test_custom_ls_input(in_layout, out_fmt): @pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS[1:]) def test_custom_ls_output(in_fmt, out_fmt): convert( - in_fmt, - CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), + in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), ) @@ -222,9 +220,7 @@ def test_multichannel_binaural_static(in_fmt, out_fmt): @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_headrotation(in_fmt, out_fmt, trj_file): convert( - in_fmt, - out_fmt, - trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), ) @@ -263,7 +259,5 @@ def test_masa_binaural_headrotation(in_fmt, out_fmt, trj_file): @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[1:]) def test_multichannel_binaural_headrotation(in_fmt, out_fmt, trj_file): convert( - in_fmt, - out_fmt, - trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), ) -- GitLab From cf7baceac12445ef66b82483fb940c8ba10b3833 Mon Sep 17 00:00:00 2001 From: Treffehn Date: Wed, 26 Apr 2023 11:23:32 +0200 Subject: [PATCH 7/8] different formatting --- ivas_processing_scripts/__main__.py | 3 +- ivas_processing_scripts/audiotools/EFAP.py | 9 +- .../audiotools/__init__.py | 6 +- .../audiotools/audioarray.py | 42 +++++++-- .../audiotools/audiofile.py | 23 +++-- .../binaural_datasets/binaural_dataset.py | 14 ++- .../audiotools/binauralobjectrenderer.py | 16 ++-- .../audiotools/constants.py | 87 +++++++++++++++---- .../audiotools/convert/binaural.py | 5 +- .../audiotools/convert/channelbased.py | 9 +- .../audiotools/convert/masa.py | 10 ++- .../audiotools/convert/objectbased.py | 24 +++-- .../audiotools/convert/scenebased.py | 24 +++-- .../audiotools/metadata.py | 17 +++- .../audiotools/rotation.py | 55 ++++++++++-- .../audiotools/wrappers/bs1770.py | 3 +- .../audiotools/wrappers/eid_xor.py | 3 +- .../audiotools/wrappers/filter.py | 14 ++- .../audiotools/wrappers/masaRenderer.py | 5 +- .../audiotools/wrappers/p50fbmnru.py | 5 +- ivas_processing_scripts/constants.py | 21 +++-- ivas_processing_scripts/processing/evs.py | 19 +++- ivas_processing_scripts/processing/ivas.py | 9 +- .../processing/processing.py | 5 +- tests/constants.py | 9 +- tests/test_audiotools_convert.py | 14 ++- 26 files changed, 350 insertions(+), 101 deletions(-) diff --git a/ivas_processing_scripts/__main__.py b/ivas_processing_scripts/__main__.py index 05352bbe..6d793205 100755 --- a/ivas_processing_scripts/__main__.py +++ b/ivas_processing_scripts/__main__.py @@ -39,7 +39,8 @@ if __name__ == "__main__": description="IVAS Processing scripts for setting up listening tests. Please refer to README.md for usage." ) parser.add_argument( - "config", help="YAML configuration file", + "config", + help="YAML configuration file", ) parser.add_argument( "--debug", help="Set logging level to debug", action="store_true", default=False diff --git a/ivas_processing_scripts/audiotools/EFAP.py b/ivas_processing_scripts/audiotools/EFAP.py index 5dc60a0a..b83d57e6 100755 --- a/ivas_processing_scripts/audiotools/EFAP.py +++ b/ivas_processing_scripts/audiotools/EFAP.py @@ -40,7 +40,9 @@ import numpy as np def wrap_angles( - azi: float, ele: float, clip_ele: Optional[bool] = False, + azi: float, + ele: float, + clip_ele: Optional[bool] = False, ) -> Tuple[float, float]: """ Wrap angles to (-180, 180] azimuth and [-90, 90] elevation @@ -807,7 +809,10 @@ class EFAP: for poly, mod in found_polys: surface = self.verts[poly] d = self._point_plane_dist( - surface[0].pos, surface[1].pos, surface[2].pos, point_pos, + surface[0].pos, + surface[1].pos, + surface[2].pos, + point_pos, ) if d >= 0: dist.append(d) diff --git a/ivas_processing_scripts/audiotools/__init__.py b/ivas_processing_scripts/audiotools/__init__.py index 2547618f..b7ceb7d1 100755 --- a/ivas_processing_scripts/audiotools/__init__.py +++ b/ivas_processing_scripts/audiotools/__init__.py @@ -184,7 +184,11 @@ def get_args(): default=None, ) output_parser.add_argument( - "-mnru", "--mnru_q", type=float, help="Flag for MNRU processing", default=None, + "-mnru", + "--mnru_q", + type=float, + help="Flag for MNRU processing", + default=None, ) output_parser.add_argument( "-esdru", diff --git a/ivas_processing_scripts/audiotools/audioarray.py b/ivas_processing_scripts/audiotools/audioarray.py index 74947c65..c0909c4c 100755 --- a/ivas_processing_scripts/audiotools/audioarray.py +++ b/ivas_processing_scripts/audiotools/audioarray.py @@ -115,7 +115,9 @@ def trim( def window( - x: np.ndarray, fs: Optional[int] = 48000, len_ms: Optional[float] = 100, + x: np.ndarray, + fs: Optional[int] = 48000, + len_ms: Optional[float] = 100, ) -> np.ndarray: """ Apply windowing to the start and end @@ -241,7 +243,10 @@ def delay( return x -def limiter(x: np.ndarray, fs: int,) -> np.ndarray: +def limiter( + x: np.ndarray, + fs: int, +) -> np.ndarray: """ Apply limiting to an audio signal @@ -314,7 +319,7 @@ def limiter(x: np.ndarray, fs: int,) -> np.ndarray: fac = attack_constant ** (np.arange(1, framesize + 1, dtype=np.float32)) else: release_constant = 0.01 ** ( - 1.0 / (0.005 * (200.0 ** release_heuristic) * fs) + 1.0 / (0.005 * (200.0**release_heuristic) * fs) ) fac = release_constant ** ( np.arange(1, framesize + 1, dtype=np.float32) @@ -342,7 +347,9 @@ def limiter(x: np.ndarray, fs: int,) -> np.ndarray: def get_framewise( - x: np.ndarray, chunk_size: int, zero_pad: Optional[bool] = False, + x: np.ndarray, + chunk_size: int, + zero_pad: Optional[bool] = False, ) -> Iterator: """ Generator to yield a signal frame by frame @@ -410,7 +417,11 @@ def framewise_io( """Deprecated functions (partly replaced by ITU binaries)""" -def resample(x: np.ndarray, in_freq: int, out_freq: int,) -> np.ndarray: +def resample( + x: np.ndarray, + in_freq: int, + out_freq: int, +) -> np.ndarray: """ Resample a multi-channel audio array @@ -445,7 +456,11 @@ def resample(x: np.ndarray, in_freq: int, out_freq: int,) -> np.ndarray: return y -def lpfilter(x: np.ndarray, fc: int, fs: int,) -> np.ndarray: +def lpfilter( + x: np.ndarray, + fc: int, + fs: int, +) -> np.ndarray: """ Low-pass filter a multi-channel audio array @@ -478,7 +493,10 @@ def lpfilter(x: np.ndarray, fc: int, fs: int,) -> np.ndarray: return y -def cut(x: np.ndarray, limits: Optional[Tuple[int, int]],) -> np.ndarray: +def cut( + x: np.ndarray, + limits: Optional[Tuple[int, int]], +) -> np.ndarray: """ Cut an audio array @@ -524,7 +542,10 @@ def cut(x: np.ndarray, limits: Optional[Tuple[int, int]],) -> np.ndarray: def compare( - ref: np.ndarray, test: np.ndarray, fs: int, per_frame: bool = False, + ref: np.ndarray, + test: np.ndarray, + fs: int, + per_frame: bool = False, ) -> dict: """ Compare two audio arrays @@ -612,7 +633,10 @@ def compare( return result -def getdelay(x: np.ndarray, y: np.ndarray,) -> int: +def getdelay( + x: np.ndarray, + y: np.ndarray, +) -> int: """ Get the delay between two audio signals diff --git a/ivas_processing_scripts/audiotools/audiofile.py b/ivas_processing_scripts/audiotools/audiofile.py index f837d0b2..954c91f8 100755 --- a/ivas_processing_scripts/audiotools/audiofile.py +++ b/ivas_processing_scripts/audiotools/audiofile.py @@ -84,7 +84,9 @@ def read( ) elif data.dtype == np.float32: data = np.interp( - data, (-1, 1), (np.iinfo(np.int16).min, np.iinfo(np.int16).max), + data, + (-1, 1), + (np.iinfo(np.int16).min, np.iinfo(np.int16).max), ) x = np.array(data, dtype=outdtype) file_len = x.shape[0] @@ -105,7 +107,9 @@ def read( def write( - filename: Union[str, Path], x: np.ndarray, fs: Optional[int] = 48000, + filename: Union[str, Path], + x: np.ndarray, + fs: Optional[int] = 48000, ) -> None: """ Write audio file (.pcm, .wav or .raw) @@ -273,7 +277,11 @@ def split( return out_paths -def combine(in_filenames: list, out_file: str, in_fs: Optional[int] = 48000,) -> None: +def combine( + in_filenames: list, + out_file: str, + in_fs: Optional[int] = 48000, +) -> None: """ Combines audio files into one multi-channel file @@ -315,7 +323,10 @@ def combine(in_filenames: list, out_file: str, in_fs: Optional[int] = 48000,) -> def split_channels( - in_file: str, out_filenames: list, in_nchans: int, in_fs: Optional[int] = 48000, + in_file: str, + out_filenames: list, + in_nchans: int, + in_fs: Optional[int] = 48000, ) -> None: """ Split multi-channel audio files into individual mono files @@ -355,7 +366,9 @@ def split_channels( write(out_file, y, fs=in_fs) -def parse_wave_header(filename: str,) -> dict: +def parse_wave_header( + filename: str, +) -> dict: """ Get the format information from a WAV file. Return a dictionary with the format information diff --git a/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py b/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py index 1bb4cf58..e5d5ac95 100755 --- a/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py +++ b/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py @@ -46,7 +46,9 @@ from ivas_processing_scripts.audiotools.constants import ( from ivas_processing_scripts.audiotools.EFAP import wrap_angles -def load_hrtf(filename: Union[str, Path],) -> Tuple[np.ndarray, np.ndarray, int]: +def load_hrtf( + filename: Union[str, Path], +) -> Tuple[np.ndarray, np.ndarray, int]: """ Read HRTFs from Matlab dictionary file mat @@ -86,7 +88,9 @@ def load_hrtf(filename: Union[str, Path],) -> Tuple[np.ndarray, np.ndarray, int] def load_ir( - in_fmt: str, out_fmt: str, dataset: Optional[str] = None, + in_fmt: str, + out_fmt: str, + dataset: Optional[str] = None, ) -> Tuple[np.ndarray, np.ndarray, int]: """ Load IRs for a specified rendering format @@ -240,7 +244,11 @@ def find_ir( return i_dir, dist_sort -def dist_on_sphere(positions: np.ndarray, azi: float, ele: float,) -> np.ndarray: +def dist_on_sphere( + positions: np.ndarray, + azi: float, + ele: float, +) -> np.ndarray: """ Compute great-circle distance diff --git a/ivas_processing_scripts/audiotools/binauralobjectrenderer.py b/ivas_processing_scripts/audiotools/binauralobjectrenderer.py index 529764a7..efc0bae7 100755 --- a/ivas_processing_scripts/audiotools/binauralobjectrenderer.py +++ b/ivas_processing_scripts/audiotools/binauralobjectrenderer.py @@ -126,14 +126,14 @@ def barycentric_weights( v_1_plane = v_1 / v_1[2] v_2_plane = v_2 / v_2[2] v_3_plane = v_3 / v_3[2] - eps = 10 ** -10 + eps = 10**-10 # compute planar barycentric coordinates denom = (v_2_plane[1] - v_3_plane[1]) * (v_1_plane[0] - v_3_plane[0]) + ( v_3_plane[0] - v_2_plane[0] ) * (v_1_plane[1] - v_3_plane[1]) # denom is proportional to area of triangle -> when area is zero, use linear 1d interpolation - if abs(denom) <= 10 ** -15: + if abs(denom) <= 10**-15: interp_1d = True if not interp_1d: @@ -163,7 +163,7 @@ def barycentric_weights( dot[k] = np.dot(v_diff_norm[ind_i], v_diff_norm[ind_j]) k += 1 - margin = 10 ** -5 + margin = 10**-5 indices_minus_one = np.array(np.abs(dot + 1) < margin) if indices_minus_one.any(): # test if one entry is -1 v_ind = dot_v_ind[indices_minus_one] @@ -203,7 +203,7 @@ def barycentric_weights( W_3 = W_3_plane * np.dot(v_3, v_3_plane) # avoid rejection of triangles due to numerical errors since point lies on edge of tiangle - threshold_error = -1 * 10 ** -8 + threshold_error = -1 * 10**-8 if threshold_error < W_1 < 0: W_1 = 0 if threshold_error < W_2 < 0: @@ -215,7 +215,8 @@ def barycentric_weights( def get_tri_weights( - pos: np.ndarray, SourcePosition: np.ndarray, + pos: np.ndarray, + SourcePosition: np.ndarray, ) -> Tuple[np.ndarray, np.ndarray]: """ Finds suitable triangle of data points on surface in which the defined point lies @@ -340,7 +341,7 @@ def interpolate_2d( f"Sum of positive barycentric weights larger than expected: {W_1 +W_2 +W_3}" ) - threshold_error = -1 * 10 ** -10 + threshold_error = -1 * 10**-10 if W_1 < threshold_error or W_2 < threshold_error or W_3 < threshold_error: raise ValueError("Point lies outside of triangle! No interpolation possible") @@ -384,7 +385,8 @@ def interpolate_2d( def add_ghost_speaker_bary( - SourcePosition: np.ndarray, IR: np.ndarray, + SourcePosition: np.ndarray, + IR: np.ndarray, ) -> Tuple[list[bool], np.ndarray, np.ndarray]: """ Adds a ghost speaker at the poles if necessary and indicates result by bool values diff --git a/ivas_processing_scripts/audiotools/constants.py b/ivas_processing_scripts/audiotools/constants.py index 90a8b229..c3af9d29 100755 --- a/ivas_processing_scripts/audiotools/constants.py +++ b/ivas_processing_scripts/audiotools/constants.py @@ -33,8 +33,12 @@ import numpy as np BINAURAL_AUDIO_FORMATS = { - "BINAURAL": {"num_channels": 2,}, - "BINAURAL_ROOM": {"num_channels": 2,}, + "BINAURAL": { + "num_channels": 2, + }, + "BINAURAL_ROOM": { + "num_channels": 2, + }, } BINAURAL_LFE_GAIN = 10 ** (5.5 / 20) @@ -237,27 +241,66 @@ CHANNEL_BASED_AUDIO_ALTNAMES = { } METADATA_ASSISTED_SPATIAL_AUDIO_FORMATS = { - "MASA1": {"num_channels": 1,}, - "MASA2": {"num_channels": 2,}, + "MASA1": { + "num_channels": 1, + }, + "MASA2": { + "num_channels": 2, + }, } OBJECT_BASED_AUDIO_FORMATS = { - "ISM1": {"num_channels": 1,}, - "ISM2": {"num_channels": 2,}, - "ISM3": {"num_channels": 3,}, - "ISM4": {"num_channels": 4,}, + "ISM1": { + "num_channels": 1, + }, + "ISM2": { + "num_channels": 2, + }, + "ISM3": { + "num_channels": 3, + }, + "ISM4": { + "num_channels": 4, + }, } SCENE_BASED_AUDIO_FORMATS = { - "FOA": {"num_channels": 4, "is_planar": False,}, - "HOA2": {"num_channels": 9, "is_planar": False,}, - "HOA3": {"num_channels": 16, "is_planar": False,}, - "PLANARFOA": {"num_channels": 4, "is_planar": True,}, - "PLANARHOA2": {"num_channels": 9, "is_planar": True,}, - "PLANARHOA3": {"num_channels": 16, "is_planar": True,}, - "SBA1": {"num_channels": 4, "is_planar": False,}, - "SBA2": {"num_channels": 9, "is_planar": False,}, - "SBA3": {"num_channels": 16, "is_planar": False,}, + "FOA": { + "num_channels": 4, + "is_planar": False, + }, + "HOA2": { + "num_channels": 9, + "is_planar": False, + }, + "HOA3": { + "num_channels": 16, + "is_planar": False, + }, + "PLANARFOA": { + "num_channels": 4, + "is_planar": True, + }, + "PLANARHOA2": { + "num_channels": 9, + "is_planar": True, + }, + "PLANARHOA3": { + "num_channels": 16, + "is_planar": True, + }, + "SBA1": { + "num_channels": 4, + "is_planar": False, + }, + "SBA2": { + "num_channels": 9, + "is_planar": False, + }, + "SBA3": { + "num_channels": 16, + "is_planar": False, + }, } SCENE_METADATA_FORMATS = {"META"} @@ -640,8 +683,14 @@ SEED_PADDING = 0 # delay in number of samples DELAY_COMPENSATION_FOR_FILTERING = { - "SHQ2": {"up": 436, "down": 218,}, - "SHQ3": {"up": 436, "down": 145,}, + "SHQ2": { + "up": 436, + "down": 218, + }, + "SHQ3": { + "up": 436, + "down": 145, + }, "MSIN": 92, "LP1p5": 322, "LP35": 232, diff --git a/ivas_processing_scripts/audiotools/convert/binaural.py b/ivas_processing_scripts/audiotools/convert/binaural.py index 4d600139..b23e69ee 100755 --- a/ivas_processing_scripts/audiotools/convert/binaural.py +++ b/ivas_processing_scripts/audiotools/convert/binaural.py @@ -36,7 +36,10 @@ import numpy as np from scipy.signal import fftconvolve -def NS2SA(fs: float, x: float,) -> int: +def NS2SA( + fs: float, + x: float, +) -> int: """ Converts from nanoseconds to number of samples diff --git a/ivas_processing_scripts/audiotools/convert/channelbased.py b/ivas_processing_scripts/audiotools/convert/channelbased.py index 8f8d1a91..6bdd6b33 100755 --- a/ivas_processing_scripts/audiotools/convert/channelbased.py +++ b/ivas_processing_scripts/audiotools/convert/channelbased.py @@ -55,7 +55,9 @@ from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu def convert_channelbased( - cba: audio.ChannelBasedAudio, out: audio.Audio, **kwargs, + cba: audio.ChannelBasedAudio, + out: audio.Audio, + **kwargs, ) -> audio.Audio: """Convert channel-based audio to the requested output format""" # CBA -> Binaural @@ -278,7 +280,10 @@ def render_cba_to_sba(cba: audio.ChannelBasedAudio, sba: audio.SceneBasedAudio) scenebased.zero_vert_channels(sba) -def rotate_cba(cba: audio.ChannelBasedAudio, trajectory: str,) -> np.ndarray: +def rotate_cba( + cba: audio.ChannelBasedAudio, + trajectory: str, +) -> np.ndarray: """ Rotate MC signal by applying a rotation matrix calculated from the current quaternion in each subframe diff --git a/ivas_processing_scripts/audiotools/convert/masa.py b/ivas_processing_scripts/audiotools/convert/masa.py index 5c39acbc..c802a78b 100755 --- a/ivas_processing_scripts/audiotools/convert/masa.py +++ b/ivas_processing_scripts/audiotools/convert/masa.py @@ -42,7 +42,9 @@ from ivas_processing_scripts.audiotools.wrappers.masaRenderer import masaRendere def convert_masa( - masa: audio.MetadataAssistedSpatialAudio, out: audio.Audio, **kwargs, + masa: audio.MetadataAssistedSpatialAudio, + out: audio.Audio, + **kwargs, ) -> audio.Audio: """Convert Metadata Assisted Spatial audio to the requested output format""" @@ -109,7 +111,8 @@ def render_masa_to_binaural( def render_masa_to_cba( - masa: audio.MetadataAssistedSpatialAudio, cba: audio.ChannelBasedAudio, + masa: audio.MetadataAssistedSpatialAudio, + cba: audio.ChannelBasedAudio, ) -> None: """ Rendering of MASA input signal to Channel-based format @@ -137,7 +140,8 @@ def render_masa_to_cba( def render_masa_to_sba( - masa: audio.MetadataAssistedSpatialAudio, sba: audio.SceneBasedAudio, + masa: audio.MetadataAssistedSpatialAudio, + sba: audio.SceneBasedAudio, ) -> None: """ Rendering of MASA input signal to SBA format diff --git a/ivas_processing_scripts/audiotools/convert/objectbased.py b/ivas_processing_scripts/audiotools/convert/objectbased.py index c2c7a227..c6d0f114 100755 --- a/ivas_processing_scripts/audiotools/convert/objectbased.py +++ b/ivas_processing_scripts/audiotools/convert/objectbased.py @@ -58,7 +58,9 @@ from ivas_processing_scripts.utils import apply_func_parallel def convert_objectbased( - oba: audio.ObjectBasedAudio, out: audio.Audio, **kwargs, + oba: audio.ObjectBasedAudio, + out: audio.Audio, + **kwargs, ) -> audio.Audio: """Convert an ISM signal to the requested output format""" @@ -148,7 +150,8 @@ def render_oba_to_binaural( def render_oba_to_cba( - oba: audio.ObjectBasedAudio, cba: audio.ChannelBasedAudio, + oba: audio.ObjectBasedAudio, + cba: audio.ChannelBasedAudio, ) -> None: """ Rendering of ISM input signal to channel-based format @@ -203,7 +206,10 @@ def render_oba_to_cba( gains_old = gains.copy() -def render_oba_to_sba(oba: audio.ObjectBasedAudio, sba: audio.SceneBasedAudio,) -> None: +def render_oba_to_sba( + oba: audio.ObjectBasedAudio, + sba: audio.SceneBasedAudio, +) -> None: """ Rendering of ISM input signal to SBA format @@ -251,7 +257,9 @@ def render_oba_to_sba(oba: audio.ObjectBasedAudio, sba: audio.SceneBasedAudio,) def rotate_oba( - azi: np.ndarray, ele: np.ndarray, trajectory: Optional[str] = None, + azi: np.ndarray, + ele: np.ndarray, + trajectory: Optional[str] = None, ) -> Tuple[np.ndarray, np.ndarray]: """ Application of head tracking trajectory @@ -334,5 +342,11 @@ def render_object( obj_audio = oba.audio[:, [obj_idx]] azi, ele = rotate_oba(azi, ele, trajectory) # convolve signal with HRIRs - result_audio = binaural_fftconv_framewise(obj_audio, IR, SourcePosition, azi, ele,) + result_audio = binaural_fftconv_framewise( + obj_audio, + IR, + SourcePosition, + azi, + ele, + ) return result_audio diff --git a/ivas_processing_scripts/audiotools/convert/scenebased.py b/ivas_processing_scripts/audiotools/convert/scenebased.py index b27cf054..b8295808 100755 --- a/ivas_processing_scripts/audiotools/convert/scenebased.py +++ b/ivas_processing_scripts/audiotools/convert/scenebased.py @@ -58,7 +58,9 @@ from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu def convert_scenebased( - sba: audio.SceneBasedAudio, out: audio.Audio, **kwargs, + sba: audio.SceneBasedAudio, + out: audio.Audio, + **kwargs, ) -> audio.Audio: """Convert scene-based audio to the requested output format""" @@ -130,7 +132,8 @@ def render_sba_to_binaural( def render_sba_to_cba( - sba: audio.SceneBasedAudio, cba: audio.ChannelBasedAudio, + sba: audio.SceneBasedAudio, + cba: audio.ChannelBasedAudio, ) -> None: """ Rendering of SBA input signal to channel-based format @@ -148,7 +151,8 @@ def render_sba_to_cba( def render_sba_to_sba( - sba_in: audio.SceneBasedAudio, sba_out: audio.SceneBasedAudio, + sba_in: audio.SceneBasedAudio, + sba_out: audio.SceneBasedAudio, ) -> None: """ Rendering of SBA input signal to SBA output format @@ -172,7 +176,10 @@ def render_sba_to_sba( zero_vert_channels(sba_out) -def rotate_sba(sba: audio.SceneBasedAudio, trajectory: str,) -> np.ndarray: +def rotate_sba( + sba: audio.SceneBasedAudio, + trajectory: str, +) -> np.ndarray: """ Rotate HOA signal by applying a rotation matrix calculated from the current quaternion in each subframe @@ -390,7 +397,12 @@ def get_allrad_mtx( hoa_dec[1, 0] = 0.5 hoa_dec[1, 1] = -0.5 else: - Y_td = getRSH(T_DESIGN_11_AZI, T_DESIGN_11_ELE, ambi_order, norm="ortho",) + Y_td = getRSH( + T_DESIGN_11_AZI, + T_DESIGN_11_ELE, + ambi_order, + norm="ortho", + ) Y_td *= np.sqrt(4 * np.pi) n_ls_woLFE = cba.num_channels - len(cba.lfe_index) @@ -409,7 +421,7 @@ def get_allrad_mtx( if rE_weight_bool: a_n = rE_weight(ambi_order) - nrg_pre = np.sqrt(len(n_ls_woLFE) / np.sum(a_n ** 2)) + nrg_pre = np.sqrt(len(n_ls_woLFE) / np.sum(a_n**2)) hoa_dec = hoa_dec @ np.diag(a_n) * nrg_pre hoa_dec = np.insert(hoa_dec, cba.lfe_index, np.zeros(n_harm), axis=0) diff --git a/ivas_processing_scripts/audiotools/metadata.py b/ivas_processing_scripts/audiotools/metadata.py index d5cbf167..d0d44502 100755 --- a/ivas_processing_scripts/audiotools/metadata.py +++ b/ivas_processing_scripts/audiotools/metadata.py @@ -454,7 +454,10 @@ def split_meta_in_file( def check_ISM_metadata( - in_meta: dict, num_objects: int, num_items: int, item_names: Optional[list] = None, + in_meta: dict, + num_objects: int, + num_items: int, + item_names: Optional[list] = None, ) -> list: """Find ISM metadata""" @@ -537,7 +540,9 @@ def metadata_search( def add_remove_preamble( - metadata, preamble, add: Optional[bool] = True, + metadata, + preamble, + add: Optional[bool] = True, ): preamble_frames = preamble / IVAS_FRAME_LEN_MS if not preamble_frames.is_integer(): @@ -549,14 +554,18 @@ def add_remove_preamble( if metadata is not None and metadata[obj_idx] is not None: if add: metadata[obj_idx] = trim( - metadata[obj_idx], limits=(-int(preamble_frames), 0), samples=True, + metadata[obj_idx], + limits=(-int(preamble_frames), 0), + samples=True, ) # add radius 1 metadata[obj_idx][: int(preamble_frames), 2] = 1 else: metadata[obj_idx] = trim( - metadata[obj_idx], limits=(int(preamble_frames), 0), samples=True, + metadata[obj_idx], + limits=(int(preamble_frames), 0), + samples=True, ) return metadata diff --git a/ivas_processing_scripts/audiotools/rotation.py b/ivas_processing_scripts/audiotools/rotation.py index 30c6d442..742548a8 100755 --- a/ivas_processing_scripts/audiotools/rotation.py +++ b/ivas_processing_scripts/audiotools/rotation.py @@ -43,7 +43,12 @@ translated from ivas_rotation.c def SHrot_p( - i: int, l: int, a: int, b: int, SHrotmat: np.ndarray, R_lm1: np.ndarray, + i: int, + l: int, + a: int, + b: int, + SHrotmat: np.ndarray, + R_lm1: np.ndarray, ) -> float: """Helper function to calculate the ps""" @@ -67,13 +72,25 @@ def SHrot_p( return p -def SHrot_u(l: int, m: int, n: int, SHrotmat: np.ndarray, R_lm1: np.ndarray,) -> float: +def SHrot_u( + l: int, + m: int, + n: int, + SHrotmat: np.ndarray, + R_lm1: np.ndarray, +) -> float: """Helper function to calculate the us""" return SHrot_p(0, l, m, n, SHrotmat, R_lm1) -def SHrot_v(l: int, m: int, n: int, SHrotmat: np.ndarray, R_lm1: np.ndarray,) -> float: +def SHrot_v( + l: int, + m: int, + n: int, + SHrotmat: np.ndarray, + R_lm1: np.ndarray, +) -> float: """Helper function to calculate the vs""" if m == 0: @@ -93,7 +110,13 @@ def SHrot_v(l: int, m: int, n: int, SHrotmat: np.ndarray, R_lm1: np.ndarray,) -> return p0 * (1.0 - d) + p1 * np.sqrt(1.0 + d) -def SHrot_w(l: int, m: int, n: int, SHrotmat: np.ndarray, R_lm1: np.ndarray,) -> float: +def SHrot_w( + l: int, + m: int, + n: int, + SHrotmat: np.ndarray, + R_lm1: np.ndarray, +) -> float: """Helper function to calculate the w""" if m == 0: @@ -109,7 +132,10 @@ def SHrot_w(l: int, m: int, n: int, SHrotmat: np.ndarray, R_lm1: np.ndarray,) -> return p0 - p1 -def SHrotmatgen(R: np.ndarray, order: Optional[int] = 3,) -> np.ndarray: +def SHrotmatgen( + R: np.ndarray, + order: Optional[int] = 3, +) -> np.ndarray: """ Calculate SHD rotation matrix from that in real space translated from ivas_rotation.c @@ -193,7 +219,10 @@ def SHrotmatgen(R: np.ndarray, order: Optional[int] = 3,) -> np.ndarray: return SHrotmat -def Quat2Euler(quat: np.ndarray, degrees: bool = True,) -> np.ndarray: +def Quat2Euler( + quat: np.ndarray, + degrees: bool = True, +) -> np.ndarray: """Convert Quaternion to Euler angles""" sinr = +2.0 * (quat[..., 0] * quat[..., 1] + quat[..., 2] * quat[..., 3]) @@ -215,7 +244,10 @@ def Quat2Euler(quat: np.ndarray, degrees: bool = True,) -> np.ndarray: return ypr -def Euler2Quat(ypr: np.ndarray, degrees: bool = True,) -> np.ndarray: +def Euler2Quat( + ypr: np.ndarray, + degrees: bool = True, +) -> np.ndarray: """Convert Euler angles to Quaternion""" if degrees: @@ -249,7 +281,9 @@ def Euler2Quat(ypr: np.ndarray, degrees: bool = True,) -> np.ndarray: return quat -def Quat2RotMat(quat: np.ndarray,) -> np.ndarray: +def Quat2RotMat( + quat: np.ndarray, +) -> np.ndarray: """Convert quaternion to rotation matrix""" R = np.zeros([3, 3]) @@ -318,7 +352,10 @@ def Quat2RotMat(quat: np.ndarray,) -> np.ndarray: def rotateAziEle( - azi: float, ele: float, R: np.ndarray, is_planar: bool = False, + azi: float, + ele: float, + R: np.ndarray, + is_planar: bool = False, ) -> Tuple[float, float]: """Rotate azimuth and elevation angles with rotation matrix""" diff --git a/ivas_processing_scripts/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index d65c12bd..fe756c07 100755 --- a/ivas_processing_scripts/audiotools/wrappers/bs1770.py +++ b/ivas_processing_scripts/audiotools/wrappers/bs1770.py @@ -50,7 +50,8 @@ logger.setLevel(logging.DEBUG) def bs1770demo( - input: audio.Audio, target_loudness: Optional[float] = -26, + input: audio.Audio, + target_loudness: Optional[float] = -26, ) -> Tuple[float, float]: """ Wrapper for ITU-R BS.1770-4, requires bs1770demo binary diff --git a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py index 6cd371ed..86075b95 100644 --- a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py +++ b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py @@ -150,7 +150,8 @@ def create_and_apply_error_pattern( def validate_error_pattern_application( - error_pattern: Optional[Union[Path, str]] = None, error_rate: Optional[int] = None, + error_pattern: Optional[Union[Path, str]] = None, + error_rate: Optional[int] = None, ) -> None: """ Validate settings for the network simulator diff --git a/ivas_processing_scripts/audiotools/wrappers/filter.py b/ivas_processing_scripts/audiotools/wrappers/filter.py index a9fdd5a4..9be95758 100755 --- a/ivas_processing_scripts/audiotools/wrappers/filter.py +++ b/ivas_processing_scripts/audiotools/wrappers/filter.py @@ -184,7 +184,10 @@ def filter_itu( return output -def lpfilter_itu(x: Audio, fc: int,) -> np.ndarray: +def lpfilter_itu( + x: Audio, + fc: int, +) -> np.ndarray: """ Low-pass filter a multi-channel audio array @@ -234,7 +237,9 @@ def lpfilter_itu(x: Audio, fc: int,) -> np.ndarray: return y -def hp50filter_itu(x: Audio,) -> np.ndarray: +def hp50filter_itu( + x: Audio, +) -> np.ndarray: """ High-pass 50Hz filter a multi-channel audio array @@ -286,7 +291,10 @@ def hp50filter_itu(x: Audio,) -> np.ndarray: return y -def resample_itu(x: Audio, fs_new: int,) -> np.ndarray: +def resample_itu( + x: Audio, + fs_new: int, +) -> np.ndarray: """ Resampling of multi-channel audio array diff --git a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py index 7e6d8419..ed0c3013 100755 --- a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py +++ b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py @@ -42,7 +42,10 @@ from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES from ivas_processing_scripts.utils import find_binary, run -def masaRenderer(masa: audio.MetadataAssistedSpatialAudio, out_fmt: str,) -> np.ndarray: +def masaRenderer( + masa: audio.MetadataAssistedSpatialAudio, + out_fmt: str, +) -> np.ndarray: """ Wrapper for masaRenderer (from MASA reference software) diff --git a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py index 92738b63..4bc6b046 100755 --- a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py +++ b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py @@ -43,7 +43,10 @@ from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES from ivas_processing_scripts.utils import find_binary, run -def p50fbmnru(input: audio.Audio, q_db: float,) -> np.ndarray: +def p50fbmnru( + input: audio.Audio, + q_db: float, +) -> np.ndarray: """ Wrapper for P.50 Fullband MNRU (Modulated Noise Reference Unit), requires p50fbmnru binary The mode is M (Modulated Noise) as specified in section 5.2.1 of S4-141392 - EVS-7c Processing functions for characterization phase v110.doc diff --git a/ivas_processing_scripts/constants.py b/ivas_processing_scripts/constants.py index 907f1899..c2731016 100755 --- a/ivas_processing_scripts/constants.py +++ b/ivas_processing_scripts/constants.py @@ -62,15 +62,26 @@ DEFAULT_CONFIG = { "master_seed": 0, "metadata_path": None, # postprocessing - "postprocessing": {"hp50": False, "limit": False,}, + "postprocessing": { + "hp50": False, + "limit": False, + }, } DEFAULT_CONFIG_EVS = { - "cod": {"bin": find_binary("IVAS_cod", raise_error=False),}, - "dec": {"bin": find_binary("IVAS_dec", raise_error=False),}, + "cod": { + "bin": find_binary("IVAS_cod", raise_error=False), + }, + "dec": { + "bin": find_binary("IVAS_dec", raise_error=False), + }, } DEFAULT_CONFIG_IVAS = { - "cod": {"bin": find_binary("IVAS_cod", raise_error=False),}, - "dec": {"bin": find_binary("IVAS_dec", raise_error=False),}, + "cod": { + "bin": find_binary("IVAS_cod", raise_error=False), + }, + "dec": { + "bin": find_binary("IVAS_dec", raise_error=False), + }, } DEFAULT_CONFIG_BINARIES = { diff --git a/ivas_processing_scripts/processing/evs.py b/ivas_processing_scripts/processing/evs.py index 8783a5cd..ebe6ebf0 100755 --- a/ivas_processing_scripts/processing/evs.py +++ b/ivas_processing_scripts/processing/evs.py @@ -65,7 +65,9 @@ class EVS(Processing): self.in_fmt = audio.fromtype(self.in_fmt) self._validate() - def _validate(self,): + def _validate( + self, + ): if not self.cod_bin or not Path(self.cod_bin).exists(): if platform.system() == "Windows" and ( self.cod_bin and Path(self.cod_bin).with_suffix(".exe").exists() @@ -108,7 +110,8 @@ class EVS(Processing): ) elif self.tx.get("type", None) == "FER": validate_error_pattern_application( - self.tx["error_pattern"], self.tx["error_rate"], + self.tx["error_pattern"], + self.tx["error_rate"], ) def process( @@ -159,7 +162,10 @@ class EVS(Processing): ] split_channels( - in_file, split_chan_files, self.in_fmt.num_channels, self.in_fs, + in_file, + split_chan_files, + self.in_fmt.num_channels, + self.in_fs, ) # run processing @@ -250,7 +256,12 @@ class EVS(Processing): cmd.extend(self.cod_opts) cmd.extend( - [str(bitrate), str(self.in_fs // 1000), str(in_pcm_file), str(bitstream),] + [ + str(bitrate), + str(self.in_fs // 1000), + str(in_pcm_file), + str(bitstream), + ] ) run(cmd, logger=logger) diff --git a/ivas_processing_scripts/processing/ivas.py b/ivas_processing_scripts/processing/ivas.py index ef7e4ce2..b2cae46b 100755 --- a/ivas_processing_scripts/processing/ivas.py +++ b/ivas_processing_scripts/processing/ivas.py @@ -91,7 +91,8 @@ class IVAS(Processing): ) elif self.tx.get("type", None) == "FER": validate_error_pattern_application( - self.tx["error_pattern"], self.tx["error_rate"], + self.tx["error_pattern"], + self.tx["error_rate"], ) def process( @@ -291,7 +292,11 @@ class IVAS(Processing): if output_format == "": cmd.extend( - [str(self.out_fs // 1000), str(bitstream), str(out_file),] + [ + str(self.out_fs // 1000), + str(bitstream), + str(out_file), + ] ) else: cmd.extend( diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 0d87db1f..97b59b24 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -112,7 +112,10 @@ def concat_setup(cfg: TestConfig, chain, logger: logging.Logger): ) ) concat_meta_from_file( - cfg.items_list, cfg.metadata_path, cfg.concat_meta, cfg.input["fmt"], + cfg.items_list, + cfg.metadata_path, + cfg.concat_meta, + cfg.input["fmt"], ) # set input to the concatenated file we have just written to the output dir diff --git a/tests/constants.py b/tests/constants.py index 16aa011a..11c48dc2 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -175,7 +175,14 @@ METADATA_SCENES_TO_TEST_NO_BE = [SCENE_DESC_DIR.joinpath(s) for s in ["masa_scen """ Binaural rendering """ INPUT_FORMATS_BINAURAL = OUTPUT_FORMATS[2:] INPUT_FORMATS_BINAURAL.extend( - ["ISM1", "ISM2", "ISM3", "ISM4", "MASA1", "MASA2",] + [ + "ISM1", + "ISM2", + "ISM3", + "ISM4", + "MASA1", + "MASA2", + ] ) OUTPUT_FORMATS_BINAURAL = ["BINAURAL", "BINAURAL_ROOM"] HR_TRAJECTORIES_TO_TEST = [ diff --git a/tests/test_audiotools_convert.py b/tests/test_audiotools_convert.py index d91f0b19..fa555319 100644 --- a/tests/test_audiotools_convert.py +++ b/tests/test_audiotools_convert.py @@ -135,7 +135,8 @@ def test_mono_fail(out_fmt): @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input(in_layout, out_fmt): convert( - CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, + CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), + out_fmt, ) @@ -143,7 +144,8 @@ def test_custom_ls_input(in_layout, out_fmt): @pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS[1:]) def test_custom_ls_output(in_fmt, out_fmt): convert( - in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), + in_fmt, + CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), ) @@ -220,7 +222,9 @@ def test_multichannel_binaural_static(in_fmt, out_fmt): @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_headrotation(in_fmt, out_fmt, trj_file): convert( - in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + in_fmt, + out_fmt, + trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), ) @@ -259,5 +263,7 @@ def test_masa_binaural_headrotation(in_fmt, out_fmt, trj_file): @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[1:]) def test_multichannel_binaural_headrotation(in_fmt, out_fmt, trj_file): convert( - in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + in_fmt, + out_fmt, + trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), ) -- GitLab From 989878fb56e370074bdb51144f191463871688c9 Mon Sep 17 00:00:00 2001 From: Treffehn Date: Wed, 26 Apr 2023 11:26:31 +0200 Subject: [PATCH 8/8] small formatting --- ivas_processing_scripts/processing/processing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 97b59b24..a4fcb2ff 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -457,7 +457,6 @@ def remove_preamble(cfg): def preprocess_background_noise(cfg): - # TODO: add checks and errors for sampling rate and number channels compared to input signals # create audio objects input_audio = audio.fromfile( -- GitLab