Loading ivas_processing_scripts/audiotools/audioarray.py +7 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ # import logging import warnings from typing import Iterator, Optional, Tuple, Union import numpy as np Loading Loading @@ -268,6 +269,7 @@ def limiter( release_heuristics_mem = 0.0 gain = 1.0 strong_saturation_cnt = 0 limited = False if x.ndim == 1: n_samples_x = x.shape Loading Loading @@ -326,16 +328,21 @@ def limiter( fr_gain = np.tile(gain * fac + frame_gain * (1.0 - fac), (n_chan_x, 1)).T fr_sig *= fr_gain gain = fr_gain[-1, 0] limited = True else: gain = 1.0 release_heuristics_mem = release_heuristic # hard limiting for everything that still sticks out if (fr_sig > 32767).any() or (fr_sig < -32768).any(): limited = True idx_max = np.where(fr_sig > 32767) fr_sig[idx_max] = 32767 idx_min = np.where(fr_sig < -32768) fr_sig[idx_min] = -32768 if limited: warnings.warn("Limiting had to be applied") return x Loading ivas_processing_scripts/audiotools/binaural_datasets/HRIR_ORANGE53_LS.mat LFS +2 −2 Original line number Diff line number Diff line version https://git-lfs.github.com/spec/v1 oid sha256:9660be83192f7babb4f67e19653a94bc02cee7b3071065880cf618547c19d842 size 20138 oid sha256:2e25ef101e9e72c5d70a55bc1451a07d041d29f96a803d7d3f968f20fe403316 size 20190 ivas_processing_scripts/audiotools/metadata.py +44 −5 Original line number Diff line number Diff line Loading @@ -146,7 +146,6 @@ class Metadata: self.audio.append(sba) def parse_optional_values(self, f: TextIO): # TODO implementation raise NotImplementedError( "Additional configuration keys in metadata currently unsupported!" ) Loading Loading @@ -223,6 +222,22 @@ def trim_meta( pad_noise: Optional[bool] = False, samples: Optional[bool] = False, ) -> None: """ Trim or pad ISM including metadata positive limits trim negative limits pad Parameters ---------- x: audio.ObjectBasedAudio ISM audio object limits: Optional[Tuple[int, int]] Number of samples to trim or pad at beginning and end pad_noise: Optional[bool] Flag for padding noise instead of silence samples: Optional[bool] Flag for interpreting limits as samples, otherwise milliseconds """ if not limits: return Loading Loading @@ -289,12 +304,32 @@ def concat_meta_from_file( input_fmt: str, preamble: Optional[int] = None, ) -> None: """ Concatenate ISM metadata from files Parameters ---------- audio_files: list[str] List of audio file names meta_files: list[list[str]] List of corresponding metadata file names out_file: list[str] Name of concatenated output file silence_pre: int Silence inserted before each item silence_post: int Silence inserted after each item input_fmt: str Input audio format preamble: Optional[int] Length of preamble in milliseconds """ # create audio objects audio_objects = [] fs = None for i, audio_file in enumerate(audio_files): # metadata is cut/looped to signal length in init of audio object # TODO check fs for audio object when pcm audio_object = audio.fromfile(input_fmt, audio_file, in_meta=meta_files[i]) audio_objects.append(audio_object) if fs: Loading Loading @@ -438,9 +473,13 @@ 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""" list_meta = [] if in_meta is None: for item in item_names: Loading Loading @@ -493,7 +532,7 @@ def metadata_search( in_meta: Union[str, Path], item_names: list[Union[str, Path]], num_objects: int, ) -> list: ) -> list[list[Union[Path, str]]]: """Search for ISM metadata with structure item_name.{0-3}.csv in in_meta folder""" if not item_names: Loading ivas_processing_scripts/audiotools/rotation.py +5 −3 Original line number Diff line number Diff line Loading @@ -136,14 +136,14 @@ def SHrotmatgen( R: np.ndarray, order: Optional[int] = 3, ) -> np.ndarray: """Calculate SHD rotation matrix from that in real space """ Calculate SHD rotation matrix from that in real space translated from ivas_rotation.c Parameters: ---------- R: np.ndarray real-space rotation matrix order: Optional[int] Ambisonics order, default = 3 Loading @@ -151,8 +151,8 @@ def SHrotmatgen( ---------- SHrotmat: np.ndarray SHD rotation matrix """ dim = (order + 1) * (order + 1) SHrotmat = np.zeros([dim, dim]) Loading Loading @@ -357,6 +357,8 @@ def rotateAziEle( R: np.ndarray, is_planar: bool = False, ) -> Tuple[float, float]: """Rotate azimuth and elevation angles with rotation matrix""" w = np.cos(np.deg2rad(ele)) dv = np.array( [ Loading ivas_processing_scripts/constants.py +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ DEFAULT_CONFIG = { # postprocessing "postprocessing": { "hp50": False, "limit": True, "limit": False, }, } DEFAULT_CONFIG_EVS = { Loading Loading
ivas_processing_scripts/audiotools/audioarray.py +7 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ # import logging import warnings from typing import Iterator, Optional, Tuple, Union import numpy as np Loading Loading @@ -268,6 +269,7 @@ def limiter( release_heuristics_mem = 0.0 gain = 1.0 strong_saturation_cnt = 0 limited = False if x.ndim == 1: n_samples_x = x.shape Loading Loading @@ -326,16 +328,21 @@ def limiter( fr_gain = np.tile(gain * fac + frame_gain * (1.0 - fac), (n_chan_x, 1)).T fr_sig *= fr_gain gain = fr_gain[-1, 0] limited = True else: gain = 1.0 release_heuristics_mem = release_heuristic # hard limiting for everything that still sticks out if (fr_sig > 32767).any() or (fr_sig < -32768).any(): limited = True idx_max = np.where(fr_sig > 32767) fr_sig[idx_max] = 32767 idx_min = np.where(fr_sig < -32768) fr_sig[idx_min] = -32768 if limited: warnings.warn("Limiting had to be applied") return x Loading
ivas_processing_scripts/audiotools/binaural_datasets/HRIR_ORANGE53_LS.mat LFS +2 −2 Original line number Diff line number Diff line version https://git-lfs.github.com/spec/v1 oid sha256:9660be83192f7babb4f67e19653a94bc02cee7b3071065880cf618547c19d842 size 20138 oid sha256:2e25ef101e9e72c5d70a55bc1451a07d041d29f96a803d7d3f968f20fe403316 size 20190
ivas_processing_scripts/audiotools/metadata.py +44 −5 Original line number Diff line number Diff line Loading @@ -146,7 +146,6 @@ class Metadata: self.audio.append(sba) def parse_optional_values(self, f: TextIO): # TODO implementation raise NotImplementedError( "Additional configuration keys in metadata currently unsupported!" ) Loading Loading @@ -223,6 +222,22 @@ def trim_meta( pad_noise: Optional[bool] = False, samples: Optional[bool] = False, ) -> None: """ Trim or pad ISM including metadata positive limits trim negative limits pad Parameters ---------- x: audio.ObjectBasedAudio ISM audio object limits: Optional[Tuple[int, int]] Number of samples to trim or pad at beginning and end pad_noise: Optional[bool] Flag for padding noise instead of silence samples: Optional[bool] Flag for interpreting limits as samples, otherwise milliseconds """ if not limits: return Loading Loading @@ -289,12 +304,32 @@ def concat_meta_from_file( input_fmt: str, preamble: Optional[int] = None, ) -> None: """ Concatenate ISM metadata from files Parameters ---------- audio_files: list[str] List of audio file names meta_files: list[list[str]] List of corresponding metadata file names out_file: list[str] Name of concatenated output file silence_pre: int Silence inserted before each item silence_post: int Silence inserted after each item input_fmt: str Input audio format preamble: Optional[int] Length of preamble in milliseconds """ # create audio objects audio_objects = [] fs = None for i, audio_file in enumerate(audio_files): # metadata is cut/looped to signal length in init of audio object # TODO check fs for audio object when pcm audio_object = audio.fromfile(input_fmt, audio_file, in_meta=meta_files[i]) audio_objects.append(audio_object) if fs: Loading Loading @@ -438,9 +473,13 @@ 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""" list_meta = [] if in_meta is None: for item in item_names: Loading Loading @@ -493,7 +532,7 @@ def metadata_search( in_meta: Union[str, Path], item_names: list[Union[str, Path]], num_objects: int, ) -> list: ) -> list[list[Union[Path, str]]]: """Search for ISM metadata with structure item_name.{0-3}.csv in in_meta folder""" if not item_names: Loading
ivas_processing_scripts/audiotools/rotation.py +5 −3 Original line number Diff line number Diff line Loading @@ -136,14 +136,14 @@ def SHrotmatgen( R: np.ndarray, order: Optional[int] = 3, ) -> np.ndarray: """Calculate SHD rotation matrix from that in real space """ Calculate SHD rotation matrix from that in real space translated from ivas_rotation.c Parameters: ---------- R: np.ndarray real-space rotation matrix order: Optional[int] Ambisonics order, default = 3 Loading @@ -151,8 +151,8 @@ def SHrotmatgen( ---------- SHrotmat: np.ndarray SHD rotation matrix """ dim = (order + 1) * (order + 1) SHrotmat = np.zeros([dim, dim]) Loading Loading @@ -357,6 +357,8 @@ def rotateAziEle( R: np.ndarray, is_planar: bool = False, ) -> Tuple[float, float]: """Rotate azimuth and elevation angles with rotation matrix""" w = np.cos(np.deg2rad(ele)) dv = np.array( [ Loading
ivas_processing_scripts/constants.py +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ DEFAULT_CONFIG = { # postprocessing "postprocessing": { "hp50": False, "limit": True, "limit": False, }, } DEFAULT_CONFIG_EVS = { Loading