aspcore.fouriertransform
Methods for discrete Fourier transform, and linear convolution and correlation in the frequency domain
The forward transforms will operate on the last axis, and put the resulting frequency axis first. The inverse transforms will operate on the first axis and put the resulting time axis last. A time domain sample can be accessed as time_signal[…,n] A frequency domain sample can be accessed as freq_signal[f,…]
The motivation is that the methods are build for multichannel audio processing, where the assumption is that only 1-D FFTs are needed. The most common use case is that time domain processing operates directly on the last axis, and frequency domain processing operates on the channel axes, but broadcasts over the frequency axis. This behaviour for the transforms results in much fewer transpositions, and makes the code more readable.
Important
Note the time convention, which is not the same as in the numpy.fft module. This is to achieve consistency with the acoustics literature that is used for the sound field analysis modules. The definition of the DFT is u(k) = sum_{n=0}^{N-1} u[n] e^{i 2pi k n / N}, for frequency bins k = 0, 1, …, N-1, and the definition of the Inverse DFT is u[n] = rac{1}{N} sum_{k=0}^{N-1} u(k) e^{-i 2pi k n / N}.
It can be viewed as a direct consequence of choosing the definition of a plane wave propagating in the d direction to be u(r) = e^{i k r^T d}, where k is the wavenumber.
The following methods can be helpful for filtering using frequency-domain filters when multiple channels are involved. When possible, for correlation and convolution the functions will zero-pad the signals correctly in order to avoid circular convolution.
In particular, the functions can be useful frequency domain adaptive filters, where overlap-save is used for both linear convolutions and correlations. It can be tricky there to get the zero-padding right.
References
Functions
|
Convolves every channel of input with every channel of the filter |
|
Convolves every channel of input with every channel of the filter |
|
Performs linear convolution between a time-domain signal and a frequency-domain filter |
|
Computes the linear correlation between two time-domain signals |
|
Correlates every channel of input with every channel of the filter |
|
Correlates every channel of input with every channel of the filter |
|
Correlates every channel of input with every channel of the filter |
|
Computes linear correlation between two frequency-domain signals |
|
Computes linear correlation between a time-domain signal and a frequency-domain filter |
|
Computes linear correlation between a frequency-domain signal and a time-domain filter |
|
Computes linear correlation between two time-domain signals |
|
All exponential values to calculate the DFT for a specific frequency bin |
|
Computes the FFT |
|
Returns the angular frequencies associated with the sampled frequencies of the DFT |
|
Returns the sampled frequencies in Hz for a discrete Fourier transform |
|
Returns angular frequencies associated with the real frequencies of the DFT |
|
Returns the real sampled frequencies in Hz for a discrete Fourier transform |
|
Get wave numbers associated with the real frequencies of the DFT |
|
Returns the wave numbers associated with the sampled frequencies of the DFT |
|
All exponential values to calculate the IDFT for a specific output time step |
|
Computes the inverse FFT |
|
Inserts the values associated with negative frequencies. |
|
Inverse FFT, and moves the first axis to the last axis |
|
Computes the real FFT |