DFT¶
Class for performing the Discrete Fourier Transform (DFT) and inverse DFT for real signals, including multichannel. It is also possible to specific an analysis or synthesis window.
When available, it is possible to use the pyfftw
or mkl_fft
packages.
Otherwise the default is to use numpy.fft.rfft
/numpy.fft.irfft
.
More on pyfftw
can be read here:
https://pyfftw.readthedocs.io/en/latest/index.html
More on mkl_fft
can be read here:
https://github.com/IntelPython/mkl_fft
- class pyroomacoustics.transform.dft.DFT(nfft, D=1, analysis_window=None, synthesis_window=None, transform='numpy', axis=0, precision='double', bits=None)¶
Bases:
object
Class for performing the Discrete Fourier Transform (DFT) of real signals.
- X¶
Real DFT computed by
analysis
.- Type:
numpy array
- x¶
IDFT computed by
synthesis
.- Type:
numpy array
- nfft¶
FFT size.
- Type:
int
- D¶
Number of channels.
- Type:
int
- transform¶
Which FFT package will be used.
- Type:
str
- analysis_window¶
Window to be applied before DFT.
- Type:
numpy array
- synthesis_window¶
Window to be applied after inverse DFT.
- Type:
numpy array
- axis¶
Axis over which to compute the FFT.
- Type:
int
- precision, bits
How many precision bits to use for the input. Twice the amount will be used for complex spectrum.
- Type:
string, np.float32, np.float64, np.complex64, np.complex128
- Parameters:
nfft (int) – FFT size.
D (int, optional) – Number of channels. Default is 1.
analysis_window (numpy array, optional) – Window to be applied before DFT. Default is no window.
synthesis_window (numpy array, optional) – Window to be applied after inverse DFT. Default is no window.
transform (str, optional) – which FFT package to use:
numpy
,pyfftw
, ormkl
. Default isnumpy
.axis (int, optional) – Axis over which to compute the FFT. Default is first axis.
precision (string, np.float32, np.float64, np.complex64, np.complex128, optional) – How many precision bits to use for the input. If ‘single’/np.float32/np.complex64, 32 bits for real inputs or 64 for complex spectrum. Otherwise, cast to 64 bits for real inputs or 128 for complex spectrum (default).
- analysis(x)¶
Perform frequency analysis of a real input using DFT.
- Parameters:
x (numpy array) – Real signal in time domain.
- Returns:
DFT of input.
- Return type:
numpy array
- synthesis(X=None)¶
Perform time synthesis of frequency domain to real signal using the inverse DFT.
- Parameters:
X (numpy array, optional) – Complex signal in frequency domain. Default is to use DFT computed from
analysis
.- Returns:
IDFT of
self.X
or input if given.- Return type:
numpy array