LabVIEW Advanced Signal Processing Toolkit API Reference

TFA STFT VI

  • Updated2023-02-21
  • 13 minute(s) read

TFA STFT VI

Owning Palette: Time Frequency Transform VIs

Requires: Advanced Signal Processing Toolkit

Computes the short-time Fourier transform (STFT) of signal. Wire data to the signal input to determine the polymorphic instance to use or manually select the instance.

Details  

TFA STFT (Waveform)

extension specifies the method to use to pad data at the borders of the input signal to lessen discontinuity. The extension length is half the window length.

0Zero padding (default)—Uses zeros to pad the input data. Watch for abrupt transitions between the padded zeros and the input data, which causes large artifacts near the transition.
1Symmetric—Uses replications of the input data to pad the data, except that this VI left-flips the block at the input and right-flips the block at the end.
2Periodic—Adds a replication of the input data block before and another replication after the input data block to pad the data.
signal specifies the input signal.
time-frequency sampling info specifies the density to use to sample the signal in the time-frequency domain and defines the size of the resulting 2D time-frequency array.
time steps specifies the sampling period, in samples, along the time axis in the joint time-frequency domain. The default is –1, which specifies that this VI adjusts time steps automatically so that no more than 512 rows exist in spectrogram. The number of rows in spectrogram equals the signal length divided by time steps.

National Instruments recommends that you set time steps such that the number of rows in spectrogram does not exceed 512. If you specify a small value for time steps, this VI might return a large spectrogram, which requires a long computation time and more memory.

If you need a small sampling period to observe more details and the signal length is large, divide the signal into smaller segments and compute spectrogram for each segment. If the signal is oversampled, you also can downsample the signal. The scale info output contains the actual sampling period, in seconds, along the time axis of the spectrogram.
frequency bins is the FFT block size of the STFT. frequency bins must be a power of 2 and greater than 0. The scale info output contains the actual sampling period in hertz along the frequency axis. You also can consider frequency bins as the number of bins along the frequency axis to sample the signal in the joint time-frequency domain.
window info specifies the sliding window to use to compute the STFT and defines the resolution of the resulting time-frequency representation. Use the user defined window input to specify a customized window.
type specifies the type of the sliding window.
length specifies the length, in samples, of the sliding window. The default is –1, which indicates that this VI sets the window length to four times time steps. Thus, the overlap between sliding windows is 75 percent. However, this VI wraps the default window length to 64 when time steps is less than 16. length controls the relationship between the time resolution and the frequency resolution of the time-frequency representation. A large window length provides better frequency resolution but poorer time resolution.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
user defined window specifies the coefficients of the sliding window to use to compute the STFT. If you specify a value for user defined window, this VI ignores the settings in the window info input. Use window info to specify a commonly used sliding window, such as the hanning window or the hamming window.
STFT coef returns the linear time-frequency representation of the signal. Use the TFA Coefficients Indicator to display the magnitude of STFT coef on an intensity graph. You can save the time-dependent 2D array to a text file for use in another software environment. The resulting text file contains only Z values and does not retain the time axis information or the frequency axis information. You can use the TFA Get Time and Freq Scale Info VI to compute the time scale information and the frequency scale information of the time-frequency representation.
scale info returns the time scale and the frequency scale information of the time-frequency representation, including the time offset, the time interval between every two contiguous rows, the frequency offset, and the frequency interval between every two contiguous columns of STFT coef. Use the TFA Get Time and Freq Scale Info VI to return detailed information about the time scale and the frequency scale.
error out contains error information. This output provides standard error out functionality.

TFA STFT (Real)

extension specifies the method to use to pad data at the borders of the input signal to lessen discontinuity. The extension length is half the window length.

0Zero padding (default)—Uses zeros to pad the input data. Watch for abrupt transitions between the padded zeros and the input data, which causes large artifacts near the transition.
1Symmetric—Uses replications of the input data to pad the data, except that this VI left-flips the block at the input and right-flips the block at the end.
2Periodic—Adds a replication of the input data block before and another replication after the input data block to pad the data.
signal specifies the input signal.
time-frequency sampling info specifies the density to use to sample the signal in the time-frequency domain and defines the size of the resulting 2D time-frequency array.
time steps specifies the sampling period, in samples, along the time axis in the joint time-frequency domain. The default is –1, which specifies that this VI adjusts time steps automatically so that no more than 512 rows exist in spectrogram. The number of rows in spectrogram equals the signal length divided by time steps.

National Instruments recommends that you set time steps such that the number of rows in spectrogram does not exceed 512. If you specify a small value for time steps, this VI might return a large spectrogram, which requires a long computation time and more memory.

If you need a small sampling period to observe more details and the signal length is large, divide the signal into smaller segments and compute spectrogram for each segment. If the signal is oversampled, you also can downsample the signal. The scale info output contains the actual sampling period, in seconds, along the time axis of the spectrogram.
frequency bins is the FFT block size of the STFT. frequency bins must be a power of 2 and greater than 0. The scale info output contains the actual sampling period in hertz along the frequency axis. You also can consider frequency bins as the number of bins along the frequency axis to sample the signal in the joint time-frequency domain.
window info specifies the sliding window to use to compute the STFT and defines the resolution of the resulting time-frequency representation. Use the user defined window input to specify a customized window.
type specifies the type of the sliding window.
length specifies the length, in samples, of the sliding window. The default is –1, which indicates that this VI sets the window length to four times time steps. Thus, the overlap between sliding windows is 75 percent. However, this VI wraps the default window length to 64 when time steps is less than 16. length controls the relationship between the time resolution and the frequency resolution of the time-frequency representation. A large window length provides better frequency resolution but poorer time resolution.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
user defined window specifies the coefficients of the sliding window to use to compute the STFT. If you specify a value for user defined window, this VI ignores the settings in the window info input. Use window info to specify a commonly used sliding window, such as the hanning window or the hamming window.
sampling rate specifies the sampling rate of signal in hertz. sampling rate must be greater than 0, or this VI sets sampling rate to 1 automatically. The default is 1.
STFT coef returns the linear time-frequency representation of the signal. Use the TFA Coefficients Indicator to display the magnitude of STFT coef on an intensity graph. You can save the time-dependent 2D array to a text file for use in another software environment. The resulting text file contains only Z values and does not retain the time axis information or the frequency axis information. You can use the TFA Get Time and Freq Scale Info VI to compute the time scale information and the frequency scale information of the time-frequency representation.
scale info returns the time scale and the frequency scale information of the time-frequency representation, including the time offset, the time interval between every two contiguous rows, the frequency offset, and the frequency interval between every two contiguous columns of STFT coef. Use the TFA Get Time and Freq Scale Info VI to return detailed information about the time scale and the frequency scale.
error out contains error information. This output provides standard error out functionality.

TFA STFT (Complex)

extension specifies the method to use to pad data at the borders of the input signal to lessen discontinuity. The extension length is half the window length.

0Zero padding (default)—Uses zeros to pad the input data. Watch for abrupt transitions between the padded zeros and the input data, which causes large artifacts near the transition.
1Symmetric—Uses replications of the input data to pad the data, except that this VI left-flips the block at the input and right-flips the block at the end.
2Periodic—Adds a replication of the input data block before and another replication after the input data block to pad the data.
signal specifies the input signal.
time-frequency sampling info specifies the density to use to sample the signal in the time-frequency domain and defines the size of the resulting 2D time-frequency array.
time steps specifies the sampling period, in samples, along the time axis in the joint time-frequency domain. The default is –1, which specifies that this VI adjusts time steps automatically so that no more than 512 rows exist in spectrogram. The number of rows in spectrogram equals the signal length divided by time steps.

National Instruments recommends that you set time steps such that the number of rows in spectrogram does not exceed 512. If you specify a small value for time steps, this VI might return a large spectrogram, which requires a long computation time and more memory.

If you need a small sampling period to observe more details and the signal length is large, divide the signal into smaller segments and compute spectrogram for each segment. If the signal is oversampled, you also can downsample the signal. The scale info output contains the actual sampling period, in seconds, along the time axis of the spectrogram.
frequency bins is the FFT block size of the STFT. frequency bins must be a power of 2 and greater than 0. The scale info output contains the actual sampling period in hertz along the frequency axis. You also can consider frequency bins as the number of bins along the frequency axis to sample the signal in the joint time-frequency domain.
window info specifies the sliding window to use to compute the STFT and defines the resolution of the resulting time-frequency representation. Use the user defined window input to specify a customized window.
type specifies the type of the sliding window.
length specifies the length, in samples, of the sliding window. The default is –1, which indicates that this VI sets the window length to four times time steps. Thus, the overlap between sliding windows is 75 percent. However, this VI wraps the default window length to 64 when time steps is less than 16. length controls the relationship between the time resolution and the frequency resolution of the time-frequency representation. A large window length provides better frequency resolution but poorer time resolution.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
user defined window specifies the coefficients of the sliding window to use to compute the STFT. If you specify a value for user defined window, this VI ignores the settings in the window info input. Use window info to specify a commonly used sliding window, such as the hanning window or the hamming window.
sampling rate specifies the sampling rate of signal in hertz. sampling rate must be greater than 0, or this VI sets sampling rate to 1 automatically. The default is 1.
STFT coef returns the linear time-frequency representation of the signal. Use the TFA Coefficients Indicator to display the magnitude of STFT coef on an intensity graph. You can save the time-dependent 2D array to a text file for use in another software environment. The resulting text file contains only Z values and does not retain the time axis information or the frequency axis information. You can use the TFA Get Time and Freq Scale Info VI to compute the time scale information and the frequency scale information of the time-frequency representation.
scale info returns the time scale and the frequency scale information of the time-frequency representation, including the time offset, the time interval between every two contiguous rows, the frequency offset, and the frequency interval between every two contiguous columns of STFT coef. Use the TFA Get Time and Freq Scale Info VI to return detailed information about the time scale and the frequency scale.
error out contains error information. This output provides standard error out functionality.

TFA STFT Details

The short-time Fourier transform (STFT) is the simplest method to use to analyze a time-varying signal or nonstationary signal whose frequency component varies over time. To compute the STFT of an entire signal, this VI uses a sliding window to divide the signal into several blocks and then applies the fast Fourier transform (FFT) to each data block to obtain the frequency contents. You can overlap the sliding window. The following illustration shows the computing procedure of the STFT:

The STFT aligns the center of the first sliding window with the first sample of the signal and extends the signal at the beginning with zeros or the signal itself. L is the window length, and dM is the step size to move the sliding window.

You can use the following equation to compute the STFT:

where s[i] is the signal, is the window function, L is the window length, dM is time step, and N is frequency bins. The window function determines the joint time-frequency resolution of the STFT. The longer the window length, the better the frequency resolution and the worse the time resolution. When dM is greater than or equal to the window length, L, no overlap exists between sliding windows. When dM is smaller than the window length, the overlap in percent equals 100×((L-dM)/L). For example, if you set the window length to 256 and time steps to 64, the overlap is 75%.

Log in to get a better experience