|
6 | 6 | from torch import Tensor |
7 | 7 |
|
8 | 8 | from torchaudio._extension import _IS_TORCHAUDIO_EXT_AVAILABLE |
| 9 | +from torchaudio._internal.module_utils import dropping_support |
9 | 10 |
|
10 | 11 |
|
11 | 12 | def _dB2Linear(x: float) -> float: |
@@ -324,7 +325,7 @@ def biquad(waveform: Tensor, b0: float, b1: float, b2: float, a0: float, a1: flo |
324 | 325 | a1 = torch.as_tensor(a1, dtype=dtype, device=device).view(1) |
325 | 326 | a2 = torch.as_tensor(a2, dtype=dtype, device=device).view(1) |
326 | 327 |
|
327 | | - output_waveform = lfilter( |
| 328 | + output_waveform = _lfilter_deprecated( |
328 | 329 | waveform, |
329 | 330 | torch.cat([a0, a1, a2]), |
330 | 331 | torch.cat([b0, b1, b2]), |
@@ -698,8 +699,8 @@ def filtfilt( |
698 | 699 | Tensor: Waveform with dimension of either `(..., num_filters, time)` if ``a_coeffs`` and ``b_coeffs`` |
699 | 700 | are 2D Tensors, or `(..., time)` otherwise. |
700 | 701 | """ |
701 | | - forward_filtered = lfilter(waveform, a_coeffs, b_coeffs, clamp=False, batching=True) |
702 | | - backward_filtered = lfilter( |
| 702 | + forward_filtered = _lfilter_deprecated(waveform, a_coeffs, b_coeffs, clamp=False, batching=True) |
| 703 | + backward_filtered = _lfilter_deprecated( |
703 | 704 | forward_filtered.flip(-1), |
704 | 705 | a_coeffs, |
705 | 706 | b_coeffs, |
@@ -997,7 +998,7 @@ def _lfilter_core( |
997 | 998 | _lfilter = _lfilter_core |
998 | 999 |
|
999 | 1000 |
|
1000 | | -def lfilter(waveform: Tensor, a_coeffs: Tensor, b_coeffs: Tensor, clamp: bool = True, batching: bool = True) -> Tensor: |
| 1001 | +def _lfilter_deprecated(waveform: Tensor, a_coeffs: Tensor, b_coeffs: Tensor, clamp: bool = True, batching: bool = True) -> Tensor: |
1001 | 1002 | r"""Perform an IIR filter by evaluating difference equation, using differentiable implementation |
1002 | 1003 | developed separately by *Yu et al.* :cite:`ismir_YuF23` and *Forgione et al.* :cite:`forgione2021dynonet`. |
1003 | 1004 | The gradients of ``a_coeffs`` are computed based on a faster algorithm from :cite:`ycy2024diffapf`. |
@@ -1066,6 +1067,7 @@ def lfilter(waveform: Tensor, a_coeffs: Tensor, b_coeffs: Tensor, clamp: bool = |
1066 | 1067 |
|
1067 | 1068 | return output |
1068 | 1069 |
|
| 1070 | +lfilter = dropping_support(_lfilter_deprecated) |
1069 | 1071 |
|
1070 | 1072 | def lowpass_biquad(waveform: Tensor, sample_rate: int, cutoff_freq: float, Q: float = 0.707) -> Tensor: |
1071 | 1073 | r"""Design biquad lowpass filter and perform filtering. Similar to SoX implementation. |
@@ -1115,7 +1117,7 @@ def _overdrive_core_loop_generic( |
1115 | 1117 | _overdrive_core_loop_cpu = _overdrive_core_loop_generic |
1116 | 1118 |
|
1117 | 1119 |
|
1118 | | -def overdrive(waveform: Tensor, gain: float = 20, colour: float = 20) -> Tensor: |
| 1120 | +def _overdrive_deprecated(waveform: Tensor, gain: float = 20, colour: float = 20) -> Tensor: |
1119 | 1121 | r"""Apply a overdrive effect to the audio. Similar to SoX implementation. |
1120 | 1122 |
|
1121 | 1123 | .. devices:: CPU CUDA |
@@ -1170,6 +1172,7 @@ def overdrive(waveform: Tensor, gain: float = 20, colour: float = 20) -> Tensor: |
1170 | 1172 |
|
1171 | 1173 | return output_waveform.clamp(min=-1, max=1).view(actual_shape) |
1172 | 1174 |
|
| 1175 | +overdrive = dropping_support(_overdrive_deprecated) |
1173 | 1176 |
|
1174 | 1177 | def phaser( |
1175 | 1178 | waveform: Tensor, |
|
0 commit comments