Loading ivas_processing_scripts/audiotools/audiofile.py +14 −3 Original line number Diff line number Diff line Loading @@ -34,11 +34,13 @@ import logging import struct from pathlib import Path from typing import Optional, Tuple, Union from warnings import warn import numpy as np import scipy.io.wavfile as wav from .audioarray import trim, window from .constants import VERT_HOA_CHANNELS_ACN logger = logging.getLogger("__main__") logger.setLevel(logging.DEBUG) Loading Loading @@ -326,6 +328,8 @@ def split_channels( in_file: str, out_filenames: list, in_nchans: int, out_nchans: int, is_planar: Optional[bool] = False, in_fs: Optional[int] = 48000, ) -> None: """ Loading @@ -339,6 +343,10 @@ def split_channels( List of output file names (.pcm, .raw or .wav) in_nchans: int Input number of channels out_nchans: int Number of channels to be split is_planar: Optional[bool] If true vertical SBA channels are set to zero in_fs: Optional[int] = 48000 Input sampling rate, default 48000 Hz Loading @@ -350,14 +358,17 @@ def split_channels( # validation if in_nchans is None: raise ValueError("Number of channels to split must be specified!") if in_nchans != len(out_filenames): print( if out_nchans != len(out_filenames): warn( "Split: Mismatch between number of channels and output filenames length. Truncating output filenames list." ) out_filenames = out_filenames[:in_nchans] out_filenames = out_filenames[:out_nchans] x, in_fs = read(in_file, nchannels=in_nchans, fs=in_fs) if is_planar: x[:, VERT_HOA_CHANNELS_ACN[VERT_HOA_CHANNELS_ACN < in_nchans]] = 0 # Write output files for idx, out_file in enumerate(out_filenames): # extract correct channel Loading ivas_processing_scripts/processing/chains.py +2 −0 Original line number Diff line number Diff line Loading @@ -300,11 +300,13 @@ def get_processing_chain( "tx": tx_cfg, "preamble": preamble, "evs_lfe_9k6bps_nb": evs_lfe_9k6bps_nb, "sba_format": cond_cfg.get("sba_format", tmp_in_fmt), } ) ) # update values to reflect decoder output tmp_in_fs = dec_cfg.get("fs", tmp_in_fs) tmp_in_fmt = cond_cfg.get("sba_format", cfg.input["fmt"]) elif cond_cfg["type"] == "ivas": cod_cfg = cond_cfg["cod"] Loading ivas_processing_scripts/processing/evs.py +20 −3 Original line number Diff line number Diff line Loading @@ -167,16 +167,33 @@ class EVS(Processing): if not self.out_fs: self.out_fs = self.in_fs # consider SBA format for condition condition_fmt = audio.fromtype(self.sba_format) if isinstance(self.in_fmt, audio.SceneBasedAudio): if not isinstance(condition_fmt, audio.SceneBasedAudio) or ( condition_fmt.num_channels > self.in_fmt.num_channels ): raise ValueError( "SBA format has to be SBA with lower order than input signal" ) is_planar = condition_fmt.is_planar else: if self.in_fmt.name != condition_fmt.name: raise ValueError("Cannot specify SBA format for non SBA input formats") is_planar = False # Split the channels to prepare for multi-mono coding split_chan_files = [ out_file.with_suffix(f".{i}.pcm") for i in range(self.in_fmt.num_channels) out_file.with_suffix(f".{i}.pcm") for i in range(condition_fmt.num_channels) ] split_channels( in_file, split_chan_files, self.in_fmt.num_channels, self.in_fs, in_nchans=self.in_fmt.num_channels, out_nchans=condition_fmt.num_channels, in_fs=self.in_fs, is_planar=is_planar, ) # run processing Loading tests/data/test_SBA.yml +1 −0 Original line number Diff line number Diff line Loading @@ -265,6 +265,7 @@ conditions_to_generate: ### For possible arguments see overall bitstream modification type: "JBM" error_profile: 3 sba_format: "PLANARFOA" ################################################ ### Post-processing Loading Loading
ivas_processing_scripts/audiotools/audiofile.py +14 −3 Original line number Diff line number Diff line Loading @@ -34,11 +34,13 @@ import logging import struct from pathlib import Path from typing import Optional, Tuple, Union from warnings import warn import numpy as np import scipy.io.wavfile as wav from .audioarray import trim, window from .constants import VERT_HOA_CHANNELS_ACN logger = logging.getLogger("__main__") logger.setLevel(logging.DEBUG) Loading Loading @@ -326,6 +328,8 @@ def split_channels( in_file: str, out_filenames: list, in_nchans: int, out_nchans: int, is_planar: Optional[bool] = False, in_fs: Optional[int] = 48000, ) -> None: """ Loading @@ -339,6 +343,10 @@ def split_channels( List of output file names (.pcm, .raw or .wav) in_nchans: int Input number of channels out_nchans: int Number of channels to be split is_planar: Optional[bool] If true vertical SBA channels are set to zero in_fs: Optional[int] = 48000 Input sampling rate, default 48000 Hz Loading @@ -350,14 +358,17 @@ def split_channels( # validation if in_nchans is None: raise ValueError("Number of channels to split must be specified!") if in_nchans != len(out_filenames): print( if out_nchans != len(out_filenames): warn( "Split: Mismatch between number of channels and output filenames length. Truncating output filenames list." ) out_filenames = out_filenames[:in_nchans] out_filenames = out_filenames[:out_nchans] x, in_fs = read(in_file, nchannels=in_nchans, fs=in_fs) if is_planar: x[:, VERT_HOA_CHANNELS_ACN[VERT_HOA_CHANNELS_ACN < in_nchans]] = 0 # Write output files for idx, out_file in enumerate(out_filenames): # extract correct channel Loading
ivas_processing_scripts/processing/chains.py +2 −0 Original line number Diff line number Diff line Loading @@ -300,11 +300,13 @@ def get_processing_chain( "tx": tx_cfg, "preamble": preamble, "evs_lfe_9k6bps_nb": evs_lfe_9k6bps_nb, "sba_format": cond_cfg.get("sba_format", tmp_in_fmt), } ) ) # update values to reflect decoder output tmp_in_fs = dec_cfg.get("fs", tmp_in_fs) tmp_in_fmt = cond_cfg.get("sba_format", cfg.input["fmt"]) elif cond_cfg["type"] == "ivas": cod_cfg = cond_cfg["cod"] Loading
ivas_processing_scripts/processing/evs.py +20 −3 Original line number Diff line number Diff line Loading @@ -167,16 +167,33 @@ class EVS(Processing): if not self.out_fs: self.out_fs = self.in_fs # consider SBA format for condition condition_fmt = audio.fromtype(self.sba_format) if isinstance(self.in_fmt, audio.SceneBasedAudio): if not isinstance(condition_fmt, audio.SceneBasedAudio) or ( condition_fmt.num_channels > self.in_fmt.num_channels ): raise ValueError( "SBA format has to be SBA with lower order than input signal" ) is_planar = condition_fmt.is_planar else: if self.in_fmt.name != condition_fmt.name: raise ValueError("Cannot specify SBA format for non SBA input formats") is_planar = False # Split the channels to prepare for multi-mono coding split_chan_files = [ out_file.with_suffix(f".{i}.pcm") for i in range(self.in_fmt.num_channels) out_file.with_suffix(f".{i}.pcm") for i in range(condition_fmt.num_channels) ] split_channels( in_file, split_chan_files, self.in_fmt.num_channels, self.in_fs, in_nchans=self.in_fmt.num_channels, out_nchans=condition_fmt.num_channels, in_fs=self.in_fs, is_planar=is_planar, ) # run processing Loading
tests/data/test_SBA.yml +1 −0 Original line number Diff line number Diff line Loading @@ -265,6 +265,7 @@ conditions_to_generate: ### For possible arguments see overall bitstream modification type: "JBM" error_profile: 3 sba_format: "PLANARFOA" ################################################ ### Post-processing Loading