Commit f355f68b authored by Anika Treffehn's avatar Anika Treffehn
Browse files

formatting

parent 6b9e70c7
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -120,7 +120,9 @@ def load_ir(
    if out_fmt.startswith("BINAURAL") and "ROOM" in out_fmt:

        if "_IR" in out_fmt or "_REVERB" in out_fmt:
            warn("For reference rendering _IR and _REVERB extensions of BINAURAL_ROOM are ignored")
            warn(
                "For reference rendering _IR and _REVERB extensions of BINAURAL_ROOM are ignored"
            )

        dataset_prefix = "BRIR"
        if dataset is None:
+7 −2
Original line number Diff line number Diff line
@@ -294,10 +294,15 @@ def process_audio(
        x.audio = esdru(x, esdru_alpha)

    """Spatial distortion"""
    if spatial_distortion_frequency is not None and spatial_distortion_amplitude is not None:
    if (
        spatial_distortion_frequency is not None
        and spatial_distortion_amplitude is not None
    ):
        if logger:
            logger.debug("Applying spatial distortion")
        x.audio = spatial_distortion(x, spatial_distortion_amplitude, spatial_distortion_frequency)
        x.audio = spatial_distortion(
            x, spatial_distortion_amplitude, spatial_distortion_frequency
        )

    """loudness normalization"""
    if loudness is not None:
+30 −11
Original line number Diff line number Diff line
@@ -30,17 +30,19 @@
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

import os.path
from pathlib import Path
from typing import Optional, Union
from warnings import warn

from ivas_processing_scripts.audiotools.wrappers.networkSimulator import LIST_JBM_PROFILES, ERROR_PATTERNS_DIR
from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES
from ivas_processing_scripts.utils import find_binary, run
from ivas_processing_scripts.audiotools.wrappers.eid_xor import eid_xor
from ivas_processing_scripts.audiotools.wrappers.networkSimulator import (
    ERROR_PATTERNS_DIR,
    LIST_JBM_PROFILES,
    length_pattern,
)
from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed
from ivas_processing_scripts.audiotools.wrappers.networkSimulator import length_pattern
from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES
from ivas_processing_scripts.utils import find_binary, run


def dlyerr_2_errpat(
@@ -87,7 +89,9 @@ def dlyerr_2_errpat(
    if "dlyerr_2_errpat" in DEFAULT_CONFIG_BINARIES["binary_paths"]:
        binary = find_binary(
            DEFAULT_CONFIG_BINARIES["binary_paths"]["dlyerr_2_errpat"].name,
            binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["dlyerr_2_errpat"].parent,
            binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"][
                "dlyerr_2_errpat"
            ].parent,
        )
    else:
        binary = find_binary("dlyerr_2_errpat")
@@ -98,7 +102,9 @@ def dlyerr_2_errpat(
            f"Delay and error pattern file {dlyerr_pattern} for bitstream processing does not exist"
        )
    if delay is not None and late_loss_rate is not None:
        raise ValueError("Can't scpecify delay and late loss rate for dlyerr_2_err tool but only one of them")
        raise ValueError(
            "Can't scpecify delay and late loss rate for dlyerr_2_err tool but only one of them"
        )

    # set up command line
    cmd = [
@@ -132,7 +138,17 @@ def dlyerr_2_errpat(
    return


def evs_jbm(bitstream, bitstream_processed, error_profile, error_pattern, errpatt_late_loss_rate, errpatt_delay, errpatt_seed, errpatt_frames_packet, master_seed):
def evs_jbm(
    bitstream,
    bitstream_processed,
    error_profile,
    error_pattern,
    errpatt_late_loss_rate,
    errpatt_delay,
    errpatt_seed,
    errpatt_frames_packet,
    master_seed,
):

    # convert delay and error profile
    delay = None
@@ -257,9 +273,13 @@ def validate_evs_jbm(
                "JBM pattern and JBM profile number are specified for bitstream processing. Can't use both! Please check the configuration."
            )
        if errpatt_late_loss_rate is not None and errpatt_delay is not None:
            raise ValueError("For EVS JBM conditions with error pattern only late loss rate OR delay has to be specified, not both!")
            raise ValueError(
                "For EVS JBM conditions with error pattern only late loss rate OR delay has to be specified, not both!"
            )
        if errpatt_late_loss_rate is None and errpatt_delay is None:
            raise ValueError("For EVS JBM conditions with error pattern either late loss rate or delay has to be specified!")
            raise ValueError(
                "For EVS JBM conditions with error pattern either late loss rate or delay has to be specified!"
            )
        if errpatt_seed is None:
            warn("No seed was specified for EVS JBM offset -> Use 0")
    elif error_profile is not None:
@@ -272,4 +292,3 @@ def validate_evs_jbm(
            f"n_frames_per_paket is {n_frames_per_packet}. Should be 1 or 2. Please check your configuration."
        )
    return
+1 −1
Original line number Diff line number Diff line
@@ -30,10 +30,10 @@
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

from copy import deepcopy
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Optional
from copy import deepcopy

import numpy as np

+2 −4
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ from pathlib import Path
from typing import Optional, Union
from warnings import warn

from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed
from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES
from ivas_processing_scripts.utils import find_binary, run
from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed

LIST_JBM_PROFILES = range(11)
ERROR_PATTERNS_DIR = Path(__file__).parent.parent.parent.joinpath("dly_error_profiles")
@@ -84,8 +84,6 @@ def validate_network_simulator(
            raise ValueError(
                "JBM pattern and JBM profile number are specified for bitstream processing. Can't use both! Please check the configuration."
            )
        if errpatt_seed is None:
            raise warn("No error pattern seed specified for JBM offset -> use 0")
    elif error_profile is not None:
        if error_profile not in LIST_JBM_PROFILES:
            raise ValueError(
@@ -238,7 +236,7 @@ def apply_network_simulator(


def length_pattern(path_pattern):
    with open(path_pattern, 'r') as f:
    with open(path_pattern, "r") as f:
        p = f.readlines()
        length = len(p)
    return length
Loading