Generator

class gpype.backend.sources.generator.Generator[source]

Bases: FixedRateSource

Signal generator for creating synthetic test signals.

Generates configurable test signals with optional noise for testing pipelines. Supports multiple waveforms (sine, rectangular, pulse) with multi-channel output; every channel carries the same signal.

SHAPE_SINUSOID = 'sine'

Sinusoidal waveform signal shape

SHAPE_RECTANGULAR = 'rect'

Square wave signal shape

SHAPE_PULSE = 'pulse'

Brief pulses signal shape

SIGNAL_SHAPES = ('sine', 'rect', 'pulse')

Every shape this node can produce. Named, and named with the parameter it constrains, because the set had no representation at all before: the shapes existed as three separate constants and the only thing that knew which were valid was an if/elif chain in step(). A form offering a dropdown, or a generated catalog, has nowhere else to read this from.

DEFAULT_SAMPLING_RATE = 250.0

Default sampling rate in Hz

DEFAULT_CHANNEL_COUNT = 8

Default number of channels

DEFAULT_SIGNAL_FREQUENCY = 10.0

Default signal frequency in Hz

DEFAULT_SIGNAL_SHAPE = 'sine'

Default signal shape

DEFAULT_SIGNAL_AMPLITUDE = 0.0

Default signal amplitude

DEFAULT_NOISE_AMPLITUDE = 0.0

Default noise amplitude

class Configuration[source]

Bases: Configuration

Configuration class for Generator signal parameters.

class Keys[source]

Bases: Keys

Configuration key constants for the Generator.

SIGNAL_FREQUENCY = 'signal_frequency'

Signal frequency configuration key

SIGNAL_SHAPE = 'signal_shape'

Signal shape configuration key

SIGNAL_AMPLITUDE = 'signal_amplitude'

Signal amplitude configuration key

NOISE_AMPLITUDE = 'noise_amplitude'

Noise amplitude configuration key

__init__(sampling_rate=None, channel_count=None, frame_size=None, signal_frequency=None, signal_shape=None, signal_amplitude=0.0, noise_amplitude=0.0, edge_id=None, **kwargs)[source]

Initialize the signal generator.

Parameters:
  • sampling_rate (float) – Sampling frequency in Hz.

  • channel_count (int) – Number of output channels. All get same signals.

  • frame_size (int) – Samples per output frame.

  • signal_frequency (float) – Signal frequency in Hz. Defaults to 10.0.

  • signal_shape (str) – Waveform shape (sine, rect, pulse). Defaults to sine.

  • signal_amplitude (float) – Peak amplitude of signal component.

  • noise_amplitude (float) – Standard deviation of Gaussian noise.

  • edge_id (Optional[str]) – Which edge runs this node, matched against the edge process’s –edge-id. None, the default, is every edge; ignored when the pipeline is not distributed.

  • **kwargs – Additional parameters for FixedRateSource.

Raises:

ValueError – If signal_frequency or noise_amplitude is negative, or signal_shape is unsupported.

NUM_TIMELINE_CHANNELS = 1

One channel beyond the configured count, carrying the instant each frame was produced.

A generator numbers nothing, so Sync numbers it by counting arrivals – and under distributed residency that Sync runs in the server process, counting arrivals off a socket. Pairing those positions with a locally read clock fits the master timeline to the transport rather than to the signal. The stamp is what makes the two residencies the same measurement.

setup(data, port_context_in)[source]

Declare the generated channels and the timestamp beside them.

Parameters:
  • data (dict[str, ndarray]) – Input data arrays (empty for source nodes).

  • port_context_in (dict[str, dict]) – Input port contexts (empty for source nodes).

Return type:

dict[str, dict]

Returns:

Output port contexts, describing one timestamp channel after the signal channels.

step(data)[source]

Generate one frame of synthetic signal data.

Creates a frame containing the configured waveform plus optional noise. Maintains phase continuity across frames through time tracking.

Parameters:

data (dict[str, ndarray]) – Input data dictionary (unused for signal generation).

Return type:

dict[str, ndarray]

Returns:

Output data dictionary with generated signal frame of shape (frame_size, channel_count), or None if not a decimation step.