- class flamo.auxiliary.filterbank.FilterBank(fraction: int = 3, order: int = 5, fmin: float = 20.0, fmax: float = 18000.0, sample_rate: int = 48000, nfft: int = None, backend: str = 'scipy')
Generates a filterbank and filters tensors.
This is gpu compatible if using torch backend, but it might be slow. The octave filterbanks is created using cascade Buttwerworth filters, which then are processed using the biquad function native to PyTorch.
This class is useful, e.g., to get the decay curves of RIRs.
- Arguments:
fraction (int): Fraction of octave bands (1 or 3).
order (int): Order of the Butterworth filter.
fmin (int): Minimum frequency.
fmax (int): Maximum frequency.
sample_rate (int): Sampling rate.
nfft (int, optional): Number of FFT points.
backend (str): Backend to use (‘scipy’ or ‘torch’).
Adapted from DecayFitNet original implementation by @georg-goetz https://github.com/georg-goetz/DecayFitNet
- forward(x)
Forward pass of the filter bank.
- Returns:
x (torch.Tensor): Input tensor.
- Returns:
torch.Tensor: Filtered tensor.
- get_center_frequencies()
Gets the center frequencies.
- Returns:
list: List of center frequencies.
- get_filterbank_impulse_response()
Returns the impulse response of the filterbank.
- Returns:
torch.Tensor: Impulse response of the filterbank.
- set_center_frequencies(center_freqs)
Sets the center frequencies and updates the filters.
- Arguments:
center_freqs (list): List of new center frequencies.
- set_order(order)
Sets the filter order and updates the filters.
- Arguments:
order (int): New filter order.
- set_sample_rate(sample_rate)
Sets the sample rate and updates the filters.
- Arguments:
sample_rate (int): New sample rate.