diff --git a/README.md b/README.md index b0a0912412f01c6d28a637f08d08efae908405d9..3106bcbde77ce8c482ecc1594d4cbabdca6fc406 100755 --- a/README.md +++ b/README.md @@ -253,6 +253,8 @@ input: # background_noise_path: ".../noise.wav" ### Flag for using low level [-4,+4] background noise; default = false # low_level_noise: true + ### Flag for repeating the whole signal once and discarding the first half after processing + # repeat_signal: true ``` diff --git a/examples/TEMPLATE.yml b/examples/TEMPLATE.yml index a5039d4d1f6e327579f3466182c650a113a94dea..270be375381794af3646f198248bc3fa7ed6070d 100755 --- a/examples/TEMPLATE.yml +++ b/examples/TEMPLATE.yml @@ -117,6 +117,8 @@ input: # background_noise_path: ".../noise.wav" ### Flag for using low level [-4,+4] background noise; default = false # low_level_noise: true + ### Flag for repeating the whole signal once and discarding the first half after processing + # repeat_signal: true ################################################# ### Bitstream processing diff --git a/experiments/selection/P800-2/config/P800-2.yml b/experiments/selection/P800-2/config/P800-2.yml index af6d38ccf162aa1f0d05f88713ea2fa878de25e6..86f717898baba8c6e224ec089722f083eb3562d5 100644 --- a/experiments/selection/P800-2/config/P800-2.yml +++ b/experiments/selection/P800-2/config/P800-2.yml @@ -40,6 +40,7 @@ preprocessing_2: snr: 15 ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s) background_noise_path: "experiments/selection/P800-2/background_noise/background_noise.wav" + repeat_signal: true ################################################# ### Bitstream processing diff --git a/experiments/selection/P800-4/config/P800-4.yml b/experiments/selection/P800-4/config/P800-4.yml index d48a900ec4a73922a4d3f1dbb2f2b0160a74a5d7..6c3a53ac6d01bd5e3b6c80d7a8539e554ed7b575 100644 --- a/experiments/selection/P800-4/config/P800-4.yml +++ b/experiments/selection/P800-4/config/P800-4.yml @@ -35,6 +35,7 @@ preprocessing_2: # concatenation_order: [] preamble: 10000 preamble_noise: true + repeat_signal: true ################################################# ### Bitstream processing diff --git a/experiments/selection/P800-5/config/P800-5.yml b/experiments/selection/P800-5/config/P800-5.yml index de93f64d2d9266f936c584076cfe56a930d9a396..1b7d50a9fef5c12fe3101bee1e0c7175e63a2688 100644 --- a/experiments/selection/P800-5/config/P800-5.yml +++ b/experiments/selection/P800-5/config/P800-5.yml @@ -40,6 +40,7 @@ preprocessing_2: snr: 15 ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s) background_noise_path: "experiments/selection/P800-5/background_noise/background_noise.wav" + repeat_signal: true ################################################# ### Bitstream processing diff --git a/ivas_processing_scripts/audiotools/convert/channelbased.py b/ivas_processing_scripts/audiotools/convert/channelbased.py index 480d635e5019a9e0e2a496a3edeefc25285e13f3..5b9874a2f818b63a54802684c00228e8bde8a42c 100755 --- a/ivas_processing_scripts/audiotools/convert/channelbased.py +++ b/ivas_processing_scripts/audiotools/convert/channelbased.py @@ -112,6 +112,10 @@ def render_cba_to_binaural( render_cba_to_cba(cba, cba_stereo) bin.audio = cba_stereo.audio return + elif cba.name == "STEREO": + # no binauralization possible for stereo -> assume binaural signal + bin.audio = cba.audio + return cba.audio = resample_itu(cba, 48000) old_fs = cba.fs diff --git a/ivas_processing_scripts/generation/process_ism_items.py b/ivas_processing_scripts/generation/process_ism_items.py index cb8a46b8668a4b84ad49c4970f36e155d82aad57..ff123663c66a77686e29c67c154c462e14017d7e 100644 --- a/ivas_processing_scripts/generation/process_ism_items.py +++ b/ivas_processing_scripts/generation/process_ism_items.py @@ -102,10 +102,22 @@ def generate_ism_items( # repeat for all source files for i in range(N_sources): # parse parameters from the scene description - source_file = scene["source"][i] if isinstance(scene["source"], list) else scene["source"] - source_azi = scene["azimuth"][i] if isinstance(scene["azimuth"], list) else scene["azimuth"] - source_ele = scene["elevation"][i] if isinstance(scene["elevation"], list) else scene["elevation"] - + source_file = ( + scene["source"][i] + if isinstance(scene["source"], list) + else scene["source"] + ) + source_azi = ( + scene["azimuth"][i] + if isinstance(scene["azimuth"], list) + else scene["azimuth"] + ) + source_ele = ( + scene["elevation"][i] + if isinstance(scene["elevation"], list) + else scene["elevation"] + ) + logger.info( f"Encoding {source_file} at position(s) {source_azi},{source_ele}" ) diff --git a/ivas_processing_scripts/processing/chains.py b/ivas_processing_scripts/processing/chains.py index c11be9a1bc54700ee37cb9d3e6624fefcea19935..9e368f06ca2fb4821afa3884ce0c15bb17c72f0b 100755 --- a/ivas_processing_scripts/processing/chains.py +++ b/ivas_processing_scripts/processing/chains.py @@ -182,6 +182,7 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: "background_noise": background, "in_mask": pre2_cfg.get("mask", None), "multiprocessing": cfg.multiprocessing, + "repeat_signal": pre2_cfg.get("repeat_signal", False), } ) ) diff --git a/ivas_processing_scripts/processing/preprocessing_2.py b/ivas_processing_scripts/processing/preprocessing_2.py index 0e84c44780d3ca775cfde3b448a284de9c42b071..b5f4e9b60dcd962e69966dee16bd4fbaae5921fb 100644 --- a/ivas_processing_scripts/processing/preprocessing_2.py +++ b/ivas_processing_scripts/processing/preprocessing_2.py @@ -81,6 +81,8 @@ class Preprocessing2(Processing): # modify metadata metadata = add_remove_preamble(metadata, preamble) + if self.repeat_signal: + metadata = [np.concatenate((m, m), axis=0) for m in metadata] meta_files = write_ISM_metadata_in_file(metadata, [out_file], True) # modify audio object @@ -106,6 +108,13 @@ class Preprocessing2(Processing): audio_object, in_meta, logger ) + # repeat whole signal as part of preamble + if self.repeat_signal: + logger.debug("Repeat signal") + audio_object.audio = np.concatenate( + (audio_object.audio, audio_object.audio), axis=0 + ) + # save file write(out_file, audio_object.audio, fs=audio_object.fs) diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index cfc5a3811af66f6abc2406ae9cd1134435315b9a..ac12784b54f6c3e8bfd77407089cac25a63fb861 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -323,10 +323,9 @@ def preprocess_2(cfg, logger): def reverse_process_2(cfg, logger): - # remove preamble - if cfg.pre2.preamble: - logger.info("Remove preamble") - remove_preamble(cfg) + # remove preamble and first half of signal due to repetition + if cfg.pre2.preamble or cfg.pre2.repeat_signal: + remove_preamble(cfg, logger) # reverse concatenation if cfg.pre2.concatenate_input: @@ -443,7 +442,7 @@ def process_item( copyfile(ppm, out_meta[idx]) -def remove_preamble(cfg): +def remove_preamble(cfg, logger): # get number of channels from output format num_channels = audio.fromtype(cfg.postprocessing["fmt"]).num_channels for odir in cfg.out_dirs: @@ -460,10 +459,15 @@ def remove_preamble(cfg): for meta_i in meta_item: metadata_array.append(np.genfromtxt(meta_i, delimiter=",")) + # cut first half of the metadata + if cfg.pre2.repeat_signal: + metadata_array = [m[int(len(m) / 2) :, :] for m in metadata_array] + # remove preamble - metadata_array = add_remove_preamble( - metadata_array, cfg.pre2.preamble, add=False - ) + if cfg.pre2.preamble: + metadata_array = add_remove_preamble( + metadata_array, cfg.pre2.preamble, add=False + ) # write csv files write_ISM_metadata_in_file( @@ -475,8 +479,15 @@ def remove_preamble(cfg): path_input, nchannels=num_channels, fs=cfg.postprocessing["fs"] ) + # remove first half of signal + if cfg.pre2.repeat_signal: + logger.info("Remove first half of signal") + x = x[int(len(x) / 2) :, :] + # remove preamble - x = trim(x, fs, (cfg.pre2.preamble, 0)) + if cfg.pre2.preamble: + logger.info("Remove preamble") + x = trim(x, fs, (cfg.pre2.preamble, 0)) # write file write(path_input, x, fs)