mlx.core.fft.stft#
- stft(x: array, n_fft: int = 2048, hop_length: int | None = None, win_length: int | None = None, window: array | None = None, center: bool = True, pad_mode: str = 'reflect', norm: str = 'backward', onesided: bool | None = None, stream: Stream | ThreadLocalStream | Device | mlx.core.DeviceType | None = None) array#
Short-Time Fourier Transform.
Splits the last axis of
xinto overlapping frames of lengthn_fft, applieswindow, and takes the Fourier Transform of each frame. The output is always complex with shape(..., n_freq, n_frames).- Parameters:
x (array) – The input array.
n_fft (int, optional) – Size of the Fourier Transform. Default is
2048.hop_length (int, optional) – Samples between frames. Default is
n_fft // 4.win_length (int, optional) – Window size. Default is
n_fft.window (array, optional) – A one-dimensional window, centered and zero-padded to
n_fft. Default is a rectangular window.center (bool, optional) – Pad both ends so frames are centered. Default is
True.pad_mode (str, optional) – One of
"reflect","constant", or"edge", used whencenterisTrue. Default is"reflect".norm (str, optional) – One of
"backward","ortho", or"forward". Default is"backward".onesided (bool, optional) – Return only non-negative frequencies. Default is
Truefor real input andFalsefor complex input.
- Returns:
The STFT of
x.- Return type: