Commit 566cc0d4 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch '105-characterization-loudness-normalization-for-jbm-conditions-buggy' into 'main'

Resolve "[characterization] Loudness normalization for JBM conditions buggy"

See merge request !202
parents f4502ee3 e9530a12
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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)}"
        )
+5 −3
Original line number Diff line number Diff line
@@ -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,