aspcore.fouriertransform.dft

Methods for discrete Fourier transform

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. 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.

References

Functions

angular_freqs_to_wavenum(angular_freqs, c)

Converts an array of angular frequencies to wave numbers

dft_mat(dft_len)

DFT matrix corresponding to the real DFT.

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

freqs_to_angular_freqs(freqs)

Converts an array of frequencies to angular frequencies

freqs_to_wavenum(freqs, c)

Converts an array of frequencies to wave numbers

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_real_angular_freqs(num_freq, samplerate)

Returns angular frequencies associated with the real frequencies of the DFT

get_real_freqs(num_freq, samplerate)

Returns the real sampled frequencies in Hz for a discrete Fourier transform

get_real_wavenum(num_freq, samplerate, c)

Get wave numbers associated with the real frequencies of the DFT

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.

irdft_mat(dft_len[, num_freqs_removed_low])

DFT matrix corresponding to the inverse real DFT.

irfft(freq_signal[, n, num_freqs_removed_low])

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

rdft_mat(dft_len[, num_freqs_removed_low])

DFT matrix corresponding to the real DFT.

rdft_weighting(num_freqs, dft_len, ...)

The weighting required for the real DFT to be the same as the complex DFT.

rfft(time_sig[, n, num_freqs_removed_low])

Computes the real FFT