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.

DEFAULT_FRAME_SIZE = 1

declared so the catalog can read it.

Type:

See FFT

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]

Take every incoming sample and emit whole frames.

Serialises what arrives – one sample or many – into a running frame, and emits it once it is full. A frame that does not divide the input evenly simply carries the remainder into the next one, so no sample is dropped or repeated at the boundary.

Parameters:

data (dict[str, ndarray]) – Input data dictionary with PORT_IN, shape (rows, channels) for any number of rows.

Return type:

dict[str, ndarray]

Returns:

Output data dictionary with PORT_OUT holding the completed frame, or None while the frame is still filling.