Commit 18c5ab8c authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'fix_format_and_linter_complaints' into 'main'

Fix format and linter complaints

See merge request !5
parents e49676ee bdbfb3ee
Loading
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -67,11 +67,13 @@ format:
  script:
    - mkdir $ARTIFACT_FOLDER

    - isort --profile black . || ret_val_isort=$?
    - black . || ret_val_black=$?
    - git diff > "${ARTIFACT_FOLDER}/${ARTIFACT_BASE_NAME}.patch"
    - isort --profile black .
    - black .

    - if [[ $ret_val_isort != 0 || $ret_val_black != 0 ]]; then exit 1; fi
    - patch_file="${ARTIFACT_FOLDER}/${ARTIFACT_BASE_NAME}.patch"
    - git diff > $patch_file

    - if [ -s $patch_file ]; then exit 1; fi
  artifacts:
    paths:
      - "$ARTIFACT_FOLDER"
+6 −6
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ logger = logging.getLogger("__main__")
logger.setLevel(logging.DEBUG)


### Functions used in this module
# Functions used in this module
def trim(
    x: np.ndarray,
    fs: Optional[int] = 48000,
@@ -183,13 +183,13 @@ def delay_compensation(
    """

    # Get the delay in number of samples
    if flt_type == "SHQ2" and up == True:
    if flt_type == "SHQ2" and up:
        d_samples = DELAY_COMPENSATION_FOR_FILTERING["SHQ2"]["up"]
    elif flt_type == "SHQ2" and down == True:
    elif flt_type == "SHQ2" and down:
        d_samples = DELAY_COMPENSATION_FOR_FILTERING["SHQ2"]["down"]
    elif flt_type == "SHQ3" and up == True:
    elif flt_type == "SHQ3" and up:
        d_samples = DELAY_COMPENSATION_FOR_FILTERING["SHQ3"]["up"]
    elif flt_type == "SHQ3" and down == True:
    elif flt_type == "SHQ3" and down:
        d_samples = DELAY_COMPENSATION_FOR_FILTERING["SHQ3"]["down"]
    else:
        d_samples = DELAY_COMPENSATION_FOR_FILTERING[flt_type]
@@ -405,7 +405,7 @@ def framewise_io(
    )


### Deprecated functions (partly replaced by ITU binaries)
# Deprecated functions (partly replaced by ITU binaries)
def resample(
    x: np.ndarray,
    in_freq: int,
+12 −5
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

import logging
import warnings
from pathlib import Path
from typing import Optional, Tuple, Union
@@ -142,15 +141,23 @@ def load_ir(
            if in_fmt == "SBA1" or in_fmt == "FOA":
                dataset_suffix = "SBA1"
                # Use truncated SBA3 dataset if no SBA1 or 2 dataset exists
                if not (Path(__file__).parent.joinpath(f"{dataset_prefix}_{dataset}_{dataset_suffix}.mat")).is_file():
                if not (
                    Path(__file__).parent.joinpath(
                        f"{dataset_prefix}_{dataset}_{dataset_suffix}.mat"
                    )
                ).is_file():
                    dataset_suffix = "SBA3"
                    warnings.warn(f"No SBA1 dataset found -> use truncated SBA3 dataset")
                    warnings.warn("No SBA1 dataset found -> use truncated SBA3 dataset")
            elif in_fmt.endswith("2"):
                dataset_suffix = "SBA2"
                # Use truncated SBA3 dataset if no SBA1 or 2 dataset exists
                if not (Path(__file__).parent.joinpath(f"{dataset_prefix}_{dataset}_{dataset_suffix}.mat")).is_file():
                if not (
                    Path(__file__).parent.joinpath(
                        f"{dataset_prefix}_{dataset}_{dataset_suffix}.mat"
                    )
                ).is_file():
                    dataset_suffix = "SBA3"
                    warnings.warn(f"No SBA2 dataset found -> use truncated SBA3 dataset")
                    warnings.warn("No SBA2 dataset found -> use truncated SBA3 dataset")
            else:
                dataset_suffix = "SBA3"

+8 −6
Original line number Diff line number Diff line
@@ -41,12 +41,12 @@ from ivas_processing_scripts.audiotools.convert.masa import convert_masa
from ivas_processing_scripts.audiotools.convert.objectbased import convert_objectbased
from ivas_processing_scripts.audiotools.convert.scenebased import convert_scenebased
from ivas_processing_scripts.audiotools.wrappers.bs1770 import loudness_norm
from ivas_processing_scripts.audiotools.wrappers.esdru import esdru
from ivas_processing_scripts.audiotools.wrappers.filter import (
    hp50filter_itu,
    lpfilter_itu,
    resample_itu,
)
from ivas_processing_scripts.audiotools.wrappers.esdru import esdru
from ivas_processing_scripts.audiotools.wrappers.p50fbmnru import p50fbmnru

from ..metadata import write_ISM_metadata_in_file
@@ -258,13 +258,13 @@ def process_audio(
    """MNRU"""
    if mnru_q is not None:
        if logger:
            logger.debug(f"Applying P.50 Fullband MNRU")
            logger.debug("Applying P.50 Fullband MNRU")
        x.audio = p50fbmnru(x, mnru_q)

    """ESDRU"""
    if esdru_alpha is not None:
        if logger:
            logger.debug(f"Applying ESDRU Recommendation ITU-T P.811")
            logger.debug("Applying ESDRU Recommendation ITU-T P.811")
        x.audio = esdru(x, esdru_alpha)

    """limiting"""
@@ -284,17 +284,19 @@ def format_conversion(

    # validation
    if isinstance(output, audio.MetadataAssistedSpatialAudio):
        raise NotImplementedError(f"MASA is not supported as an output for rendering!")
        raise NotImplementedError("MASA is not supported as an output for rendering!")

    if isinstance(output, audio.ObjectBasedAudio) and input.name != output.name:
        raise NotImplementedError(
            f"ISM is not supported as an output for rendering! Only usable as pass-through"
            "ISM is not supported as an output for rendering! Only usable as pass-through"
        )

    if logger:
        logger.debug(f"Format conversion: {input.name} -> {output.name}")

    if input.name == output.name or (input.name.startswith("BINAURAL") and output.name.startswith("BINAURAL")):
    if input.name == output.name or (
        input.name.startswith("BINAURAL") and output.name.startswith("BINAURAL")
    ):
        output.audio = input.audio
    else:
        if isinstance(input, audio.BinauralAudio):
+0 −2
Original line number Diff line number Diff line
@@ -208,7 +208,6 @@ def render_cba_to_binaural(
def render_cba_to_cba(
    cba_in: audio.ChannelBasedAudio, cba_out: audio.ChannelBasedAudio
) -> None:

    # Stereo to Mono
    if cba_in.name == "STEREO" and cba_out.name == "MONO":
        render_mtx = np.vstack([[0.5], [0.5]])
@@ -244,7 +243,6 @@ def render_cba_to_cba(


def render_cba_to_sba(cba: audio.ChannelBasedAudio, sba: audio.SceneBasedAudio) -> None:

    if cba.name == "MONO":
        raise ValueError(f"Rendering from MONO to {sba.name} is not supported.")

Loading