From 831fbfb68ccc68b1a231542505fae4b573336951 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 6 Feb 2025 15:55:49 +0100 Subject: [PATCH 1/4] [fix] bin_dataset and kwargs not passed to called functions --- ivas_processing_scripts/audiotools/convert/objectbased.py | 2 +- ivas_processing_scripts/audiotools/convert/scenebased.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ivas_processing_scripts/audiotools/convert/objectbased.py b/ivas_processing_scripts/audiotools/convert/objectbased.py index 94c3f792..2bfc1c0c 100755 --- a/ivas_processing_scripts/audiotools/convert/objectbased.py +++ b/ivas_processing_scripts/audiotools/convert/objectbased.py @@ -113,7 +113,7 @@ def render_oba_to_binaural( render_oba_to_cba(oba, cba_tmp) - render_cba_to_binaural(cba_tmp, bin, trajectory) + render_cba_to_binaural(cba_tmp, bin, trajectory, bin_dataset, **kwargs) else: IR, SourcePosition, latency_smp = load_ir(oba.name, bin.name, bin_dataset) diff --git a/ivas_processing_scripts/audiotools/convert/scenebased.py b/ivas_processing_scripts/audiotools/convert/scenebased.py index a2b42226..a8965532 100755 --- a/ivas_processing_scripts/audiotools/convert/scenebased.py +++ b/ivas_processing_scripts/audiotools/convert/scenebased.py @@ -123,7 +123,7 @@ def render_sba_to_binaural( render_sba_to_cba(sba, cba_tmp) - channelbased.render_cba_to_binaural(cba_tmp, bin, trajectory) + channelbased.render_cba_to_binaural(cba_tmp, bin, trajectory, bin_dataset, **kwargs) else: IR, _, latency_smp = load_ir(sba.name, bin.name, bin_dataset) -- GitLab From cd5b55a55da5f91323568d501e416d9c0ada4806 Mon Sep 17 00:00:00 2001 From: "CODE1\\320267694" Date: Wed, 19 Feb 2025 10:57:09 +0100 Subject: [PATCH 2/4] comments for understanding process flow + h5py support for importing custom brirs --- .../binaural_datasets/binaural_dataset.py | 11 ++++++++--- .../audiotools/convert/channelbased.py | 3 ++- .../audiotools/convert/scenebased.py | 17 +++++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py b/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py index 8b3b84de..e3208b3c 100755 --- a/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py +++ b/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py @@ -34,6 +34,8 @@ from pathlib import Path from typing import Optional, Tuple, Union from warnings import warn +import h5py +import copy import numpy as np from scipy.io import loadmat @@ -73,6 +75,7 @@ def load_hrtf( ) mat_contents = loadmat(filename) + #mat_contents = h5py.File(filename, 'r') try: IR = mat_contents["IR"] @@ -129,8 +132,8 @@ def load_ir( if in_fmt.startswith("MOZART"): dataset_suffix = "FULL" - elif in_fmt in CHANNEL_BASED_AUDIO_FORMATS.keys(): - dataset_suffix = "LS" + elif in_fmt in CHANNEL_BASED_AUDIO_FORMATS.keys(): ##This is triggered when -if HOA3 is passed from the command line. dataset suffix is being set to LS, and "FULL" mode cannot be used - in_format being used is 7_1_4. + dataset_suffix = "FULL" elif out_fmt.startswith("BINAURAL"): dataset_prefix = "HRIR" @@ -192,7 +195,9 @@ def load_ir( in_fmt = fromtype(in_fmt) tmp_fmt = fromtype("LS") - IR_tmp = IR.copy() + #IR_tmp = IR.copy() # Bug: deprecated function, no longer works + IR_tmp = np.array(IR, copy=True) + #IR_tmp = copy.deepcopy(IR) # -> error - h5py lists cannot be pickled IR = np.zeros([IR_tmp.shape[0], IR_tmp.shape[1], in_fmt.num_channels]) ir_index = 0 diff --git a/ivas_processing_scripts/audiotools/convert/channelbased.py b/ivas_processing_scripts/audiotools/convert/channelbased.py index dbb8b160..89ddc631 100755 --- a/ivas_processing_scripts/audiotools/convert/channelbased.py +++ b/ivas_processing_scripts/audiotools/convert/channelbased.py @@ -125,7 +125,7 @@ def render_cba_to_binaural( if trajectory is not None: cba.audio = rotate_cba(cba, trajectory) - IR, _, latency_smp = load_ir(cba.name, bin.name, bin_dataset) + IR, _, latency_smp = load_ir(cba.name, bin.name, bin_dataset) ##cba.name passed to this function is 7_1_4 -> this caused the renderer to attach suffix LS to the binaural dataset name in the next step # render LFE if bin_lfe_gain is not None: @@ -133,6 +133,7 @@ def render_cba_to_binaural( cba.audio, cba.fs, cba.lfe_index, bin_lfe_gain ) + ##The following two operations must be stateful for frame-wise, TCP enabled rendering # render rest of the signal bin.audio = binaural_fftconv(cba.audio, IR, cba.num_channels, cba.lfe_index) # compensate delay from binaural dataset diff --git a/ivas_processing_scripts/audiotools/convert/scenebased.py b/ivas_processing_scripts/audiotools/convert/scenebased.py index a2b42226..6cc65620 100755 --- a/ivas_processing_scripts/audiotools/convert/scenebased.py +++ b/ivas_processing_scripts/audiotools/convert/scenebased.py @@ -89,6 +89,7 @@ def convert_scenebased( f"Conversion from {sba.name} to {out.name} is unsupported!" ) +#Rendered Audio is returned here return out @@ -114,16 +115,23 @@ def render_sba_to_binaural( Name of binaural dataset without prefix or suffix """ - if trajectory is not None: + if trajectory is not None: ##Trajectory option for pre-coded head rotations?? sba.audio = rotate_sba(sba, trajectory) - if "ROOM" in bin.name: + if "ROOM" in bin.name: #this is triggered for BINAURAL_ROOM option + ##Does this have be changed based on the new angles mode in SOFA? Or based on input format? cba_tmp = audio.fromtype("7_1_4") + ##Temporary change to 5_1 + ##cba_tmp = audio.fromtype("5_1") cba_tmp.fs = sba.fs render_sba_to_cba(sba, cba_tmp) - channelbased.render_cba_to_binaural(cba_tmp, bin, trajectory) + ##connect cba_tmp to ivas python renderer + + #Binaural dataset name is not being passeed here + channelbased.render_cba_to_binaural(cba_tmp, bin, trajectory, bin_dataset) + #channelbased.render_cba_to_binaural(cba_tmp, bin, **kwargs) - does not work if **kwargs is passed as an argument else: IR, _, latency_smp = load_ir(sba.name, bin.name, bin_dataset) @@ -156,6 +164,7 @@ def render_sba_to_cba( Channel-based output audio """ + ##recreate render_mtx = get_allrad_mtx(sba.ambi_order, cba) cba.audio = sba.audio @ render_mtx.T @@ -411,7 +420,7 @@ def get_allrad_mtx( ALLRAD matrix """ - n_harm = nchan_from_ambi_order(ambi_order) + n_harm = nchan_from_ambi_order(ambi_order) ## (ambi_order + 1)`** 2` if cba.name == "MONO": hoa_dec = np.zeros([1, n_harm]) -- GitLab From 6ef42202c5c3c3aca055ce5bece9a1494826fb1d Mon Sep 17 00:00:00 2001 From: "CODE1\\320267694" Date: Wed, 19 Feb 2025 11:05:19 +0100 Subject: [PATCH 3/4] resolve conflicts --- ivas_processing_scripts/audiotools/convert/scenebased.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivas_processing_scripts/audiotools/convert/scenebased.py b/ivas_processing_scripts/audiotools/convert/scenebased.py index bd6293da..e6553910 100755 --- a/ivas_processing_scripts/audiotools/convert/scenebased.py +++ b/ivas_processing_scripts/audiotools/convert/scenebased.py @@ -130,7 +130,7 @@ def render_sba_to_binaural( ##connect cba_tmp to ivas python renderer #Binaural dataset name is not being passeed here - channelbased.render_cba_to_binaural(cba_tmp, bin, trajectory, bin_dataset, **kwargs, bin_dataset) + channelbased.render_cba_to_binaural(cba_tmp, bin, trajectory, bin_dataset, **kwargs) #channelbased.render_cba_to_binaural(cba_tmp, bin, **kwargs) - does not work if **kwargs is passed as an argument else: IR, _, latency_smp = load_ir(sba.name, bin.name, bin_dataset) -- GitLab From 4e1326e9c9ae91415a278111f8d8f00d277511f5 Mon Sep 17 00:00:00 2001 From: "CODE1\\320267694" Date: Wed, 19 Feb 2025 14:08:38 +0100 Subject: [PATCH 4/4] removed h5py import --- .../audiotools/binaural_datasets/binaural_dataset.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py b/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py index e3208b3c..8198b27f 100755 --- a/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py +++ b/ivas_processing_scripts/audiotools/binaural_datasets/binaural_dataset.py @@ -34,8 +34,6 @@ from pathlib import Path from typing import Optional, Tuple, Union from warnings import warn -import h5py -import copy import numpy as np from scipy.io import loadmat -- GitLab