diff --git a/ivas_processing_scripts/audiotools/audioarray.py b/ivas_processing_scripts/audiotools/audioarray.py index 3e7d4c13b4fcd4ac56a13e0ec215171d0dc939dc..62c30d19bab694aa83b05972eaa91185e9b724a9 100755 --- a/ivas_processing_scripts/audiotools/audioarray.py +++ b/ivas_processing_scripts/audiotools/audioarray.py @@ -522,9 +522,7 @@ def lpfilter( N, Wn = sig.cheb2ord(fc / (fs / 2), (fc + 500) / (fs / 2), 3, 60) b, a = sig.cheby2(N, 60, Wn, "low") - # Apply the Butterworth filter for each channels, across time axis - # y = sig.lfilter(b, a, axis=0) # non zero-phase filter - y = sig.filtfilt(b, a, x, axis=0) # zero-phase filer, batch processing + y = sig.filtfilt(b, a, x, axis=0) # zero-phase filter, batch processing else: y = x diff --git a/ivas_processing_scripts/audiotools/convert/__init__.py b/ivas_processing_scripts/audiotools/convert/__init__.py index d7d612af5d403858b4b53dabf2a494cb92eb8852..953742d39eb0e300af54b9a79f482804a5f47572 100755 --- a/ivas_processing_scripts/audiotools/convert/__init__.py +++ b/ivas_processing_scripts/audiotools/convert/__init__.py @@ -35,9 +35,11 @@ from copy import copy from pathlib import Path, PurePath from shutil import copyfile from typing import Optional, Union +from warnings import warn from ivas_processing_scripts.audiotools import audio, audioarray, metadata from ivas_processing_scripts.audiotools.audiofile import write +from ivas_processing_scripts.audiotools.audioarray import lpfilter from ivas_processing_scripts.audiotools.convert.channelbased import convert_channelbased from ivas_processing_scripts.audiotools.convert.masa import convert_masa from ivas_processing_scripts.audiotools.convert.objectbased import convert_objectbased @@ -335,11 +337,17 @@ def process_audio( """low-pass filtering""" if fc is not None: - if logger: - logger.debug( - f"Applying low-pass filter with cutoff {fc} Hz using ITU STL filter" - ) - x.audio = lpfilter_itu(x, fc) + try: + if logger: + logger.debug( + f"Applying low-pass filter with cutoff {fc}Hz using ITU STL filter" + ) + x.audio = lpfilter_itu(x, fc) + except NotImplementedError: + warn(f"Low-pass filter cutoff {fc}Hz not supported by ITU filter. Falling back to python implementation.") + if logger: + logger.debug(f" Applying low-pass filter with cutoff {fc}Hz using python") + x.audio = lpfilter(x.audio, fc, x.fs) """MNRU""" if mnru_q is not None: diff --git a/ivas_processing_scripts/audiotools/wrappers/filter.py b/ivas_processing_scripts/audiotools/wrappers/filter.py index 3f6ce956d9c5625079eac2183c3fc38219e343f3..5d79fc001733542d90626e6bd3cc5f25127351c5 100755 --- a/ivas_processing_scripts/audiotools/wrappers/filter.py +++ b/ivas_processing_scripts/audiotools/wrappers/filter.py @@ -231,8 +231,8 @@ def lpfilter_itu( flt_vals = [1500, 3500, 7000, 10000, 12000, 14000, 20000] try: flt_type = flt_types[flt_vals.index(fc)] - except Exception: - raise ValueError(f"LP cut-off frequency {fc}Hz not supported.") + except ValueError as e: + raise NotImplementedError(f"LP cut-off frequency {fc}Hz not supported by ITU filter.") from e # resample if samplingrate is not supported old_fs = None