aspcore.filter

A collection of classes implementing linear convolution.

The functionality offered beyond what is available in numpy and scipy is inherent support for MIMO filters in different forms, as well as streaming filtering, where only a part of the signal is known at a time. It is also possible to filter with a time-varying impulse response.

The classes are JIT compiled using numba’s experimental jitclass to keep computational cost low.

The main function of the module is create_filter, which constructs the appropriate filter object according to the chosen parameters. The only required parameters is either an impulse response or the dimensions of the impulse response. In the latter case, the impulse response is initialized to zero.

In addition to linear convolution, the module also contains implementations of - Weighted overlap-add (WOLA) [crochiereWeighted1980, ruizComparison2021] - IIR filter - Mean with forgetting factor

References

[crochiereWeighted1980] R. Crochiere, “A weighted overlap-add method of short-time Fourier analysis/synthesis,” IEEE Transactions on Acoustics, Speech, and Signal Processing, vol. 28, no. 1, pp. 99–102, Feb. 1980, doi: 10.1109/TASSP.1980.1163353. [link]

[ruizComparison2021] S. Ruiz, T. Dietzen, T. van Waterschoot, and M. Moonen, “A comparison between overlap-save and weighted overlap-add filter banks for multi-channel Wiener filter based noise reduction,” in 2021 29th European Signal Processing Conference (EUSIPCO), Aug. 2021, pp. 336–340. doi: 10.23919/EUSIPCO54536.2021.9616352. [link]

Functions

create_filter([ir, num_in, num_out, ir_len, ...])

Returns the appropriate filter object for the desired use.

get_window_wola(block_size, overlap)

block_size is number of samples overlap is number of samples

wola_analysis(sig, window)

Generate WOLA spectrum from time domain signal

wola_synthesis(spectrum, sig_last_block, ...)

Generate time domain signal from WOLA spectrum

Classes

FilterBroadcastFreq(data_dims[, tf, ir, ...])

ir is the time domain impulse response, with shape (a0, a1,..., an, irLen) tf is frequency domain transfer function, with shape (2*irLen, a0, a1,..., an),

FilterMD_slow_fallback(data_dims[, ir, ...])

Equivalent to FilterBroadcast, but can handle arbitrary number of dimensions.

FilterNosum([ir, ir_len, num_in, num_out])

Filters a signal with a MIMO filter without summing over the input dimension.

FilterSumFreq([tf, ir, num_in, num_out, ...])

ir is the time domain impulse response, with shape (numIn, numOut, irLen) tf is frequency domain transfer function, with shape (2*irLen, numOut, numIn), it is also possible to only provide the dimensions of the filter, numIn and numOut, together with either number of frequencies or ir length, where 2*irLen==numFreq dataDims is extra dimensions of the data to broadcast over. Input should then be with shape (*dataDims, numIn, numSamples), output will be (*dataDims, numOut, numSamples).

IIRFilter(num_coeffs, denom_coeffs)

num_coeffs and denom_coeffs should be a list of ndarrays,

MovingAverage(forget_factor, dim[, dtype])

WOLA(num_in, num_out, block_size, overlap)