aspcore.fouriertransform_jax.dft_jax

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

dft_vector(freq_idx, dft_len)

All exponential values to calculate the DFT for a specific frequency bin

fft(time_sig[, n])

Computes the FFT

get_angular_freqs(num_freq, samplerate)

Returns the angular frequencies associated with the sampled frequencies of the DFT

get_freqs(num_freq, samplerate)

Returns the sampled frequencies in Hz for a discrete Fourier transform

get_wavenum(num_freq, samplerate, c)

Returns the wave numbers associated with the sampled frequencies of the DFT

idft_vector(freq_idx, dft_len)

All exponential values to calculate the IDFT for a specific output time step

ifft(freq_signal)

Computes the inverse FFT

insert_negative_frequencies(freq_signal, even)

Inserts the values associated with negative frequencies.

irfft(freq_signal[, n])

Inverse FFT, and moves the first axis to the last axis

rfft(time_sig[, n])

Computes the real FFT

Classes

partial

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.