Skip to content

File wfm_sink.h

FileList > inc > wfm > wfm_sink.h

Go to the source code of this file

ZMQ PUB sink for generated IQ (Phase B). More...

  • #include "clib_common.h"

Public Types

Type Name
typedef struct wfm_zmq_sink wfm_zmq_sink_t

Public Functions

Type Name
int wfm_zmq_sink_available (void)
1 if the real ZMQ sink (libdoppler_stream) is linked, else 0 (the pure-C core links only the weak no-op stubs). wfmgen checks this before the --output zmq:// path.
double wfm_zmq_sink_clip_fraction (const wfm_zmq_sink_t * sink)
void wfm_zmq_sink_close (wfm_zmq_sink_t * sink)
Close the sink and destroy the publisher.
wfm_zmq_sink_t * wfm_zmq_sink_open (const char * endpoint, int sample_type)
Open a ZMQ PUB sink.
double wfm_zmq_sink_peak (const wfm_zmq_sink_t * sink)
int wfm_zmq_sink_send (wfm_zmq_sink_t * sink, const float _Complex * iq, size_t n, double fs, double fc)
Convert a cf32 block to the wire type and publish it.
void wfm_zmq_sink_set_gain (wfm_zmq_sink_t * sink, double gain)
void wfm_zmq_sink_track_clipping (wfm_zmq_sink_t * sink, int on)

Detailed Description

Streams cf32 blocks (from synth or the composer) to a ZMQ PUB endpoint using doppler's dp_pub_* wire layer (SIGS header, magic "SIGS"), converting to the requested wire sample type per block. This is the --output zmq://… destination; a dp_sub_* receiver (e.g. examples/c/spectrum_analyzer) reads the stream.

Lifecycle: wfm_zmq_sink_open -> wfm_zmq_sink_send* -> wfm_zmq_sink_close

wfm_zmq_sink_t *s = wfm_zmq_sink_open("tcp://0.0.0.0:5555", 3); // ci16
wfm_zmq_sink_send(s, iq, 4096, 1e6, 2.4e9);
wfm_zmq_sink_close(s);

Public Types Documentation

typedef wfm_zmq_sink_t

typedef struct wfm_zmq_sink wfm_zmq_sink_t;

Opaque ZMQ sink.


Public Functions Documentation

function wfm_zmq_sink_available

1 if the real ZMQ sink (libdoppler_stream) is linked, else 0 (the pure-C core links only the weak no-op stubs). wfmgen checks this before the --output zmq:// path.

int wfm_zmq_sink_available (
    void
) 


function wfm_zmq_sink_clip_fraction

double wfm_zmq_sink_clip_fraction (
    const wfm_zmq_sink_t * sink
) 

Fraction (0..1) of integer I/Q components that saturated; 0 unless tracked. The generated ZmqSink handle binds peak/clip_fraction directly as per-field getters (jm#320), so no stats-snapshot struct shim is needed.


function wfm_zmq_sink_close

Close the sink and destroy the publisher.

void wfm_zmq_sink_close (
    wfm_zmq_sink_t * sink
) 

Parameters:

  • sink May be NULL.

function wfm_zmq_sink_open

Open a ZMQ PUB sink.

wfm_zmq_sink_t * wfm_zmq_sink_open (
    const char * endpoint,
    int sample_type
) 

Parameters:

  • endpoint ZMQ bind endpoint, e.g. "tcp://0.0.0.0:5555".
  • sample_type Wire type (wavegen order): 0 cf32, 1 cf64, 2 ci32, 3 ci16, 4 ci8. Integer types use full-scale ±1.0.

Returns:

Sink handle, or NULL on bad type / publisher-create failure.

Note:

Caller must wfm_zmq_sink_close() when done.


function wfm_zmq_sink_peak

double wfm_zmq_sink_peak (
    const wfm_zmq_sink_t * sink
) 

Largest per-axis magnitude seen on an integer path (pre-clip, full-scale 1).

1.0 ⇒ clipped; peak_dBFS = 20*log10(peak).


function wfm_zmq_sink_send

Convert a cf32 block to the wire type and publish it.

int wfm_zmq_sink_send (
    wfm_zmq_sink_t * sink,
    const float _Complex * iq,
    size_t n,
    double fs,
    double fc
) 

Parameters:

  • sink the sink handle.
  • iq Complex-float samples;
  • n complex sample count.
  • fs sample rate (Hz);
  • fc center frequency (Hz) — wire header.

Returns:

0 on success, non-zero on a send/allocation error.


function wfm_zmq_sink_set_gain

void wfm_zmq_sink_set_gain (
    wfm_zmq_sink_t * sink,
    double gain
) 

Set the output gain (linear; default 1.0). For headroom H dB pass 10^(−H/20). gain 1.0 sends cf32 unscaled (the direct path).


function wfm_zmq_sink_track_clipping

void wfm_zmq_sink_track_clipping (
    wfm_zmq_sink_t * sink,
    int on
) 

Enable the per-component clip counter (off by default; peak always on).



The documentation for this class was generated from the following file native/inc/wfm/wfm_sink.h