SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
SoDa::BaseBandRX Class Reference

#include <BaseBandRX.hxx>

Inheritance diagram for SoDa::BaseBandRX:
SoDa::Thread SoDa::Base SoDa::Debug

Public Member Functions

void subscribeToMailBoxes (const std::vector< MailBoxBasePtr > &mailboxes)
 implement the subscription method
void run ()
 the run method – does the work of the audio receiver process
Public Member Functions inherited from SoDa::Thread
void registerThread (SoDa::ThreadPtr me)
void operator() ()
void start ()
 Execute the thread's run loop.
void join ()
 more properly "Wait for this thread to exit its run loop".
void execCommand (CommandPtr cmd)
 Execute (dispatch) a message removed from the command stream to one of the basic Command handler functions.
virtual void shutDown ()
 optional method that performs cleanup – may not delete.
void sleep_ms (unsigned int milliseconds)
void sleep_us (unsigned int microseconds)
uint32_t getID ()
 Get the process/thread ID for this thread – helps with figuring out who caused a segfault.
Public Member Functions inherited from SoDa::Base
 Base (const std::string &oname)
 The constructor – pass a name for the object.
void registerSelf (BasePtr ptr)
std::string & getObjName ()
 get the name of this object
BasePtr findSoDaObject (const std::string &oname)
 find a SoDa Object by name.
double getTime ()
 Get a time stamp in nS resolution that monotonically increases and that is very inexpensive (typically < 100nS).
BasePtr getSelfPtr ()
 get a pointer to myself.
Public Member Functions inherited from SoDa::Debug
 Debug (std::string _unit_name=std::string("UNKNOWN"))
 Debug (const char *_unit_name_cstr)
 Debug (unsigned int _debug_level, std::string _unit_name=std::string("UNKNOWN"))
 Debug (unsigned int _debug_level, const char *_unit_name_cstr)
void debugMsg (const std::string &msg, unsigned int threshold=1)
void debugMsg (const SoDa::Format &fmt, unsigned int threshold=1)
void debugMsg (const char *msg, unsigned int threshold=1)
void setDebugLevel (unsigned int v)
unsigned int getDebugLevel ()

Static Public Member Functions

static BaseBandRXPtr make (ParamsPtr params, AudioIfcPtr audio_ifc)
 the maker – produces a shared pointer p
Static Public Member Functions inherited from SoDa::Debug
static void setDefaultLevel (unsigned int v)
static unsigned int getDefaultLevel ()
static void setGlobalLevel (unsigned int v)
static unsigned int getGlobalLevel ()

Private Member Functions

 BaseBandRX (ParamsPtr params, AudioIfcPtr audio_ifc)
 the constructor
void reportModes ()
 report all demod modes supported.
void reportAFFilters ()
 report all filters supported.
void execGetCommand (CommandPtr cmd)
 execute GET commands from the command channel
void execSetCommand (CommandPtr cmd)
 handle SET commands from the command channel
void execRepCommand (CommandPtr cmd)
 handle Report commands from the command channel
void demodulateSSB (SoDa::CBufPtr drxbuf, SoDa::Command::ModulationType mod)
 demodulate the input stream as an SSB signal place the resulting audio buffer on the audio output queue.
void demodulateAM (SoDa::CBufPtr drxbuf)
 demodulate the input stream as an amplitude modulated signal place the resulting audio buffer on the audio output queue.
void demodulateNBFM (SoDa::CBufPtr drxbuf, SoDa::Command::ModulationType mod, float af_gain)
 demodulate the input stream as a narrowband frequency modulated signal place the resulting audio buffer on the audio output queue.
void demodulateWBFM (SoDa::CBufPtr rxbuf, SoDa::Command::ModulationType mod, float af_gain)
 demodulate the input stream as a wideband frequency modulated signal place the resulting audio buffer on the audio output queue.
void demodulate (SoDa::CBufPtr rxbuf)
 apply the currently selected demodulation scheme to the input RX buffer place the resulting audio buffer on the audio output queue.
void repAFFilterShape ()
 send a report of the lower and upper edges of the IF passband based on the current filter and modulation type.
void pendAudioBuffer (SoDa::FBufPtr b)
 put an audio buffer on the "pending for output" list
void pendNullBuffer (int count=1)
 put an empty (zero signal) audio buffer on the pending for output list
float * getNextAudioBuffer ()
 return the next queued audio buffer to pass to the audio output device
void flushAudioBuffers ()
 empty the queue of pending audio buffers, we're going into TX mode.
void buildFilterMap ()
 build the audio filter map for selected bandwidths

Private Attributes

unsigned int audio_buffer_size
 size of output audio buffer chunk
unsigned int rf_buffer_size
 size of input RF buffer chunk
double audio_sample_rate
 sample rate of audio output – assumed 48KHz
double rf_sample_rate
 sample rate of RF input from USRP – assumed 625KHz
bool audio_rx_stream_enabled
 if true, send pending audio buffers to output
bool audio_rx_stream_needs_start
 if true, the audio output device needs a wakeup
bool sidetone_stream_enabled
 if true, send CW sidetone to audio output
SoDa::Command::ModulationType rx_modulation
 current receive modulation mode (USB,LSB,CW_U,CW_L,NBFM,WBFM,AM,...)
CDatMBoxPtr rx_stream
 mailbox producing rx sample stream from USRP
CmdMBoxPtr cmd_stream
 mailbox producing command stream from user
CDatMBox::Subscription rx_subs
 mailbox subscription ID for rx data stream
CmdMBox::Subscription cmd_subs
 mailbox subscription ID for command stream
AudioIfcPtr audio_ifc
 pointer to the audio interface (output) object
bool in_catchup
 when true, the audio server has fallen behind...
bool in_fallback
 when true, the audio server has gotten ahead...
unsigned int catchup_rand_mask
 a mask to use for fast selection of a random index into an audio buffer.
SoDa::FBufPtr sidetone_silence
 a sequence of zero samples to stuff silence into the audio
SoDa::ReSamplerPtr rf_resampler
 downsample the RF input to 48KS/s
SoDa::ReSamplerPtr wbfm_resampler
 downsample the RF input to 48KS/s for WBFM unit
SoDa::Command::AudioFilterBW af_filter_selection
 currently audio filter selector
SoDa::OSFilterPtr cur_audio_filter
 currently selected audio filter
SoDa::OSFilterPtr fm_audio_filter
 audio filter for FM (wider passband)
SoDa::OSFilterPtr am_pre_filter
 Before AM demod, we do some (6KHz) prefilter.
SoDa::OSFilterPtr nbfm_pre_filter
 Before NBFM demod, we do some (15KHz) prefilter – rf rate.
SoDa::OSFilterPtr am_audio_filter
 After AM demod, we do a second filter.
std::map< SoDa::Command::AudioFilterBW, SoDa::OSFilterPtr > filter_map
 map filter selectors to the filter objects
SoDa::HilbertTransformerPtr hilbert
 hilbert transform object for SSB/CW widgets
float af_gain
 audio gain setting for RX mode
float af_sidetone_gain
 audio gain setting for TX/CW mode
float * cur_af_gain
 pointer to the gain setting for this mode
float last_phase_samp
 history value used to calculate dPhase/dt in FM atan based discriminator.
MedianFilter3< float > fmMedianFilter
 simple 3 point median filter for FM units
unsigned int dbg_ctr
 debug counter, used to support one-time or infrequent bulletins
std::ofstream dbg_out
bool audio_save_enable
std::ofstream audio_file
std::ofstream audio_file2
float audio_level
float log_audio_buffer_size
float nbfm_squelch_level
 average amplitude must be greater to trigger demod.
int nbfm_squelch_hang_count
 if > 0 then send audio.
int nbfm_squelch_hang_time
 continue FM audio demod for this many frames after threshold drops

Additional Inherited Members

Static Public Attributes inherited from SoDa::Debug
static std::mutex debug_msg_mutex
Protected Member Functions inherited from SoDa::Thread
 Thread (const std::string &oname, const std::string &version=std::string("12.2.0"))
 make the thread object.
Protected Member Functions inherited from SoDa::Debug
std::string curDateTime ()
Protected Attributes inherited from SoDa::Thread
std::weak_ptr< Threadself
 A pointer to ourself.
Protected Attributes inherited from SoDa::Debug
std::string unit_name
 the name of the unit reporting status
unsigned int debug_level
 the debug level (threshold) for messages
Static Protected Attributes inherited from SoDa::Debug
static unsigned int default_debug_level
static unsigned int global_debug_level

Detailed Description

Definition at line 84 of file BaseBandRX.hxx.

Constructor & Destructor Documentation

◆ BaseBandRX()

SoDa::BaseBandRX::BaseBandRX ( ParamsPtr params,
AudioIfcPtr audio_ifc )
private

the constructor

Parameters
paramscommand line parameter object
audio_ifcpointer to the audio output handler

References audio_ifc.

Referenced by make().

Member Function Documentation

◆ buildFilterMap()

void SoDa::BaseBandRX::buildFilterMap ( )
private

build the audio filter map for selected bandwidths

◆ demodulate()

void SoDa::BaseBandRX::demodulate ( SoDa::CBufPtr rxbuf)
private

apply the currently selected demodulation scheme to the input RX buffer place the resulting audio buffer on the audio output queue.

Parameters
rxbufRF input buffer

◆ demodulateAM()

void SoDa::BaseBandRX::demodulateAM ( SoDa::CBufPtr drxbuf)
private

demodulate the input stream as an amplitude modulated signal place the resulting audio buffer on the audio output queue.

Parameters
drxbufdownsampled RF input buffer

◆ demodulateNBFM()

void SoDa::BaseBandRX::demodulateNBFM ( SoDa::CBufPtr drxbuf,
SoDa::Command::ModulationType mod,
float af_gain )
private

demodulate the input stream as a narrowband frequency modulated signal place the resulting audio buffer on the audio output queue.

Parameters
drxbufdownsampled RF input buffer
modmodulation type – NBFM
af_gainfactor to goose the audio output

References af_gain.

◆ demodulateSSB()

void SoDa::BaseBandRX::demodulateSSB ( SoDa::CBufPtr drxbuf,
SoDa::Command::ModulationType mod )
private

demodulate the input stream as an SSB signal place the resulting audio buffer on the audio output queue.

Parameters
drxbufdownsampled RF input buffer
modmodulation type – LSB, USB, CW_U, or CW_R

◆ demodulateWBFM()

void SoDa::BaseBandRX::demodulateWBFM ( SoDa::CBufPtr rxbuf,
SoDa::Command::ModulationType mod,
float af_gain )
private

demodulate the input stream as a wideband frequency modulated signal place the resulting audio buffer on the audio output queue.

Note the wideband FM unit takes the raw RX buffer rather than the downsampled rx buffer.

Parameters
rxbufRF input buffer
modmodulation type – WBFM
af_gainfactor to goose the audio output

References af_gain.

◆ execGetCommand()

void SoDa::BaseBandRX::execGetCommand ( CommandPtr cmd)
privatevirtual

execute GET commands from the command channel

Parameters
cmdthe incoming command

Reimplemented from SoDa::Thread.

◆ execRepCommand()

void SoDa::BaseBandRX::execRepCommand ( CommandPtr cmd)
privatevirtual

handle Report commands from the command channel

Parameters
cmdthe incoming command

Reimplemented from SoDa::Thread.

◆ execSetCommand()

void SoDa::BaseBandRX::execSetCommand ( CommandPtr cmd)
privatevirtual

handle SET commands from the command channel

Parameters
cmdthe incoming command

Reimplemented from SoDa::Thread.

◆ flushAudioBuffers()

void SoDa::BaseBandRX::flushAudioBuffers ( )
private

empty the queue of pending audio buffers, we're going into TX mode.

◆ getNextAudioBuffer()

float * SoDa::BaseBandRX::getNextAudioBuffer ( )
private

return the next queued audio buffer to pass to the audio output device

Returns
a pointer to the next buffer in sequence

◆ make()

BaseBandRXPtr SoDa::BaseBandRX::make ( ParamsPtr params,
AudioIfcPtr audio_ifc )
inlinestatic

the maker – produces a shared pointer p

Parameters
paramscommand line parameter object
audio_ifcpointer to the audio output handler

Definition at line 103 of file BaseBandRX.hxx.

References BaseBandRX(), and audio_ifc.

◆ pendAudioBuffer()

void SoDa::BaseBandRX::pendAudioBuffer ( SoDa::FBufPtr b)
private

put an audio buffer on the "pending for output" list

Parameters
bpointer to an audio buffer

◆ pendNullBuffer()

void SoDa::BaseBandRX::pendNullBuffer ( int count = 1)
private

put an empty (zero signal) audio buffer on the pending for output list

Parameters
countnumber of buffers to pend onto the list.

◆ repAFFilterShape()

void SoDa::BaseBandRX::repAFFilterShape ( )
private

send a report of the lower and upper edges of the IF passband based on the current filter and modulation type.

◆ reportAFFilters()

void SoDa::BaseBandRX::reportAFFilters ( )
private

report all filters supported.

◆ reportModes()

void SoDa::BaseBandRX::reportModes ( )
private

report all demod modes supported.

◆ run()

void SoDa::BaseBandRX::run ( )
virtual

the run method – does the work of the audio receiver process

Reimplemented from SoDa::Thread.

◆ subscribeToMailBoxes()

void SoDa::BaseBandRX::subscribeToMailBoxes ( const std::vector< MailBoxBasePtr > & mailboxes)
virtual

implement the subscription method

Implements SoDa::Thread.

Member Data Documentation

◆ af_filter_selection

SoDa::Command::AudioFilterBW SoDa::BaseBandRX::af_filter_selection
private

currently audio filter selector

Definition at line 271 of file BaseBandRX.hxx.

◆ af_gain

float SoDa::BaseBandRX::af_gain
private

audio gain setting for RX mode

Definition at line 284 of file BaseBandRX.hxx.

Referenced by demodulateNBFM(), and demodulateWBFM().

◆ af_sidetone_gain

float SoDa::BaseBandRX::af_sidetone_gain
private

audio gain setting for TX/CW mode

Definition at line 285 of file BaseBandRX.hxx.

◆ am_audio_filter

SoDa::OSFilterPtr SoDa::BaseBandRX::am_audio_filter
private

After AM demod, we do a second filter.

Definition at line 276 of file BaseBandRX.hxx.

◆ am_pre_filter

SoDa::OSFilterPtr SoDa::BaseBandRX::am_pre_filter
private

Before AM demod, we do some (6KHz) prefilter.

Definition at line 274 of file BaseBandRX.hxx.

◆ audio_buffer_size

unsigned int SoDa::BaseBandRX::audio_buffer_size
private

size of output audio buffer chunk

Definition at line 209 of file BaseBandRX.hxx.

◆ audio_file

std::ofstream SoDa::BaseBandRX::audio_file
private

Definition at line 300 of file BaseBandRX.hxx.

◆ audio_file2

std::ofstream SoDa::BaseBandRX::audio_file2
private

Definition at line 301 of file BaseBandRX.hxx.

◆ audio_ifc

AudioIfcPtr SoDa::BaseBandRX::audio_ifc
private

pointer to the audio interface (output) object

Definition at line 224 of file BaseBandRX.hxx.

Referenced by BaseBandRX(), and make().

◆ audio_level

float SoDa::BaseBandRX::audio_level
private

Definition at line 304 of file BaseBandRX.hxx.

◆ audio_rx_stream_enabled

bool SoDa::BaseBandRX::audio_rx_stream_enabled
private

if true, send pending audio buffers to output

Definition at line 213 of file BaseBandRX.hxx.

◆ audio_rx_stream_needs_start

bool SoDa::BaseBandRX::audio_rx_stream_needs_start
private

if true, the audio output device needs a wakeup

Definition at line 214 of file BaseBandRX.hxx.

◆ audio_sample_rate

double SoDa::BaseBandRX::audio_sample_rate
private

sample rate of audio output – assumed 48KHz

Definition at line 211 of file BaseBandRX.hxx.

◆ audio_save_enable

bool SoDa::BaseBandRX::audio_save_enable
private

Definition at line 299 of file BaseBandRX.hxx.

◆ catchup_rand_mask

unsigned int SoDa::BaseBandRX::catchup_rand_mask
private

a mask to use for fast selection of a random index into an audio buffer.

Definition at line 257 of file BaseBandRX.hxx.

◆ cmd_stream

CmdMBoxPtr SoDa::BaseBandRX::cmd_stream
private

mailbox producing command stream from user

Definition at line 220 of file BaseBandRX.hxx.

◆ cmd_subs

CmdMBox::Subscription SoDa::BaseBandRX::cmd_subs
private

mailbox subscription ID for command stream

Definition at line 222 of file BaseBandRX.hxx.

◆ cur_af_gain

float* SoDa::BaseBandRX::cur_af_gain
private

pointer to the gain setting for this mode

Definition at line 286 of file BaseBandRX.hxx.

◆ cur_audio_filter

SoDa::OSFilterPtr SoDa::BaseBandRX::cur_audio_filter
private

currently selected audio filter

Definition at line 272 of file BaseBandRX.hxx.

◆ dbg_ctr

unsigned int SoDa::BaseBandRX::dbg_ctr
private

debug counter, used to support one-time or infrequent bulletins

Definition at line 295 of file BaseBandRX.hxx.

◆ dbg_out

std::ofstream SoDa::BaseBandRX::dbg_out
private

Definition at line 296 of file BaseBandRX.hxx.

◆ filter_map

std::map<SoDa::Command::AudioFilterBW, SoDa::OSFilterPtr> SoDa::BaseBandRX::filter_map
private

map filter selectors to the filter objects

Definition at line 278 of file BaseBandRX.hxx.

◆ fm_audio_filter

SoDa::OSFilterPtr SoDa::BaseBandRX::fm_audio_filter
private

audio filter for FM (wider passband)

Definition at line 273 of file BaseBandRX.hxx.

◆ fmMedianFilter

MedianFilter3<float> SoDa::BaseBandRX::fmMedianFilter
private

simple 3 point median filter for FM units

Definition at line 292 of file BaseBandRX.hxx.

◆ hilbert

SoDa::HilbertTransformerPtr SoDa::BaseBandRX::hilbert
private

hilbert transform object for SSB/CW widgets

Definition at line 281 of file BaseBandRX.hxx.

◆ in_catchup

bool SoDa::BaseBandRX::in_catchup
private

when true, the audio server has fallen behind...

Definition at line 255 of file BaseBandRX.hxx.

◆ in_fallback

bool SoDa::BaseBandRX::in_fallback
private

when true, the audio server has gotten ahead...

Definition at line 256 of file BaseBandRX.hxx.

◆ last_phase_samp

float SoDa::BaseBandRX::last_phase_samp
private

history value used to calculate dPhase/dt in FM atan based discriminator.

Definition at line 289 of file BaseBandRX.hxx.

◆ log_audio_buffer_size

float SoDa::BaseBandRX::log_audio_buffer_size
private

Definition at line 305 of file BaseBandRX.hxx.

◆ nbfm_pre_filter

SoDa::OSFilterPtr SoDa::BaseBandRX::nbfm_pre_filter
private

Before NBFM demod, we do some (15KHz) prefilter – rf rate.

Definition at line 275 of file BaseBandRX.hxx.

◆ nbfm_squelch_hang_count

int SoDa::BaseBandRX::nbfm_squelch_hang_count
private

if > 0 then send audio.

Definition at line 308 of file BaseBandRX.hxx.

◆ nbfm_squelch_hang_time

int SoDa::BaseBandRX::nbfm_squelch_hang_time
private

continue FM audio demod for this many frames after threshold drops

Definition at line 309 of file BaseBandRX.hxx.

◆ nbfm_squelch_level

float SoDa::BaseBandRX::nbfm_squelch_level
private

average amplitude must be greater to trigger demod.

Definition at line 307 of file BaseBandRX.hxx.

◆ rf_buffer_size

unsigned int SoDa::BaseBandRX::rf_buffer_size
private

size of input RF buffer chunk

Definition at line 210 of file BaseBandRX.hxx.

◆ rf_resampler

SoDa::ReSamplerPtr SoDa::BaseBandRX::rf_resampler
private

downsample the RF input to 48KS/s

Definition at line 262 of file BaseBandRX.hxx.

◆ rf_sample_rate

double SoDa::BaseBandRX::rf_sample_rate
private

sample rate of RF input from USRP – assumed 625KHz

Definition at line 212 of file BaseBandRX.hxx.

◆ rx_modulation

SoDa::Command::ModulationType SoDa::BaseBandRX::rx_modulation
private

current receive modulation mode (USB,LSB,CW_U,CW_L,NBFM,WBFM,AM,...)

Definition at line 217 of file BaseBandRX.hxx.

◆ rx_stream

CDatMBoxPtr SoDa::BaseBandRX::rx_stream
private

mailbox producing rx sample stream from USRP

Definition at line 219 of file BaseBandRX.hxx.

◆ rx_subs

CDatMBox::Subscription SoDa::BaseBandRX::rx_subs
private

mailbox subscription ID for rx data stream

Definition at line 221 of file BaseBandRX.hxx.

◆ sidetone_silence

SoDa::FBufPtr SoDa::BaseBandRX::sidetone_silence
private

a sequence of zero samples to stuff silence into the audio

Definition at line 259 of file BaseBandRX.hxx.

◆ sidetone_stream_enabled

bool SoDa::BaseBandRX::sidetone_stream_enabled
private

if true, send CW sidetone to audio output

Definition at line 215 of file BaseBandRX.hxx.

◆ wbfm_resampler

SoDa::ReSamplerPtr SoDa::BaseBandRX::wbfm_resampler
private

downsample the RF input to 48KS/s for WBFM unit

Definition at line 264 of file BaseBandRX.hxx.


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