Loading ivas_processing_scripts/audiotools/wrappers/masaAnalyzer.py +3 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,9 @@ def masaAnalyzer( binary = find_binary("masaAnalyzer") # enforce metadata_out_filename to be a Path object if metadata_out_filename is not None and not isinstance(metadata_out_filename, Path): if metadata_out_filename is not None and not isinstance( metadata_out_filename, Path ): metadata_out_filename = Path(metadata_out_filename) if num_tcs not in [1, 2]: Loading ivas_processing_scripts/audiotools/wrappers/reverb.py +6 −5 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ def reverb_stereo( y_right = reverb(input, IR_right, align=align) # combine into stereo output y = audio.fromtype('STEREO') y = audio.fromtype("STEREO") y.fs = input.fs y.audio = np.column_stack([y_left.audio, y_right.audio]) Loading Loading @@ -252,7 +252,7 @@ def reverb_foa( y_z = reverb(input, IR_z, align=align) # combine into FOA output y = audio.fromtype('FOA') y = audio.fromtype("FOA") y.fs = input.fs y.audio = np.column_stack([y_w.audio, y_x.audio, y_y.audio, y_z.audio]) Loading Loading @@ -303,7 +303,7 @@ def reverb_hoa2( ych.append(reverb(input, IR, align=align)) # combine into HOA2 output y = audio.fromtype('HOA2') y = audio.fromtype("HOA2") y.fs = input.fs y.audio = np.column_stack( [ Loading @@ -321,6 +321,7 @@ def reverb_hoa2( return y def reverb_hoa3( input: Audio, hoa3_IR: Audio, Loading Loading @@ -365,7 +366,7 @@ def reverb_hoa3( ych.append(reverb(input, IR, align=align)) # combine into HOA3 output y = audio.fromtype('HOA3') y = audio.fromtype("HOA3") y.fs = input.fs y.audio = np.column_stack( [ Loading ivas_processing_scripts/generation/__init__.py +3 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ # import logging import yaml from ivas_processing_scripts.constants import ( Loading @@ -41,10 +42,10 @@ from ivas_processing_scripts.constants import ( from ivas_processing_scripts.generation import ( config, generate_ambi_items, generate_stereo_items, generate_ismN_items, generate_omasa_items, generate_osba_items, generate_stereo_items, ) from ivas_processing_scripts.utils import create_dir Loading ivas_processing_scripts/generation/generate_ambi_items.py +29 −15 Original line number Diff line number Diff line Loading @@ -41,8 +41,15 @@ import numpy as np from ivas_processing_scripts.audiotools import audio, audioarray, audiofile, convert from ivas_processing_scripts.audiotools.convert.objectbased import convert_objectbased from ivas_processing_scripts.audiotools.convert.scenebased import convert_scenebased from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness, loudness_norm from ivas_processing_scripts.audiotools.wrappers.reverb import reverb_foa, reverb_hoa2, reverb_hoa3 from ivas_processing_scripts.audiotools.wrappers.bs1770 import ( get_loudness, loudness_norm, ) from ivas_processing_scripts.audiotools.wrappers.reverb import ( reverb_foa, reverb_hoa2, reverb_hoa3, ) from ivas_processing_scripts.generation import config from ivas_processing_scripts.utils import apply_func_parallel Loading Loading @@ -201,7 +208,9 @@ def generate_ambi_scene( N_inputs = len(np.atleast_1d(scene["input"])) # initialize output dirs output_filename = Path(scene["output"]).parent / (cfg.use_output_prefix + Path(scene["output"]).name) output_filename = Path(scene["output"]).parent / ( cfg.use_output_prefix + Path(scene["output"]).name ) dir_path = output_filename.parent if dir_path and not dir_path.exists(): Loading @@ -211,7 +220,6 @@ def generate_ambi_scene( y = audio.SceneBasedAudio(cfg.format) for i in range(N_inputs): # parse parameters from the scene description source_file = np.atleast_1d(scene["input"])[i] IR_file = np.atleast_1d(scene["IR"])[i] Loading Loading @@ -239,7 +247,9 @@ def generate_ambi_scene( logger.info(f"Convolving {source_file} with {IR_file}") # get input filename and IR filename input_filename = Path(source_file).parent / (cfg.use_input_prefix + Path(source_file).name) input_filename = Path(source_file).parent / ( cfg.use_input_prefix + Path(source_file).name ) IR_filename = Path(IR_file).parent / (cfg.use_IR_prefix + Path(IR_file).name) # read source file Loading Loading @@ -280,7 +290,9 @@ def generate_ambi_scene( # adjust the signal length (trim from the end or pad with zeros) to align its length with the previous signal(s) N_pad = y.audio.shape[0] - x.audio.shape[0] if N_pad != 0: x.audio = audioarray.trim(x.audio, x.fs, limits=[0, -N_pad], samples=True) x.audio = audioarray.trim( x.audio, x.fs, limits=[0, -N_pad], samples=True ) # superimpose y.audio += x.audio Loading @@ -305,7 +317,9 @@ def generate_ambi_scene( binaudio = audio.fromtype("BINAURAL") binaudio.fs = y.fs convert_scenebased(y, binaudio) binaural_output_filename = output_filename.with_name(output_filename.stem + "_BINAURAL" + output_filename.suffix) binaural_output_filename = output_filename.with_name( output_filename.stem + "_BINAURAL" + output_filename.suffix ) audiofile.write( binaural_output_filename, binaudio.audio, Loading ivas_processing_scripts/generation/generate_ismN_items.py +32 −22 Original line number Diff line number Diff line Loading @@ -33,12 +33,16 @@ import csv import logging from itertools import groupby, repeat from math import floor import numpy as np from pathlib import Path import numpy as np from ivas_processing_scripts.audiotools import audio, audioarray, audiofile from ivas_processing_scripts.audiotools.convert.objectbased import convert_objectbased from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness, loudness_norm from ivas_processing_scripts.audiotools.wrappers.bs1770 import ( get_loudness, loudness_norm, ) from ivas_processing_scripts.generation import config from ivas_processing_scripts.utils import apply_func_parallel Loading Loading @@ -186,7 +190,9 @@ def generate_ismN_scene( # initialize output dirs ism_format = f"ISM{N_inputs}" output_filename = Path(scene["output"]).parent / (cfg.use_output_prefix + Path(scene["output"]).name) output_filename = Path(scene["output"]).parent / ( cfg.use_output_prefix + Path(scene["output"]).name ) dir_path = output_filename.parent if dir_path and not dir_path.exists(): Loading @@ -197,7 +203,6 @@ def generate_ismN_scene( # repeat for all source files for i in range(N_inputs): # parse parameters from the scene description source_file = ( scene["input"][i] if isinstance(scene["input"], list) else scene["input"] Loading Loading @@ -236,7 +241,9 @@ def generate_ismN_scene( logger.info(f"Encoding {source_file} at position(s) {source_azi},{source_ele}") # get input filename input_filename = Path(source_file).parent / (cfg.use_input_prefix + Path(source_file).name) input_filename = Path(source_file).parent / ( cfg.use_input_prefix + Path(source_file).name ) # generate ISM metadata .csv filename (should end with .wav..0.csv, .wav.1.csv, ...) y.metadata_files.insert(i, str(output_filename.with_suffix(f".{i}.csv"))) Loading Loading @@ -268,7 +275,9 @@ def generate_ismN_scene( # pad ISM signal with zeros to have the same length as the MASA signal N_pad = y.audio.shape[0] - x.audio.shape[0] if N_pad != 0: x.audio = audioarray.trim(x.audio, x.fs, limits=[0, -N_pad], samples=True) x.audio = audioarray.trim( x.audio, x.fs, limits=[0, -N_pad], samples=True ) # append ISM signal to the ISM object y.audio = np.append(y.audio, x.audio, axis=1) Loading Loading @@ -309,7 +318,7 @@ def generate_ismN_scene( azi = np.arange( float(eval(source_azi[0])), float(eval(source_azi[0])) + N_frames * float(eval(source_azi[1])), float(eval(source_azi[1])) float(eval(source_azi[1])), ) else: # replicate static azimuth value N_frames times Loading @@ -336,7 +345,7 @@ def generate_ismN_scene( ele = np.arange( float(eval(source_ele[0])), np.sign(float(eval(source_ele[1]))) * 90, float(eval(source_ele[1])) float(eval(source_ele[1])), )[:N_frames] # repeat the last elevation value, if array is shorter than N_frames Loading Loading @@ -381,10 +390,11 @@ def generate_ismN_scene( binaudio = audio.fromtype("BINAURAL") binaudio.fs = y.fs convert_objectbased(y, binaudio) binaural_output_filename = output_filename.with_name(output_filename.stem + "_BINAURAL" + output_filename.suffix) binaural_output_filename = output_filename.with_name( output_filename.stem + "_BINAURAL" + output_filename.suffix ) audiofile.write( binaural_output_filename, binaudio.audio, binaudio.fs, ) Loading
ivas_processing_scripts/audiotools/wrappers/masaAnalyzer.py +3 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,9 @@ def masaAnalyzer( binary = find_binary("masaAnalyzer") # enforce metadata_out_filename to be a Path object if metadata_out_filename is not None and not isinstance(metadata_out_filename, Path): if metadata_out_filename is not None and not isinstance( metadata_out_filename, Path ): metadata_out_filename = Path(metadata_out_filename) if num_tcs not in [1, 2]: Loading
ivas_processing_scripts/audiotools/wrappers/reverb.py +6 −5 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ def reverb_stereo( y_right = reverb(input, IR_right, align=align) # combine into stereo output y = audio.fromtype('STEREO') y = audio.fromtype("STEREO") y.fs = input.fs y.audio = np.column_stack([y_left.audio, y_right.audio]) Loading Loading @@ -252,7 +252,7 @@ def reverb_foa( y_z = reverb(input, IR_z, align=align) # combine into FOA output y = audio.fromtype('FOA') y = audio.fromtype("FOA") y.fs = input.fs y.audio = np.column_stack([y_w.audio, y_x.audio, y_y.audio, y_z.audio]) Loading Loading @@ -303,7 +303,7 @@ def reverb_hoa2( ych.append(reverb(input, IR, align=align)) # combine into HOA2 output y = audio.fromtype('HOA2') y = audio.fromtype("HOA2") y.fs = input.fs y.audio = np.column_stack( [ Loading @@ -321,6 +321,7 @@ def reverb_hoa2( return y def reverb_hoa3( input: Audio, hoa3_IR: Audio, Loading Loading @@ -365,7 +366,7 @@ def reverb_hoa3( ych.append(reverb(input, IR, align=align)) # combine into HOA3 output y = audio.fromtype('HOA3') y = audio.fromtype("HOA3") y.fs = input.fs y.audio = np.column_stack( [ Loading
ivas_processing_scripts/generation/__init__.py +3 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ # import logging import yaml from ivas_processing_scripts.constants import ( Loading @@ -41,10 +42,10 @@ from ivas_processing_scripts.constants import ( from ivas_processing_scripts.generation import ( config, generate_ambi_items, generate_stereo_items, generate_ismN_items, generate_omasa_items, generate_osba_items, generate_stereo_items, ) from ivas_processing_scripts.utils import create_dir Loading
ivas_processing_scripts/generation/generate_ambi_items.py +29 −15 Original line number Diff line number Diff line Loading @@ -41,8 +41,15 @@ import numpy as np from ivas_processing_scripts.audiotools import audio, audioarray, audiofile, convert from ivas_processing_scripts.audiotools.convert.objectbased import convert_objectbased from ivas_processing_scripts.audiotools.convert.scenebased import convert_scenebased from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness, loudness_norm from ivas_processing_scripts.audiotools.wrappers.reverb import reverb_foa, reverb_hoa2, reverb_hoa3 from ivas_processing_scripts.audiotools.wrappers.bs1770 import ( get_loudness, loudness_norm, ) from ivas_processing_scripts.audiotools.wrappers.reverb import ( reverb_foa, reverb_hoa2, reverb_hoa3, ) from ivas_processing_scripts.generation import config from ivas_processing_scripts.utils import apply_func_parallel Loading Loading @@ -201,7 +208,9 @@ def generate_ambi_scene( N_inputs = len(np.atleast_1d(scene["input"])) # initialize output dirs output_filename = Path(scene["output"]).parent / (cfg.use_output_prefix + Path(scene["output"]).name) output_filename = Path(scene["output"]).parent / ( cfg.use_output_prefix + Path(scene["output"]).name ) dir_path = output_filename.parent if dir_path and not dir_path.exists(): Loading @@ -211,7 +220,6 @@ def generate_ambi_scene( y = audio.SceneBasedAudio(cfg.format) for i in range(N_inputs): # parse parameters from the scene description source_file = np.atleast_1d(scene["input"])[i] IR_file = np.atleast_1d(scene["IR"])[i] Loading Loading @@ -239,7 +247,9 @@ def generate_ambi_scene( logger.info(f"Convolving {source_file} with {IR_file}") # get input filename and IR filename input_filename = Path(source_file).parent / (cfg.use_input_prefix + Path(source_file).name) input_filename = Path(source_file).parent / ( cfg.use_input_prefix + Path(source_file).name ) IR_filename = Path(IR_file).parent / (cfg.use_IR_prefix + Path(IR_file).name) # read source file Loading Loading @@ -280,7 +290,9 @@ def generate_ambi_scene( # adjust the signal length (trim from the end or pad with zeros) to align its length with the previous signal(s) N_pad = y.audio.shape[0] - x.audio.shape[0] if N_pad != 0: x.audio = audioarray.trim(x.audio, x.fs, limits=[0, -N_pad], samples=True) x.audio = audioarray.trim( x.audio, x.fs, limits=[0, -N_pad], samples=True ) # superimpose y.audio += x.audio Loading @@ -305,7 +317,9 @@ def generate_ambi_scene( binaudio = audio.fromtype("BINAURAL") binaudio.fs = y.fs convert_scenebased(y, binaudio) binaural_output_filename = output_filename.with_name(output_filename.stem + "_BINAURAL" + output_filename.suffix) binaural_output_filename = output_filename.with_name( output_filename.stem + "_BINAURAL" + output_filename.suffix ) audiofile.write( binaural_output_filename, binaudio.audio, Loading
ivas_processing_scripts/generation/generate_ismN_items.py +32 −22 Original line number Diff line number Diff line Loading @@ -33,12 +33,16 @@ import csv import logging from itertools import groupby, repeat from math import floor import numpy as np from pathlib import Path import numpy as np from ivas_processing_scripts.audiotools import audio, audioarray, audiofile from ivas_processing_scripts.audiotools.convert.objectbased import convert_objectbased from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness, loudness_norm from ivas_processing_scripts.audiotools.wrappers.bs1770 import ( get_loudness, loudness_norm, ) from ivas_processing_scripts.generation import config from ivas_processing_scripts.utils import apply_func_parallel Loading Loading @@ -186,7 +190,9 @@ def generate_ismN_scene( # initialize output dirs ism_format = f"ISM{N_inputs}" output_filename = Path(scene["output"]).parent / (cfg.use_output_prefix + Path(scene["output"]).name) output_filename = Path(scene["output"]).parent / ( cfg.use_output_prefix + Path(scene["output"]).name ) dir_path = output_filename.parent if dir_path and not dir_path.exists(): Loading @@ -197,7 +203,6 @@ def generate_ismN_scene( # repeat for all source files for i in range(N_inputs): # parse parameters from the scene description source_file = ( scene["input"][i] if isinstance(scene["input"], list) else scene["input"] Loading Loading @@ -236,7 +241,9 @@ def generate_ismN_scene( logger.info(f"Encoding {source_file} at position(s) {source_azi},{source_ele}") # get input filename input_filename = Path(source_file).parent / (cfg.use_input_prefix + Path(source_file).name) input_filename = Path(source_file).parent / ( cfg.use_input_prefix + Path(source_file).name ) # generate ISM metadata .csv filename (should end with .wav..0.csv, .wav.1.csv, ...) y.metadata_files.insert(i, str(output_filename.with_suffix(f".{i}.csv"))) Loading Loading @@ -268,7 +275,9 @@ def generate_ismN_scene( # pad ISM signal with zeros to have the same length as the MASA signal N_pad = y.audio.shape[0] - x.audio.shape[0] if N_pad != 0: x.audio = audioarray.trim(x.audio, x.fs, limits=[0, -N_pad], samples=True) x.audio = audioarray.trim( x.audio, x.fs, limits=[0, -N_pad], samples=True ) # append ISM signal to the ISM object y.audio = np.append(y.audio, x.audio, axis=1) Loading Loading @@ -309,7 +318,7 @@ def generate_ismN_scene( azi = np.arange( float(eval(source_azi[0])), float(eval(source_azi[0])) + N_frames * float(eval(source_azi[1])), float(eval(source_azi[1])) float(eval(source_azi[1])), ) else: # replicate static azimuth value N_frames times Loading @@ -336,7 +345,7 @@ def generate_ismN_scene( ele = np.arange( float(eval(source_ele[0])), np.sign(float(eval(source_ele[1]))) * 90, float(eval(source_ele[1])) float(eval(source_ele[1])), )[:N_frames] # repeat the last elevation value, if array is shorter than N_frames Loading Loading @@ -381,10 +390,11 @@ def generate_ismN_scene( binaudio = audio.fromtype("BINAURAL") binaudio.fs = y.fs convert_objectbased(y, binaudio) binaural_output_filename = output_filename.with_name(output_filename.stem + "_BINAURAL" + output_filename.suffix) binaural_output_filename = output_filename.with_name( output_filename.stem + "_BINAURAL" + output_filename.suffix ) audiofile.write( binaural_output_filename, binaudio.audio, binaudio.fs, )