libSDRForge
Loading...
Searching...
No Matches
spectrum_publisher.SpectrumPublisher Class Reference

Convert incoming IQ blocks to FFT frames at a bounded output rate. More...

Public Member Functions

None __init__ (self, *, int fft_size=2048, float max_fps=15.0)
 Initialize the instance.
SpectrumFrame|None latest_frame (self)
 Read a shared snapshot without consuming any subscriber queue.
SpectrumSubscription subscribe (self, *, int max_frames=3)
 Subscribe the component.
None unsubscribe (self, SpectrumSubscription subscription)
 Unsubscribe the component.
None reset (self)
 Allow immediate publication after retuning or stream restart.
SpectrumFrame|None publish_iq (self, np.ndarray iq, *, int center_frequency_hz, int sample_rate_hz, int timestamp_ns)
 Publish a frame if its timestamp passes the frame-rate gate.

Public Attributes

 fft_size = fft_size

Protected Attributes

 _period_ns = max(1, int(1_000_000_000 / max_fps))
 _lock = RLock()
int|None _last_timestamp_ns = None
SpectrumFrame|None _latest_frame = None
set[SpectrumSubscription] _subscribers = set()

Detailed Description

Convert incoming IQ blocks to FFT frames at a bounded output rate.

Timestamps are monotonic nanoseconds supplied by the caller. The IQ producer owns sampling and hardware; this publisher owns no device.

Constructor & Destructor Documentation

◆ __init__()

None spectrum_publisher.SpectrumPublisher.__init__ ( self,
* ,
int fft_size = 2048,
float max_fps = 15.0 )

Initialize the instance.

Parameters
selfThe current instance.
fft_sizeThe fft_size value.
max_fpsThe max_fps value.

Member Function Documentation

◆ latest_frame()

SpectrumFrame | None spectrum_publisher.SpectrumPublisher.latest_frame ( self)

Read a shared snapshot without consuming any subscriber queue.

Parameters
selfThe current instance.
Returns
The operation result.

◆ publish_iq()

SpectrumFrame | None spectrum_publisher.SpectrumPublisher.publish_iq ( self,
np.ndarray iq,
* ,
int center_frequency_hz,
int sample_rate_hz,
int timestamp_ns )

Publish a frame if its timestamp passes the frame-rate gate.

Returns None when throttled. No callback executes on the IQ thread.

Parameters
selfThe current instance.
iqThe complex IQ samples to process.
center_frequency_hzThe center_frequency_hz value.
sample_rate_hzThe sample rate in hertz.
timestamp_nsThe timestamp_ns value.
Returns
The operation result.

◆ reset()

None spectrum_publisher.SpectrumPublisher.reset ( self)

Allow immediate publication after retuning or stream restart.

Parameters
selfThe current instance.

◆ subscribe()

SpectrumSubscription spectrum_publisher.SpectrumPublisher.subscribe ( self,
* ,
int max_frames = 3 )

Subscribe the component.

Parameters
selfThe current instance.
max_framesThe max_frames value.
Returns
The operation result.

◆ unsubscribe()

None spectrum_publisher.SpectrumPublisher.unsubscribe ( self,
SpectrumSubscription subscription )

Unsubscribe the component.

Parameters
selfThe current instance.
subscriptionThe subscription value.

Member Data Documentation

◆ _last_timestamp_ns

int | None spectrum_publisher.SpectrumPublisher._last_timestamp_ns = None
protected

◆ _latest_frame

SpectrumFrame | None spectrum_publisher.SpectrumPublisher._latest_frame = None
protected

◆ _lock

spectrum_publisher.SpectrumPublisher._lock = RLock()
protected

◆ _period_ns

spectrum_publisher.SpectrumPublisher._period_ns = max(1, int(1_000_000_000 / max_fps))
protected

◆ _subscribers

set[SpectrumSubscription] spectrum_publisher.SpectrumPublisher._subscribers = set()
protected

◆ fft_size

spectrum_publisher.SpectrumPublisher.fft_size = fft_size

The documentation for this class was generated from the following file: