Framer

class gpype.backend.flow.framer.Framer[source]

Bases: IONode

Frame aggregation node for combining single samples into frames.

Collects individual samples (frame size = 1) and aggregates them into larger frames of a specified size. Maintains an internal buffer that accumulates samples until a complete frame is assembled, then outputs the entire frame. Useful for converting sample-by-sample streams into frame-based processing.

class Configuration[source]

Bases: Configuration

Configuration class for Framer parameters.

class Keys[source]

Bases: Keys

Configuration key constants for the Framer.

FRAME_SIZE = 'frame_size'

Frame size configuration key

__init__(frame_size=None, **kwargs)[source]

Initialize the Framer node.

Parameters:
  • frame_size (int) – Size of output frames to generate. Must be a positive integer. Defaults to 1 if None.

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

Raises:

ValueError – If frame_size is not an integer or is less than 1.

setup(data, port_context_in)[source]

Set up the Framer node and allocate the internal buffer.

Validates input port configuration and initializes the internal buffer based on output frame size and channel count. Input must have frame_size = 1 for proper single-sample aggregation.

Parameters:
  • data (dict[str, ndarray]) – Initial data dictionary for port configuration.

  • port_context_in (dict[str, dict]) – Input port context with frame size and channel count specifications.

Return type:

dict[str, dict]

Returns:

Output port context with updated frame size information.

Raises:

ValueError – If input frame size is not 1.

step(data)[source]

Process one sample and add it to the internal frame buffer.

Takes a single sample from input and stores it in the buffer. When a complete frame has been assembled (every frame_size samples), outputs the complete frame.

Parameters:

data (dict[str, ndarray]) – Input data dictionary containing a single sample with PORT_IN key. Sample should have shape (1, channels).

Return type:

dict[str, ndarray]

Returns:

Output data dictionary with PORT_OUT key containing the complete frame when ready, or None if frame is not complete.