Stft#

class ansys.sound.core.spectrogram_processing.Stft(signal=None, fft_size=2048, window_type='HANN', window_overlap=0.5)#

Compute the short-time Fourier transform (STFT) of a signal.

See also

Istft, PowerSpectralDensity

Examples

Compute the STFT of a signal, and display the resulting spectrogram in a colormap.

>>> from ansys.sound.core.spectrogram_processing import Stft
>>> stft = Stft(signal=signal)
>>> stft.process()
>>> spectrogram = stft.get_output()
>>> stft.plot()

See also

Spectrogram: compute the STFT and ISTFT

Example demonstrating how to compute the STFT and ISTFT.

Class instantiation takes the following parameters.

Parameters:
signalField, default: None

Input signal on which to compute the STFT.

fft_sizeint, default: 2048

Size of the FFT to compute the STFT. Use a power of 2 for better performance.

window_typestr, default: ‘HANN’

Window type used for the FFT computation. Options are 'TRIANGULAR', 'BLACKMAN', 'BLACKMANHARRIS', 'HAMMING', 'HANN', 'GAUSS', 'FLATTOP', 'RECTANGULAR', and 'BARTLETT'.

window_overlapfloat, default: 0.5

Overlap value between two successive FFT computations. Values can range from 0 to 1. For example, 0 means no overlap, and 0.5 means 50% overlap.

Methods

Stft.get_frequencies()

Get the frequency scale of the STFT magnitude and phase.

Stft.get_magnitude()

Get the magnitude of the STFT.

Stft.get_output()

Get the STFT of the signal as a DPF fields container.

Stft.get_output_as_nparray()

Get the STFT of the signal as a tuple of NumPy arrays.

Stft.get_phase()

Get the phase of the STFT.

Stft.get_time_scale()

Get the time scale of the STFT.

Stft.plot()

Plot the STFT.

Stft.plot_custom([display_phase, ...])

Plot the STFT with custom display settings.

Stft.process()

Compute the STFT.

Attributes

Stft.fft_size

Number of FFT points.

Stft.signal

Input signal as a DPF field.

Stft.window_overlap

Window overlap in %.

Stft.window_type

Window type.