Commit 41a6e390 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

add option for linear gain factor in audiotools and processing scripts

parent 4b5defdf
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ input:
### Pre-processing step performed prior to core processing for all conditions
### If not defined, preprocessing step is skipped
# preprocessing:
    ### Linear gain factor to be applied before any other processing
    # gain: 3.1622776602
    ### Target format used in rendering from input format; default = null (no rendering)
    # fmt: "7_1_4"
    ### Define mask (HP50 or 20KBP) for input signal filtering; default = null
@@ -319,6 +321,8 @@ postprocessing:
    fmt: "BINAURAL"
    ### REQUIRED: Target sampling rate in Hz for resampling
    fs: 48000
    ### Linear gain factor to be applied before any other processing
    # gain: 0.316227766
    ### Low-pass cut-off frequency in Hz; default = null (no filtering)
    # lp_cutoff: 24000
    ### Target loudness in LKFS; default = null (no loudness change applied)
+7 −0
Original line number Diff line number Diff line
@@ -114,6 +114,13 @@ def add_processing_args(group, input=True):
        help="Delay the signal by this amount in milliseconds (negative values advance, default = %(default)s)",
        default=None,
    )
    group.add_argument(
        f"-{ps}g",
        f"--{p}_gain",
        type=float,
        help="Apply the given linear gain factor to the signal, applied before other processing steps (default = %(default)s)",
        default=None,
    )
    group.add_argument(
        f"-{ps}l",
        f"--{p}_loudness",
+11 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ def convert(
    in_cutoff: Optional[int] = None,
    in_mask: Optional[str] = None,
    in_window: Optional[list] = None,
    in_gain: Optional[float] = None,
    in_loudness: Optional[float] = None,
    in_loudness_fmt: Optional[str] = None,
    out_trim: Optional[list] = None,
@@ -199,6 +200,7 @@ def convert(
    out_cutoff: Optional[int] = None,
    out_mask: Optional[str] = None,
    out_window: Optional[list] = None,
    out_gain: Optional[float] = None,
    out_loudness: Optional[float] = None,
    out_loudness_fmt: Optional[str] = None,
    limit: Optional[bool] = False,
@@ -221,6 +223,7 @@ def convert(
        fc=in_cutoff,
        mask=in_mask,
        window=in_window,
        gain=in_gain,
        loudness=in_loudness,
        loudness_fmt=in_loudness_fmt,
        spatial_distortion_amplitude=spatial_distortion_amplitude,
@@ -241,6 +244,7 @@ def convert(
        fc=out_cutoff,
        mask=out_mask,
        window=out_window,
        gain=out_gain,
        loudness=out_loudness,
        loudness_fmt=out_loudness_fmt,
        limit=limit,
@@ -259,6 +263,7 @@ def process_audio(
    fc: Optional[int] = None,
    mask: Optional[str] = None,
    window: Optional[float] = None,
    gain: Optional[float] = None,
    loudness: Optional[float] = None,
    loudness_fmt: Optional[str] = None,
    limit: Optional[bool] = False,
@@ -273,6 +278,12 @@ def process_audio(
    if fs is None:
        fs = x.fs

    """gain"""
    if gain is not None:
        if logger:
            logger.debug(f"Applying linear gain factor of {gain}")
        x.audio *= gain

    """delay audio"""
    if delay is not None:
        if isinstance(x, audio.ObjectBasedAudio):
+15 −15
Original line number Diff line number Diff line

Necessary additional executables:

| Processing step                                 | Executable            | Where to find                                                                                               |
| ------------------------------------------------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------- |
| Loudness measurement and adjustment                                                         | bs1770demo            | <https://github.com/ErikNorvell-Ericsson/STL> (Note branch)                                                     |
| MNRU                                                                                        | p50fbmnru             | <https://github.com/openitu/STL>                                                                                |
| ESDRU                                                                                       | esdru                 | <https://github.com/openitu/STL>                                                                                |
| Frame error pattern application                                                             | eid-xor               | <https://github.com/openitu/STL>                                                                                |
| Reverberation module                                                                        | reverb                | <https://github.com/openitu/STL>                                                                                |
| Error pattern generation                                                                    | gen-patt              | <https://www.itu.int/rec/T-REC-G.191-201003-S/en> (Note: Version in <https://github.com/openitu/STL> is buggy!) |
| Filtering, Resampling                                                                       | filter                | <https://www.3gpp.org/ftp/tsg_sa/WG4_CODEC/TSGS4_76/docs/S4-131277.zip>                                         |
| Random offset/seed generation (necessary for background noise and FER bitstream processing) | random                | <https://www.3gpp.org/ftp/tsg_sa/WG4_CODEC/TSGS4_76/docs/S4-131277.zip>                                         |
| JBM network simulator                                                                       | networkSimulator_g192 | <https://www.3gpp.org/ftp/tsg_sa/WG4_CODEC/TSGS4_76/docs/S4-131277.zip>                                         |
| MASA analyzer (used for SBA to MASA conversion)                                             | masaRenderer          | <https://www.3gpp.org/ftp/TSG_SA/WG4_CODEC/TSGS4_122_Athens/Docs/S4-230221.zip>                                 |
| MASA rendering (also used in loudness measurement of MASA items)                            | masaAnalyzer          | <https://www.3gpp.org/ftp/TSG_SA/WG4_CODEC/TSGS4_122_Athens/Docs/S4-230221.zip>                                 |
| EVS reference conditions                                                                    | EVS_cod, EVS_dec      | <https://www.3gpp.org/ftp/Specs/archive/26_series/26.443/26443-h00.zip>                                         |
| EVS JBM conditions                                                                          | dlyerr_2_errpat       | <http://ftp.3gpp.org/tsg_sa/WG4_CODEC/TSGS4_70/Docs/S4-121077.zip>                                              |
|-------------------------------------------------|-----------------------|-------------------------------------------------------------------------------------------------------------|
| Loudness measurement and adjustment             | bs1770demo            | https://github.com/ErikNorvell-Ericsson/STL (Note branch)                                                   |
| MNRU                                            | p50fbmnru             | https://github.com/openitu/STL                                                                              |
| ESDRU                                           | esdru                 | https://github.com/openitu/STL                                                                              |
| Frame error pattern application                 | eid-xor               | https://github.com/openitu/STL                                                                              |
| Reverberation module                            | reverb                | https://github.com/openitu/STL                                                                              |
| Error pattern generation                        | gen-patt              | https://www.itu.int/rec/T-REC-G.191-201003-S/en (Note: Version in https://github.com/openitu/STL is buggy!) |
| Filtering, Resampling                           | filter                | https://www.3gpp.org/ftp/tsg_sa/WG4_CODEC/TSGS4_76/docs/S4-131277.zip                                       |
| Random offset/seed generation (necessary for background noise and FER bitstream processing)   | random                | https://www.3gpp.org/ftp/tsg_sa/WG4_CODEC/TSGS4_76/docs/S4-131277.zip                                       |
| JBM network simulator                           | networkSimulator_g192 | https://www.3gpp.org/ftp/tsg_sa/WG4_CODEC/TSGS4_76/docs/S4-131277.zip                                       |
| MASA rendering (also used in loudness measurement of MASA items)        | masaRenderer        | https://www.3gpp.org/ftp/TSG_SA/WG4_CODEC/TSGS4_122_Athens/Docs/S4-230221.zip                               |
| EVS reference conditions        | EVS_cod, EVS_dec      | https://www.3gpp.org/ftp/Specs/archive/26_series/26.443/26443-h00.zip                                       |
| EVS JBM conditions | dlyerr_2_errpat | http://ftp.3gpp.org/tsg_sa/WG4_CODEC/TSGS4_70/Docs/S4-121077.zip |
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ def get_preprocessing(cfg: TestConfig) -> dict:
                "in_pad_noise": pre_cfg.get("pad_noise", False),
                "in_delay": pre_cfg.get("delay"),
                "in_window": pre_cfg.get("window"),
                "in_gain": pre_cfg.get("gain"),
                "in_loudness": pre_cfg.get("loudness"),
                "in_loudness_fmt": pre_cfg.get("loudness_fmt", post_fmt),
                "in_mask": pre_cfg.get("mask", None),
@@ -568,6 +569,7 @@ def get_processing_chain(
                "out_fs": post_cfg.get("fs"),
                "out_fmt": post_fmt,
                "out_cutoff": tmp_lp_cutoff,
                "in_gain": post_cfg.get("gain"), # should be in_gain here since we want to apply it before any conversion/rendering
                "bin_dataset": post_cfg.get("bin_dataset"),
                "bin_lfe_gain": post_cfg.get("bin_lfe_gain"),
                "limit": post_cfg.get("limit", True),
Loading