Commit 6a6e89e9 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

fix incorrect overlap handling

parent a221268b
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ def generate_ism_items(
                N_delay = len(y.audio[:, 0])

                # add the shift
                N_delay += int(source_overlap * x.fs)
                N_delay += int(-source_overlap * x.fs)

                # ensure delay is a multiple of 20ms
                # N_delay = int(floor(source_shift * 50) / 50 * x.fs)
+13 −13
Original line number Diff line number Diff line
@@ -121,11 +121,11 @@ def generate_stereo_items(
            )

            # convolve with stereo IR
            x_rev = reverb_stereo(x, IR)
            x = reverb_stereo(x, IR)

            # adjust the level of the stereo signal
            _, scale_factor = get_loudness(x_rev, cfg.loudness, "STEREO")
            x_rev.audio *= scale_factor
            _, scale_factor = get_loudness(x, cfg.loudness, "STEREO")
            x.audio *= scale_factor

            # shift the second (and all other) source files (positive shift creates overlap, negative shift creates a gap)
            if i > 0 and source_overlap != 0.0:
@@ -133,7 +133,7 @@ def generate_stereo_items(
                N_delay = len(y.audio[:, 0])

                # add the shift
                N_delay += int(source_overlap * x.fs)
                N_delay += int(-source_overlap * x.fs)

                # ensure delay is a multiple of 20ms
                # N_delay = int(floor(source_shift * 50) / 50 * x.fs)
@@ -154,36 +154,36 @@ def generate_stereo_items(
            # add source signal to the array of source signals
            y.fs = x.fs
            if y.audio is None:
                y.audio = x_rev.audio
                y.audio = x.audio
            else:
                # pad with zeros to have equal length of all source signals
                if x_rev.audio.shape[0] > y.audio.shape[0]:
                if x.audio.shape[0] > y.audio.shape[0]:
                    y.audio = np.vstack(
                        (
                            y.audio,
                            np.zeros(
                                (
                                    x_rev.audio.shape[0] - y.audio.shape[0],
                                    x.audio.shape[0] - y.audio.shape[0],
                                    y.audio.shape[1],
                                )
                            ),
                        )
                    )
                elif y.audio.shape[0] > x_rev.audio.shape[0]:
                    x_rev.audio = np.vstack(
                elif y.audio.shape[0] > x.audio.shape[0]:
                    x.audio = np.vstack(
                        (
                            x_rev.audio,
                            x.audio,
                            np.zeros(
                                (
                                    y.audio.shape[0] - x_rev.audio.shape[0],
                                    x_rev.audio.shape[1],
                                    y.audio.shape[0] - x.audio.shape[0],
                                    x.audio.shape[1],
                                )
                            ),
                        )
                    )

                # superimpose
                y.audio += x_rev.audio
                y.audio += x.audio

        # append pre-amble and post-amble to all sources
        if cfg.preamble != 0.0: