libSDRForge
Loading...
Searching...
No Matches
sdrforge.session.RadioSession Class Reference

Own RF warmup, discontinuity recovery, and one WFM receiver. More...

Public Member Functions

None __init__ (self, *, int frequency_hz, Literal["mono", "stereo"] mode="stereo", bool rds_enabled=False, float|None gain_db=29.7, float rf_warmup_seconds=2.0, SdrSourceIf|None source=None, Callable[[IqBlock], None]|None iq_observer=None)
 Initialize the instance.
RadioSession fm (cls, float frequency_mhz, *, bool stereo=True, bool rds=False, float|None gain_db=None, SdrSourceIf|None source=None, float rf_warmup_seconds=2.0)
 Create an FM session using MHz instead of integer Hz.
RadioSessionStatus status (self)
 Return the status.
str demodulation (self)
 Return the active audio demodulation mode.
int channel_bandwidth_hz (self)
 Return the configured channel bandwidth in hertz.
None start (self)
 Start the component.
None set_demodulation (self, str mode, int bandwidth_hz=0)
 Select the live DSP without reopening the shared SDR source.
None retune (self, int frequency_hz)
 Retune an open source without releasing its USB handle.
bool pan_acquisition (self, int center_hz)
 Move RF acquisition, following with the listener only when necessary.
bool recenter (self)
 Move the acquisition center to the selected listening frequency.
None stop (self)
 Stop the component.
Self __enter__ (self)
 Enter the managed context.
None __exit__ (self, object exc_type, object exc, object tb)
 Exit the managed context.
RadioFrame read (self)
 Decode one block, resetting DSP after gaps while preserving RDS.
Iterator[RadioFrame] stream (self)
 Yield decoded blocks until stopped or acquisition raises.

Public Attributes

 frequency_hz = frequency_hz
 acquisition_frequency_hz = frequency_hz
 gain_db = gain_db
 rf_warmup_seconds = rf_warmup_seconds
 source = source if source is not None else RtlSdrSource()
 iq_observer = iq_observer
int observer_errors = 0
tuple receiver
 performance = DspPerformanceMonitor()

Protected Member Functions

None _reset_receiver (self, *, bool preserve_metadata=False)
bool _channel_fits (self, int frequency_hz, int bandwidth_hz)
None _validate_block (self, object block)
int|None _dropped_blocks (self)

Protected Attributes

 _receiver_mode = mode
str _demodulation = "WFM"
int _channel_bandwidth_hz = 200_000
 _rds_enabled = rds_enabled
bool _started = False
int _blocks = 0
int _samples = 0
int _discontinuities = 0
str|None _last_error = None
int|None _last_timestamp_ns = None
int _last_duration_ns = 0
int|None _last_dropped_blocks = None

Detailed Description

Own RF warmup, discontinuity recovery, and one WFM receiver.

Source injection keeps tests independent of USB and allows future SDR adapters. The caller controls the iteration lifetime.

Constructor & Destructor Documentation

◆ __init__()

None sdrforge.session.RadioSession.__init__ ( self,
* ,
int frequency_hz,
Literal["mono", "stereo"] mode = "stereo",
bool rds_enabled = False,
float | None gain_db = 29.7,
float rf_warmup_seconds = 2.0,
SdrSourceIf | None source = None,
Callable[[IqBlock], None] | None iq_observer = None )

Initialize the instance.

Parameters
selfThe current instance.
frequency_hzThe frequency_hz value.
modeThe mode value.
rds_enabledThe rds_enabled value.
gain_dbThe gain_db value.
rf_warmup_secondsThe rf_warmup_seconds value.
sourceThe source value.
iq_observerThe iq_observer value.

Member Function Documentation

◆ __enter__()

Self sdrforge.session.RadioSession.__enter__ ( self)

Enter the managed context.

Parameters
selfThe current instance.
Returns
The operation result.

◆ __exit__()

None sdrforge.session.RadioSession.__exit__ ( self,
object exc_type,
object exc,
object tb )

Exit the managed context.

Parameters
selfThe current instance.
exc_typeThe exc_type value.
excThe exc value.
tbThe tb value.

◆ _channel_fits()

bool sdrforge.session.RadioSession._channel_fits ( self,
int frequency_hz,
int bandwidth_hz )
protected

◆ _dropped_blocks()

int | None sdrforge.session.RadioSession._dropped_blocks ( self)
protected

◆ _reset_receiver()

None sdrforge.session.RadioSession._reset_receiver ( self,
* ,
bool preserve_metadata = False )
protected

◆ _validate_block()

None sdrforge.session.RadioSession._validate_block ( self,
object block )
protected

◆ channel_bandwidth_hz()

int sdrforge.session.RadioSession.channel_bandwidth_hz ( self)

Return the configured channel bandwidth in hertz.

Parameters
selfThe current instance.
Returns
The operation result.

◆ demodulation()

str sdrforge.session.RadioSession.demodulation ( self)

Return the active audio demodulation mode.

Parameters
selfThe current instance.
Returns
The operation result.

◆ fm()

RadioSession sdrforge.session.RadioSession.fm ( cls,
float frequency_mhz,
* ,
bool stereo = True,
bool rds = False,
float | None gain_db = None,
SdrSourceIf | None source = None,
float rf_warmup_seconds = 2.0 )

Create an FM session using MHz instead of integer Hz.

Capture is asynchronous when supported by the default RTL-SDR adapter. Pass an injected source for hardware-free or alternate-hardware use.

Parameters
clsThe current class.
frequency_mhzThe frequency_mhz value.
stereoThe stereo value.
rdsThe rds value.
gain_dbThe tuner gain in decibels, or None for automatic gain.
sourceThe source value.
rf_warmup_secondsThe rf_warmup_seconds value.
Returns
The operation result.

◆ pan_acquisition()

bool sdrforge.session.RadioSession.pan_acquisition ( self,
int center_hz )

Move RF acquisition, following with the listener only when necessary.

Parameters
selfThe current instance.
center_hzRequested acquisition center in hertz.
Returns
Whether the hardware acquisition center changed.

◆ read()

RadioFrame sdrforge.session.RadioSession.read ( self)

Decode one block, resetting DSP after gaps while preserving RDS.

Parameters
selfThe current instance.
Returns
The operation result.

◆ recenter()

bool sdrforge.session.RadioSession.recenter ( self)

Move the acquisition center to the selected listening frequency.

Parameters
selfThe current instance.
Returns
Whether the hardware acquisition center changed.

◆ retune()

None sdrforge.session.RadioSession.retune ( self,
int frequency_hz )

Retune an open source without releasing its USB handle.

Parameters
selfThe current instance.
frequency_hzThe frequency hz value.

◆ set_demodulation()

None sdrforge.session.RadioSession.set_demodulation ( self,
str mode,
int bandwidth_hz = 0 )

Select the live DSP without reopening the shared SDR source.

Parameters
selfThe current instance.
modeThe mode value.
bandwidth_hzThe bandwidth hz value.

◆ start()

None sdrforge.session.RadioSession.start ( self)

Start the component.

Parameters
selfThe current instance.

◆ status()

RadioSessionStatus sdrforge.session.RadioSession.status ( self)

Return the status.

Parameters
selfThe current instance.
Returns
The operation result.

◆ stop()

None sdrforge.session.RadioSession.stop ( self)

Stop the component.

Parameters
selfThe current instance.

◆ stream()

Iterator[RadioFrame] sdrforge.session.RadioSession.stream ( self)

Yield decoded blocks until stopped or acquisition raises.

Parameters
selfThe current instance.
Returns
The operation result.

Member Data Documentation

◆ _blocks

sdrforge.session.RadioSession._blocks = 0
protected

◆ _channel_bandwidth_hz

sdrforge.session.RadioSession._channel_bandwidth_hz = 200_000
protected

◆ _demodulation

str sdrforge.session.RadioSession._demodulation = "WFM"
protected

◆ _discontinuities

sdrforge.session.RadioSession._discontinuities = 0
protected

◆ _last_dropped_blocks

int | None sdrforge.session.RadioSession._last_dropped_blocks = None
protected

◆ _last_duration_ns

int sdrforge.session.RadioSession._last_duration_ns = 0
protected

◆ _last_error

sdrforge.session.RadioSession._last_error = None
protected

◆ _last_timestamp_ns

int | None sdrforge.session.RadioSession._last_timestamp_ns = None
protected

◆ _rds_enabled

sdrforge.session.RadioSession._rds_enabled = rds_enabled
protected

◆ _receiver_mode

sdrforge.session.RadioSession._receiver_mode = mode
protected

◆ _samples

sdrforge.session.RadioSession._samples = 0
protected

◆ _started

sdrforge.session.RadioSession._started = False
protected

◆ acquisition_frequency_hz

sdrforge.session.RadioSession.acquisition_frequency_hz = frequency_hz

◆ frequency_hz

sdrforge.session.RadioSession.frequency_hz = frequency_hz

◆ gain_db

sdrforge.session.RadioSession.gain_db = gain_db

◆ iq_observer

sdrforge.session.RadioSession.iq_observer = iq_observer

◆ observer_errors

int sdrforge.session.RadioSession.observer_errors = 0

◆ performance

sdrforge.session.RadioSession.performance = DspPerformanceMonitor()

◆ receiver

sdrforge.session.RadioSession.receiver
Initial value:
= (
WbfmReceiver(
channel_frequency_hz=frequency_hz,
mode=mode,
rds_enabled=rds_enabled,
channel_bandwidth_hz=self._channel_bandwidth_hz,
)
)

◆ rf_warmup_seconds

sdrforge.session.RadioSession.rf_warmup_seconds = rf_warmup_seconds

◆ source

sdrforge.session.RadioSession.source = source if source is not None else RtlSdrSource()

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