Loading ivas_processing_scripts/audiotools/wrappers/reverb.py +23 −5 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ def reverb( input: Audio, IR: Audio, align: Optional[float] = None, mode: Optional[str] = None, ) -> Audio: """ Wrapper for the ITU-T reverb binary to convolve mono audio signal with an impulse response Loading @@ -63,6 +64,9 @@ def reverb( Impulse response align: float multiplicative factor to apply to the reverberated sound in order to align its energy level with a second filePath to the output file mode: str, optional Mode of operation, None - no operation on the output, "same" centers the output signals by trimming left and right edge effects equally "trim_left" - trims the left edge, "trim_right" - trims the right edge. Returns ------- Loading Loading @@ -122,14 +126,24 @@ def reverb( tmp_output_file = tmp_dir.joinpath("tmp_reverbOut.pcm") cmd.extend([tmp_input_file, tmp_IR_file, tmp_output_file]) # run the 'reverb' command # run the 'reverb' command (automatically prepends N zeros to the input signal to keep the output length the same as the input) run(cmd) # read the reverberated output file output = copy(tmp_input) output.audio, _ = read(tmp_output_file, nchannels=1, fs=tmp_input.fs) # remove trailing part (to ensure that the length of the output is the same as the input) # trim the output if mode == "same": # center the output by trimming left and right edge effects equally output.audio = output.audio[ (IR.audio.shape[0] - 1) // 2 : -(IR.audio.shape[0] - 1) // 2, : ] elif mode == "trim_left": # trim the left edge output.audio = output.audio[(IR.audio.shape[0] - 1) :, :] elif mode == "trim_right": # trim the right edge output.audio = output.audio[: -(IR.audio.shape[0] - 1), :] if old_fs: Loading @@ -143,6 +157,7 @@ def reverb_stereo( input: Audio, stereo_IR: Audio, align: Optional[float] = None, mode: Optional[str] = None, ) -> Audio: """ Wrapper for the ITU-T reverb binary to convolve mono audio signal with a stereo impulse response Loading @@ -155,6 +170,9 @@ def reverb_stereo( Impulse response align: float multiplicative factor to apply to the reverberated sound in order to align its energy level with the second file mode: str, optional Mode of operation, None - no operation on the output, "same" centers the output signals by trimming left and right edge effects equally "trim_left" - trims the left edge, "trim_right" - trims the right edge. Returns ------- Loading Loading @@ -182,8 +200,8 @@ def reverb_stereo( align = 1.0 / np.max(np.abs(H)) # convolve mono input with left and right IR y_left = reverb(input, IR_left, align=align) y_right = reverb(input, IR_right, align=align) y_left = reverb(input, IR_left, align=align, mode=mode) y_right = reverb(input, IR_right, align=align, mode=mode) # combine into stereo output y = audio.fromtype("STEREO") Loading ivas_processing_scripts/generation/generate_masa_items.py +3 −3 Original line number Diff line number Diff line Loading @@ -292,11 +292,11 @@ def generate_MASA_scene( # convolve MONO source audio with FOA/HOA2/HOA3 IR -> results in FOA/HOA2/HOA3 audio object if IR_fmt == "FOA": x = reverb_foa(x, IR) x = reverb_foa(x, IR, mode=None) elif IR_fmt == "HOA2": x = reverb_hoa2(x, IR) x = reverb_hoa2(x, IR, mode=None) elif IR_fmt == "HOA3": x = reverb_hoa3(x, IR) x = reverb_hoa3(x, IR, mode=None) # adjust the level of the FOA/HOA2/HOA3 signal x.audio, _ = loudness_norm(x, level, loudness_format="STEREO") Loading ivas_processing_scripts/generation/generate_mc_items.py +3 −3 Original line number Diff line number Diff line Loading @@ -292,11 +292,11 @@ def generate_MC_scene( # convolve MONO source audio with FOA/HOA2/HOA3 IR -> results in FOA/HOA2/HOA3 audio object if IR_fmt == "FOA": x = reverb_foa(x, IR) x = reverb_foa(x, IR, mode=None) elif IR_fmt == "HOA2": x = reverb_hoa2(x, IR) x = reverb_hoa2(x, IR, mode=None) elif IR_fmt == "HOA3": x = reverb_hoa3(x, IR) x = reverb_hoa3(x, IR, mode=None) # adjust the level of the FOA/HOA2/HOA3 signal x.audio, _ = loudness_norm(x, level, loudness_format="STEREO") Loading ivas_processing_scripts/generation/generate_sba_items.py +3 −3 Original line number Diff line number Diff line Loading @@ -262,11 +262,11 @@ def generate_sba_scene( # convolve MONO source audio with FOA/HOA2/HOA3 IR -> results in FOA/HOA2/HOA3 audio object if cfg.format == "FOA": x = reverb_foa(x, IR) x = reverb_foa(x, IR, mode=None) elif cfg.format == "HOA2": x = reverb_hoa2(x, IR) x = reverb_hoa2(x, IR, mode=None) elif cfg.format == "HOA3": x = reverb_hoa3(x, IR) x = reverb_hoa3(x, IR, mode=None) # adjust the level of the FOA/HOA2/HOA3 signal x.audio, _ = loudness_norm(x, level, loudness_format="STEREO") Loading ivas_processing_scripts/generation/generate_stereo_items.py +1 −1 Original line number Diff line number Diff line Loading @@ -267,7 +267,7 @@ def generate_stereo_scene( IR = audio.fromfile("STEREO", IR_filename) # convolve MONO source audio with STEREO IR -> results in STEREO audio object x = reverb_stereo(x, IR) x = reverb_stereo(x, IR, mode=None) # adjust the level of the STEREO signal x.audio, _ = loudness_norm(x, level, loudness_format="STEREO") Loading Loading
ivas_processing_scripts/audiotools/wrappers/reverb.py +23 −5 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ def reverb( input: Audio, IR: Audio, align: Optional[float] = None, mode: Optional[str] = None, ) -> Audio: """ Wrapper for the ITU-T reverb binary to convolve mono audio signal with an impulse response Loading @@ -63,6 +64,9 @@ def reverb( Impulse response align: float multiplicative factor to apply to the reverberated sound in order to align its energy level with a second filePath to the output file mode: str, optional Mode of operation, None - no operation on the output, "same" centers the output signals by trimming left and right edge effects equally "trim_left" - trims the left edge, "trim_right" - trims the right edge. Returns ------- Loading Loading @@ -122,14 +126,24 @@ def reverb( tmp_output_file = tmp_dir.joinpath("tmp_reverbOut.pcm") cmd.extend([tmp_input_file, tmp_IR_file, tmp_output_file]) # run the 'reverb' command # run the 'reverb' command (automatically prepends N zeros to the input signal to keep the output length the same as the input) run(cmd) # read the reverberated output file output = copy(tmp_input) output.audio, _ = read(tmp_output_file, nchannels=1, fs=tmp_input.fs) # remove trailing part (to ensure that the length of the output is the same as the input) # trim the output if mode == "same": # center the output by trimming left and right edge effects equally output.audio = output.audio[ (IR.audio.shape[0] - 1) // 2 : -(IR.audio.shape[0] - 1) // 2, : ] elif mode == "trim_left": # trim the left edge output.audio = output.audio[(IR.audio.shape[0] - 1) :, :] elif mode == "trim_right": # trim the right edge output.audio = output.audio[: -(IR.audio.shape[0] - 1), :] if old_fs: Loading @@ -143,6 +157,7 @@ def reverb_stereo( input: Audio, stereo_IR: Audio, align: Optional[float] = None, mode: Optional[str] = None, ) -> Audio: """ Wrapper for the ITU-T reverb binary to convolve mono audio signal with a stereo impulse response Loading @@ -155,6 +170,9 @@ def reverb_stereo( Impulse response align: float multiplicative factor to apply to the reverberated sound in order to align its energy level with the second file mode: str, optional Mode of operation, None - no operation on the output, "same" centers the output signals by trimming left and right edge effects equally "trim_left" - trims the left edge, "trim_right" - trims the right edge. Returns ------- Loading Loading @@ -182,8 +200,8 @@ def reverb_stereo( align = 1.0 / np.max(np.abs(H)) # convolve mono input with left and right IR y_left = reverb(input, IR_left, align=align) y_right = reverb(input, IR_right, align=align) y_left = reverb(input, IR_left, align=align, mode=mode) y_right = reverb(input, IR_right, align=align, mode=mode) # combine into stereo output y = audio.fromtype("STEREO") Loading
ivas_processing_scripts/generation/generate_masa_items.py +3 −3 Original line number Diff line number Diff line Loading @@ -292,11 +292,11 @@ def generate_MASA_scene( # convolve MONO source audio with FOA/HOA2/HOA3 IR -> results in FOA/HOA2/HOA3 audio object if IR_fmt == "FOA": x = reverb_foa(x, IR) x = reverb_foa(x, IR, mode=None) elif IR_fmt == "HOA2": x = reverb_hoa2(x, IR) x = reverb_hoa2(x, IR, mode=None) elif IR_fmt == "HOA3": x = reverb_hoa3(x, IR) x = reverb_hoa3(x, IR, mode=None) # adjust the level of the FOA/HOA2/HOA3 signal x.audio, _ = loudness_norm(x, level, loudness_format="STEREO") Loading
ivas_processing_scripts/generation/generate_mc_items.py +3 −3 Original line number Diff line number Diff line Loading @@ -292,11 +292,11 @@ def generate_MC_scene( # convolve MONO source audio with FOA/HOA2/HOA3 IR -> results in FOA/HOA2/HOA3 audio object if IR_fmt == "FOA": x = reverb_foa(x, IR) x = reverb_foa(x, IR, mode=None) elif IR_fmt == "HOA2": x = reverb_hoa2(x, IR) x = reverb_hoa2(x, IR, mode=None) elif IR_fmt == "HOA3": x = reverb_hoa3(x, IR) x = reverb_hoa3(x, IR, mode=None) # adjust the level of the FOA/HOA2/HOA3 signal x.audio, _ = loudness_norm(x, level, loudness_format="STEREO") Loading
ivas_processing_scripts/generation/generate_sba_items.py +3 −3 Original line number Diff line number Diff line Loading @@ -262,11 +262,11 @@ def generate_sba_scene( # convolve MONO source audio with FOA/HOA2/HOA3 IR -> results in FOA/HOA2/HOA3 audio object if cfg.format == "FOA": x = reverb_foa(x, IR) x = reverb_foa(x, IR, mode=None) elif cfg.format == "HOA2": x = reverb_hoa2(x, IR) x = reverb_hoa2(x, IR, mode=None) elif cfg.format == "HOA3": x = reverb_hoa3(x, IR) x = reverb_hoa3(x, IR, mode=None) # adjust the level of the FOA/HOA2/HOA3 signal x.audio, _ = loudness_norm(x, level, loudness_format="STEREO") Loading
ivas_processing_scripts/generation/generate_stereo_items.py +1 −1 Original line number Diff line number Diff line Loading @@ -267,7 +267,7 @@ def generate_stereo_scene( IR = audio.fromfile("STEREO", IR_filename) # convolve MONO source audio with STEREO IR -> results in STEREO audio object x = reverb_stereo(x, IR) x = reverb_stereo(x, IR, mode=None) # adjust the level of the STEREO signal x.audio, _ = loudness_norm(x, level, loudness_format="STEREO") Loading