From e9530a1263ded1dfe256f02e5bb4316b56219963 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 22 Aug 2025 15:36:16 +0200 Subject: [PATCH] [fix] preamble/repeat removal for JBM reference condition for loudness; refactor logic for JBM loudness scaling to be a bit clearer --- ivas_processing_scripts/processing/processing.py | 12 ++++++------ .../processing/processing_splitting_scaling.py | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 51380988..aa495efa 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -200,29 +200,29 @@ def concat_teardown( in_fs, meta, tracefile, - ivas_jbm, + tracefile_needed, repeat_signal, preamble, logger: logging.Logger, ): if splits is None: raise ValueError("Splitting not possible without split marker") - if ivas_jbm and tracefile is None: + if tracefile_needed and tracefile is None: raise ValueError( "Splitting for IVAS JBM conditions not possible without tracefile" ) - if (out_fmt.startswith("ISM") or out_fmt.startswith("MASA")) and ivas_jbm: + if (out_fmt.startswith("ISM") or out_fmt.startswith("MASA")) and tracefile_needed: raise ValueError( "Splitting with JBM compensation not supported for formats with metadata (e.g. MASA, ISM)" ) - if logger and ivas_jbm: + if logger and tracefile_needed: logger.debug("Split files with JBM compensation") elif logger: logger.debug("Split files") - if not ivas_jbm: + if not tracefile_needed: # if sampling rate changed, adjust splits fs_new = float(fs) fs_old = float(in_fs) @@ -257,7 +257,7 @@ def concat_teardown( raise ValueError( f"Last split index {splits[-1]} is larger than the signal length {len(x)}" ) - elif (splits[-1] < len(x)) and not ivas_jbm: + elif (splits[-1] < len(x)) and not tracefile_needed: warn( f"Last split index {splits[-1]} is smaller than the signal length {len(x)}" ) diff --git a/ivas_processing_scripts/processing/processing_splitting_scaling.py b/ivas_processing_scripts/processing/processing_splitting_scaling.py index 597e256a..e6edc173 100644 --- a/ivas_processing_scripts/processing/processing_splitting_scaling.py +++ b/ivas_processing_scripts/processing/processing_splitting_scaling.py @@ -203,7 +203,9 @@ class Processing_splitting_scaling(Processing): def revert_preamble_concatenation( self, x, fs, in_file, out_file, in_meta, noerror=False, logger=None ): - if self.ivas_jbm and not noerror: + tracefile_needed = self.ivas_jbm and not noerror + + if tracefile_needed: # read JBM data tracefile = in_file.with_name(f"{in_file.name.split('.')[0]}.tracefile.csv") tracefile_data = np.genfromtxt(tracefile, delimiter=";") @@ -213,7 +215,7 @@ class Processing_splitting_scaling(Processing): # remove preamble and first half of signal due to repetition # JBM conditions are handled later in concat_teardown - if not self.ivas_jbm and (self.preamble or self.repeat_signal): + if not tracefile_needed and (self.preamble or self.repeat_signal): x, in_meta = remove_preamble( x, self.out_fmt, @@ -249,7 +251,7 @@ class Processing_splitting_scaling(Processing): split_fs, in_meta, tracefile_data, - ivas_jbm_splitting_flag, + tracefile_needed, self.repeat_signal, self.preamble, logger, -- GitLab