FFT

class gpype.backend.transform.fft.FFT[source]

Bases: IONode

Fast Fourier Transform node for frequency domain analysis.

Performs windowed FFT on input data with configurable window size, overlap, and window functions. Uses rolling buffer for continuous processing and proper amplitude scaling for spectral analysis.

class Configuration[source]

Bases: Configuration

Configuration class for FFT parameters.

class Keys[source]

Bases: Keys

Configuration key constants for the FFT.

WINDOW_SIZE = 'window_size'

Window size configuration key

WINDOW_FUNCTION = 'window_function'

Window function configuration key

OVERLAP = 'overlap'

Overlap configuration key

__init__(window_size=None, window_function=None, overlap=None, **kwargs)[source]

Initialize FFT transform node.

Parameters:
  • window_size (int) – Size of the FFT window in samples. Must be > 1.

  • window_function (str, optional) – Name of the window function to apply. Defaults to ‘boxcar’ (rectangular window).

  • overlap (float, optional) – Overlap ratio between consecutive windows, ranging from 0.0 to 1.0. Defaults to 0.5.

  • **kwargs – Additional configuration parameters passed to IONode.

Raises:
  • ValueError – If window_size is None, not an integer, or <= 1.

  • ValueError – If overlap is not a float or outside [0, 1] range.

setup(data, port_context_in)[source]

Set up the FFT node and initialize windowing components.

Parameters:
  • data (dict) – Initial data dictionary for port configuration.

  • port_context_in (dict) – Input port context information.

Returns:

Output port context with updated frame size for FFT output.

Return type:

dict

Raises:

ValueError – If input frame size is not 1.

step(data)[source]

Process one frame of data and compute FFT when ready.

Parameters:

data (dict) – Dictionary containing input data arrays with shape (1, channel_count) for each frame.

Returns:

Dictionary containing FFT amplitude spectrum when

decimation step is reached, None otherwise. Output shape is (frequency_bins, channel_count) where frequency_bins is (window_size // 2 + 1).

Return type:

dict or None