Loading ivas_processing_scripts/audiotools/convert/masa.py +24 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,7 @@ from typing import Optional, Union from warnings import warn from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.convert import channelbased from ivas_processing_scripts.audiotools.wrappers.masaRenderer import masaRenderer from ivas_processing_scripts.audiotools.wrappers.masaRenderer import ivasRendMasa """ MetadataAssistedSpatialAudio functions """ Loading Loading @@ -90,6 +89,8 @@ def render_masa_to_binaural( Name of binaural dataset without prefix or suffix """ # Needed if using masaRenderer (deprecated) """ if "ROOM" in bin.name: cba_tmp = audio.fromtype("7_1_4") cba_tmp.fs = masa.fs Loading @@ -108,6 +109,19 @@ def render_masa_to_binaural( ) bin.audio = masaRenderer(masa, "BINAURAL") """ if bin_dataset is not None: warn( "Binaural dataset selection not supported by IVAS_rend - please render manually" ) if bin.name == "BINAURAL_ROOM": warn( "BINAURAL_ROOM is not a valid output format for IVAS_rend. Defaulting to BINAURAL_ROOM_IR." ) bin.name += "_IR" bin.audio = ivasRendMasa(masa, bin.name, trajectory) def render_masa_to_cba( Loading @@ -125,6 +139,8 @@ def render_masa_to_cba( Channel-based output audio """ # Needed if using masaRenderer (deprecated) """ if cba.name not in ["5_1", "7_1_4"]: warn( f"MasaRenderer does not support {cba.name} natively. Using 7_1_4 as an intermediate format." Loading @@ -137,6 +153,8 @@ def render_masa_to_cba( channelbased.render_cba_to_cba(cba_tmp, cba) else: cba.audio = masaRenderer(masa, cba.name) """ cba.audio = ivasRendMasa(masa, cba.name) def render_masa_to_sba( Loading @@ -154,6 +172,8 @@ def render_masa_to_sba( SBA output audio """ # Needed if using masaRenderer (deprecated) """ warn( f"MasaRenderer does not support {sba.name} natively. Using 7_1_4 as an intermediate format." ) Loading @@ -163,3 +183,5 @@ def render_masa_to_sba( cba_tmp.audio = masaRenderer(masa, cba_tmp.name) channelbased.render_cba_to_sba(cba_tmp, sba) """ sba.audio = ivasRendMasa(masa, sba.name) ivas_processing_scripts/audiotools/wrappers/masaRenderer.py +58 −0 Original line number Diff line number Diff line Loading @@ -39,9 +39,67 @@ from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES from ivas_processing_scripts.processing.ivas import IVAS_rend from ivas_processing_scripts.utils import find_binary, run from warnings import deprecated def ivasRendMasa( masa: audio.MetadataAssistedSpatialAudio, out_fmt: str, trajectory: Path = None, ) -> np.ndarray: """ Wrapper for IVAS_Rend MASA Rendering Parameters ---------- masa : MetadataAssistedSpatialAudio Input MASA audio out_fmt: str Desired output format (only 5_1, 7_1_4 and BINAURAL supported) Returns ------- output : np.ndarray MASA rendered to out_fmt """ if "ivas_rend" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["ivas_rend"].name, binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["ivas_rend"].parent, ) else: binary = find_binary("ivas_rend") rend = IVAS_rend( { "bin": binary, "in_fmt": masa.name, "in_fs": masa.fs, "out_fmt": out_fmt, "trajectory": trajectory, } ) with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) tmp_in = tmp_dir.joinpath("tmp_masaRendIn.pcm") tmp_out = tmp_dir.joinpath("tmp_masaRendOut.pcm") masa_metadata_file = masa.metadata_file if masa_metadata_file is not None and not isinstance(masa_metadata_file, Path): masa_metadata_file = Path(masa_metadata_file) rend.process(tmp_in, tmp_out, in_meta=masa_metadata_file) output, _ = read(tmp_out) return output @deprecated( "This function has been replaced by ivasRendMasa, please switch code to use that instead" ) def masaRenderer( masa: audio.MetadataAssistedSpatialAudio, out_fmt: str, Loading ivas_processing_scripts/binary_paths.yml +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ # eid-xor: "path/to/binary/eid-xor" # ### Binary for error pattern generation # gen-patt: "path/to/binary/gen-patt" # ### Binary for IVAS Renderer # ivas_rend: "path/to/binary/ivas_rend" # ### Binary for random offset/seed generation # random: "path/to/binary/random" # ### Binary for JBM network similulator Loading tests/test_binaries_present.py +2 −1 Original line number Diff line number Diff line Loading @@ -41,9 +41,10 @@ BINARIES = [ "eid-xor", "gen-patt", "filter", "ivas_rend", "random", "networkSimulator_g192", "masaRenderer", # "masaRenderer", "masaAnalyzer", ] Loading Loading
ivas_processing_scripts/audiotools/convert/masa.py +24 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,7 @@ from typing import Optional, Union from warnings import warn from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.convert import channelbased from ivas_processing_scripts.audiotools.wrappers.masaRenderer import masaRenderer from ivas_processing_scripts.audiotools.wrappers.masaRenderer import ivasRendMasa """ MetadataAssistedSpatialAudio functions """ Loading Loading @@ -90,6 +89,8 @@ def render_masa_to_binaural( Name of binaural dataset without prefix or suffix """ # Needed if using masaRenderer (deprecated) """ if "ROOM" in bin.name: cba_tmp = audio.fromtype("7_1_4") cba_tmp.fs = masa.fs Loading @@ -108,6 +109,19 @@ def render_masa_to_binaural( ) bin.audio = masaRenderer(masa, "BINAURAL") """ if bin_dataset is not None: warn( "Binaural dataset selection not supported by IVAS_rend - please render manually" ) if bin.name == "BINAURAL_ROOM": warn( "BINAURAL_ROOM is not a valid output format for IVAS_rend. Defaulting to BINAURAL_ROOM_IR." ) bin.name += "_IR" bin.audio = ivasRendMasa(masa, bin.name, trajectory) def render_masa_to_cba( Loading @@ -125,6 +139,8 @@ def render_masa_to_cba( Channel-based output audio """ # Needed if using masaRenderer (deprecated) """ if cba.name not in ["5_1", "7_1_4"]: warn( f"MasaRenderer does not support {cba.name} natively. Using 7_1_4 as an intermediate format." Loading @@ -137,6 +153,8 @@ def render_masa_to_cba( channelbased.render_cba_to_cba(cba_tmp, cba) else: cba.audio = masaRenderer(masa, cba.name) """ cba.audio = ivasRendMasa(masa, cba.name) def render_masa_to_sba( Loading @@ -154,6 +172,8 @@ def render_masa_to_sba( SBA output audio """ # Needed if using masaRenderer (deprecated) """ warn( f"MasaRenderer does not support {sba.name} natively. Using 7_1_4 as an intermediate format." ) Loading @@ -163,3 +183,5 @@ def render_masa_to_sba( cba_tmp.audio = masaRenderer(masa, cba_tmp.name) channelbased.render_cba_to_sba(cba_tmp, sba) """ sba.audio = ivasRendMasa(masa, sba.name)
ivas_processing_scripts/audiotools/wrappers/masaRenderer.py +58 −0 Original line number Diff line number Diff line Loading @@ -39,9 +39,67 @@ from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES from ivas_processing_scripts.processing.ivas import IVAS_rend from ivas_processing_scripts.utils import find_binary, run from warnings import deprecated def ivasRendMasa( masa: audio.MetadataAssistedSpatialAudio, out_fmt: str, trajectory: Path = None, ) -> np.ndarray: """ Wrapper for IVAS_Rend MASA Rendering Parameters ---------- masa : MetadataAssistedSpatialAudio Input MASA audio out_fmt: str Desired output format (only 5_1, 7_1_4 and BINAURAL supported) Returns ------- output : np.ndarray MASA rendered to out_fmt """ if "ivas_rend" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["ivas_rend"].name, binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["ivas_rend"].parent, ) else: binary = find_binary("ivas_rend") rend = IVAS_rend( { "bin": binary, "in_fmt": masa.name, "in_fs": masa.fs, "out_fmt": out_fmt, "trajectory": trajectory, } ) with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) tmp_in = tmp_dir.joinpath("tmp_masaRendIn.pcm") tmp_out = tmp_dir.joinpath("tmp_masaRendOut.pcm") masa_metadata_file = masa.metadata_file if masa_metadata_file is not None and not isinstance(masa_metadata_file, Path): masa_metadata_file = Path(masa_metadata_file) rend.process(tmp_in, tmp_out, in_meta=masa_metadata_file) output, _ = read(tmp_out) return output @deprecated( "This function has been replaced by ivasRendMasa, please switch code to use that instead" ) def masaRenderer( masa: audio.MetadataAssistedSpatialAudio, out_fmt: str, Loading
ivas_processing_scripts/binary_paths.yml +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ # eid-xor: "path/to/binary/eid-xor" # ### Binary for error pattern generation # gen-patt: "path/to/binary/gen-patt" # ### Binary for IVAS Renderer # ivas_rend: "path/to/binary/ivas_rend" # ### Binary for random offset/seed generation # random: "path/to/binary/random" # ### Binary for JBM network similulator Loading
tests/test_binaries_present.py +2 −1 Original line number Diff line number Diff line Loading @@ -41,9 +41,10 @@ BINARIES = [ "eid-xor", "gen-patt", "filter", "ivas_rend", "random", "networkSimulator_g192", "masaRenderer", # "masaRenderer", "masaAnalyzer", ] Loading