SoDaRadio-5.0.3-master:8901fb5
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SoDa::BaseBandTX Class Reference

#include <BaseBandTX.hxx>

Inheritance diagram for SoDa::BaseBandTX:
SoDa::SoDaThread SoDa::SoDaBase SoDa::Debug

Public Member Functions

 BaseBandTX (Params *params, DatMBox *tx_stream, CmdMBox *cmd_stream, AudioIfc *audio_ifc)
 constructor More...
 
void run ()
 the run method – does the work of the audio transmitter process More...
 
- Public Member Functions inherited from SoDa::SoDaThread
 SoDaThread (const std::string &oname)
 
void start ()
 Execute the threads run loop. More...
 
void join ()
 more properly "Wait for this thread to exit its run loop". More...
 
bool waitForJoin (unsigned int m)
 wait for the thread to stop running, or the specified time to pass. More...
 
void execCommand (Command *cmd)
 Execute (dispatch) a message removed from the command stream to one of the basic Command handler functions. More...
 
- Public Member Functions inherited from SoDa::SoDaBase
 SoDaBase (const std::string &oname)
 The constructor – pass a name for the object. More...
 
std::string & getObjName ()
 get the name of this object More...
 
SoDaBasefindSoDaObject (const std::string &oname)
 find a SoDa Object by name. More...
 
double getTime ()
 Get a time stamp in nS resolution that monotonically increases and that is very inexpensive (typically < 100nS). More...
 
- 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 boost::format &fmt, unsigned int threshold=1)
 
void debugMsg (const char *msg, unsigned int threshold=1)
 
void setDebugLevel (unsigned int v)
 
unsigned int getDebugLevel ()
 

Private Member Functions

void execGetCommand (Command *cmd)
 execute GET commands from the command channel More...
 
void execSetCommand (Command *cmd)
 handle SET commands from the command channel More...
 
void execRepCommand (Command *cmd)
 handle Report commands from the command channel More...
 
SoDa::SoDaBufmodulateAM (float *audio_buf, unsigned int len, bool is_usb, bool is_lsb)
 create an AM/SSB modulation envelope More...
 
SoDa::SoDaBufmodulateFM (float *audio_buf, unsigned int len, double deviation)
 create a narrowband/wideband FM modulation envelope More...
 

Private Attributes

double fm_phase
 
double nbfm_deviation
 phase advance for 2.5kHz deviation. More...
 
double wbfm_deviation
 phase advance for 75kHz deviation More...
 
double fm_mic_gain
 separate gain control for FM deviation.... More...
 
DatMBoxtx_stream
 outbound RF stream to USRPTX transmit chain More...
 
CmdMBoxcmd_stream
 command stream from UI and other units More...
 
unsigned int cmd_subs
 subscription ID for command stream More...
 
SoDa::ReSample48to625interpolator
 Upsample from 48KHz to 625KHz. More...
 
unsigned int audio_buffer_size
 length (in samples) of an input audio buffer More...
 
double audio_sample_rate
 wired in lots of places as 48KHz More...
 
unsigned int tx_buffer_size
 how long is the outbound RF buffer More...
 
SoDa::Command::ModulationType tx_mode
 what modulation scheme? USB? LSB? CW_U?... More...
 
bool cw_tx_mode
 if true, tx_mode is CW_L or CW_U More...
 
bool tx_on
 set by Command::TX_STATE to on or off More...
 
float af_gain
 local microphone gain. More...
 
AudioIfcaudio_ifc
 pointer to an AudioIfc object for the microphone input More...
 
bool tx_stream_on
 if true, we are transmitting. More...
 
std::complex< float > * audio_IQ_buf
 temporary storage for outbound modulation envelope More...
 
float * ssb_af_upsample
 SSB modulation requires that we upsample before doing the quadrature generation. More...
 
float * noise_buffer
 This is a buffer that holds a set of "noise" samples (uniform random) for testing the TX audio chain. More...
 
bool tx_noise_source_ena
 When this is TRUE, audio modes (USB,LSB,AM,NBFM,WBFM) use a noise source for input. More...
 
bool tx_audio_filter_ena
 There is an audio filter in the chain, by default. More...
 
SoDa::OSFiltertx_audio_filter
 TX audio filter. More...
 
SoDa::HilbertTransformerhilbert
 The hilbert transformer to create an analytic (I/Q) signal. More...
 
float mic_gain
 mic gain is adjustable, to make sure we aren't noxious. More...
 
bool debug_mode
 if true, print extra debug info More...
 
int debug_ctr
 

Additional Inherited Members

- 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 ()
 
- Static Public Attributes inherited from SoDa::Debug
static boost::mutex debug_msg_mutex
 
- Protected Member Functions inherited from SoDa::Debug
std::string curDateTime ()
 
- Protected Attributes inherited from SoDa::Debug
std::string unit_name
 the name of the unit reporting status More...
 
unsigned int debug_level
 the debug level (threshold) for messages More...
 
- Static Protected Attributes inherited from SoDa::Debug
static unsigned int default_debug_level = 0
 
static unsigned int global_debug_level = 0
 

Detailed Description

Definition at line 53 of file BaseBandTX.hxx.

Constructor & Destructor Documentation

◆ BaseBandTX()

SoDa::BaseBandTX::BaseBandTX ( Params params,
DatMBox tx_stream,
CmdMBox cmd_stream,
AudioIfc audio_ifc 
)

constructor

Parameters
paramscommand line parameter object
tx_streampointer to mailbox holding USRP RX bitstream
cmd_streampointer to mailbox holding control/report commands
audio_ifcpointer to the audio output handler

Definition at line 45 of file BaseBandTX.cxx.

References audio_buffer_size, audio_ifc, audio_IQ_buf, cmd_stream, cmd_subs, debug_ctr, debug_mode, fm_mic_gain, fm_phase, SoDa::Params::getAFBufferSize(), SoDa::Params::getAudioSampleRate(), SoDa::Params::getRFBufferSize(), hilbert, interpolator, mic_gain, nbfm_deviation, noise_buffer, SoDa::MultiMBox< T >::subscribe(), tx_audio_filter, tx_audio_filter_ena, tx_buffer_size, tx_noise_source_ena, tx_stream, tx_stream_on, and wbfm_deviation.

Member Function Documentation

◆ execGetCommand()

void SoDa::BaseBandTX::execGetCommand ( SoDa::Command cmd)
privatevirtual

execute GET commands from the command channel

Parameters
cmdthe incoming command

Reimplemented from SoDa::SoDaThread.

Definition at line 357 of file BaseBandTX.cxx.

◆ execRepCommand()

void SoDa::BaseBandTX::execRepCommand ( SoDa::Command cmd)
privatevirtual

handle Report commands from the command channel

Parameters
cmdthe incoming command

Reimplemented from SoDa::SoDaThread.

Definition at line 362 of file BaseBandTX.cxx.

◆ execSetCommand()

void SoDa::BaseBandTX::execSetCommand ( SoDa::Command cmd)
privatevirtual

◆ modulateAM()

SoDa::SoDaBuf * SoDa::BaseBandTX::modulateAM ( float *  audio_buf,
unsigned int  len,
bool  is_usb,
bool  is_lsb 
)
private

create an AM/SSB modulation envelope

Parameters
audio_bufthe buffer of modulating audio info
lenthe length of the audio buffer
is_usbif true, generate upper sideband
is_lsbif true, generate lower sideband if both is_usb and is_lsb are false, the modulator creates an IQ stream that is amplitude modulated

If the modulation scheme is USB or SSB, we need to make an analytic signal from the scalar real audio_buf.

If we're looking at USB, then for I = sin(w), Q => cos(w) for LSB I = sin(w), Q => -cos(w)

if neither is_usb is_lsb is true, then we want to produce an AM envelope. Put the same signal in both I and Q.

Now that the I/Q channels have been populated, get a transmit buffer. and upsample the I/Q audio up to the RF rate.

Upsample the IQ audio (at 48KS/s) to the RF sample rate of 625 KS/s

pass the newly created and filled buffer back to the caller

Definition at line 200 of file BaseBandTX.cxx.

References SoDa::MultiMBox< T >::alloc(), SoDa::ReSample48to625::apply(), SoDa::HilbertTransformer::apply(), audio_buffer_size, audio_IQ_buf, SoDa::SoDaBuf::getComplexBuf(), SoDa::SoDaBuf::getComplexLen(), hilbert, interpolator, mic_gain, tx_buffer_size, and tx_stream.

Referenced by run().

◆ modulateFM()

SoDa::SoDaBuf * SoDa::BaseBandTX::modulateFM ( float *  audio_buf,
unsigned int  len,
double  deviation 
)
private

create a narrowband/wideband FM modulation envelope

Parameters
audio_bufthe buffer of modulating audio info
lenthe length of the audio buffer
deviationthe phase shift per audio sample for a maximum amplitude (1.0) input.

Note that this modulator varies the mic gain to prevent over-deviation.

Definition at line 243 of file BaseBandTX.cxx.

References SoDa::MultiMBox< T >::alloc(), SoDa::ReSample48to625::apply(), audio_buffer_size, audio_IQ_buf, fm_mic_gain, fm_phase, interpolator, tx_buffer_size, and tx_stream.

Referenced by run().

◆ run()

void SoDa::BaseBandTX::run ( )
virtual

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

This is the BaseBandTX run loop.

while true
if(commands_available)
handle commands
else if(in CW transmit mode)
sleep 1mS
else
if ((tx ON) and audio is ready)
get audio buffer
modulate with audio buffer
put modulation envelope in outbound queue
sleep 1mS

Implements SoDa::SoDaThread.

Definition at line 111 of file BaseBandTX.cxx.

References SoDa::Command::AM, SoDa::OSFilter::apply(), audio_buffer_size, audio_ifc, cmd_stream, cmd_subs, cw_tx_mode, SoDa::SoDaThread::execCommand(), SoDa::MultiMBox< T >::free(), SoDa::MultiMBox< T >::get(), SoDa::Command::LSB, modulateAM(), modulateFM(), SoDa::Command::NBFM, nbfm_deviation, noise_buffer, SoDa::MultiMBox< T >::put(), SoDa::AudioIfc::recv(), SoDa::AudioIfc::recvBufferReady(), SoDa::Command::STOP, SoDa::Command::target, tx_audio_filter, tx_audio_filter_ena, tx_mode, tx_noise_source_ena, tx_stream, tx_stream_on, SoDa::Command::USB, SoDa::AudioIfc::wakeIn(), SoDa::Command::WBFM, and wbfm_deviation.

Member Data Documentation

◆ af_gain

float SoDa::BaseBandTX::af_gain
private

local microphone gain.

Definition at line 134 of file BaseBandTX.hxx.

Referenced by execSetCommand().

◆ audio_buffer_size

unsigned int SoDa::BaseBandTX::audio_buffer_size
private

length (in samples) of an input audio buffer

Definition at line 125 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), modulateAM(), modulateFM(), and run().

◆ audio_ifc

AudioIfc* SoDa::BaseBandTX::audio_ifc
private

pointer to an AudioIfc object for the microphone input

Definition at line 137 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and run().

◆ audio_IQ_buf

std::complex<float>* SoDa::BaseBandTX::audio_IQ_buf
private

temporary storage for outbound modulation envelope

Definition at line 143 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), modulateAM(), and modulateFM().

◆ audio_sample_rate

double SoDa::BaseBandTX::audio_sample_rate
private

wired in lots of places as 48KHz

Definition at line 126 of file BaseBandTX.hxx.

◆ cmd_stream

CmdMBox* SoDa::BaseBandTX::cmd_stream
private

command stream from UI and other units

Definition at line 118 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), execSetCommand(), and run().

◆ cmd_subs

unsigned int SoDa::BaseBandTX::cmd_subs
private

subscription ID for command stream

Definition at line 119 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and run().

◆ cw_tx_mode

bool SoDa::BaseBandTX::cw_tx_mode
private

if true, tx_mode is CW_L or CW_U

Definition at line 130 of file BaseBandTX.hxx.

Referenced by execSetCommand(), and run().

◆ debug_ctr

int SoDa::BaseBandTX::debug_ctr
private

Definition at line 184 of file BaseBandTX.hxx.

Referenced by BaseBandTX().

◆ debug_mode

bool SoDa::BaseBandTX::debug_mode
private

if true, print extra debug info

Definition at line 183 of file BaseBandTX.hxx.

Referenced by BaseBandTX().

◆ fm_mic_gain

double SoDa::BaseBandTX::fm_mic_gain
private

separate gain control for FM deviation....

Definition at line 114 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and modulateFM().

◆ fm_phase

double SoDa::BaseBandTX::fm_phase
private

Definition at line 111 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and modulateFM().

◆ hilbert

SoDa::HilbertTransformer* SoDa::BaseBandTX::hilbert
private

The hilbert transformer to create an analytic (I/Q) signal.

Definition at line 176 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and modulateAM().

◆ interpolator

SoDa::ReSample48to625* SoDa::BaseBandTX::interpolator
private

Upsample from 48KHz to 625KHz.

Definition at line 122 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), modulateAM(), and modulateFM().

◆ mic_gain

float SoDa::BaseBandTX::mic_gain
private

mic gain is adjustable, to make sure we aren't noxious.

Definition at line 181 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and modulateAM().

◆ nbfm_deviation

double SoDa::BaseBandTX::nbfm_deviation
private

phase advance for 2.5kHz deviation.

Definition at line 112 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and run().

◆ noise_buffer

float* SoDa::BaseBandTX::noise_buffer
private

This is a buffer that holds a set of "noise" samples (uniform random) for testing the TX audio chain.

Definition at line 155 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and run().

◆ ssb_af_upsample

float* SoDa::BaseBandTX::ssb_af_upsample
private

SSB modulation requires that we upsample before doing the quadrature generation.

Definition at line 149 of file BaseBandTX.hxx.

◆ tx_audio_filter

SoDa::OSFilter* SoDa::BaseBandTX::tx_audio_filter
private

TX audio filter.

Definition at line 171 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and run().

◆ tx_audio_filter_ena

bool SoDa::BaseBandTX::tx_audio_filter_ena
private

There is an audio filter in the chain, by default.

This is the enable.

Definition at line 166 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), execSetCommand(), and run().

◆ tx_buffer_size

unsigned int SoDa::BaseBandTX::tx_buffer_size
private

how long is the outbound RF buffer

Definition at line 127 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), modulateAM(), and modulateFM().

◆ tx_mode

SoDa::Command::ModulationType SoDa::BaseBandTX::tx_mode
private

what modulation scheme? USB? LSB? CW_U?...

Definition at line 129 of file BaseBandTX.hxx.

Referenced by execSetCommand(), and run().

◆ tx_noise_source_ena

bool SoDa::BaseBandTX::tx_noise_source_ena
private

When this is TRUE, audio modes (USB,LSB,AM,NBFM,WBFM) use a noise source for input.

Definition at line 161 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), execSetCommand(), and run().

◆ tx_on

bool SoDa::BaseBandTX::tx_on
private

set by Command::TX_STATE to on or off

Definition at line 131 of file BaseBandTX.hxx.

Referenced by execSetCommand().

◆ tx_stream

DatMBox* SoDa::BaseBandTX::tx_stream
private

outbound RF stream to USRPTX transmit chain

Definition at line 117 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), modulateAM(), modulateFM(), and run().

◆ tx_stream_on

bool SoDa::BaseBandTX::tx_stream_on
private

if true, we are transmitting.

Definition at line 139 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), execSetCommand(), and run().

◆ wbfm_deviation

double SoDa::BaseBandTX::wbfm_deviation
private

phase advance for 75kHz deviation

Definition at line 113 of file BaseBandTX.hxx.

Referenced by BaseBandTX(), and run().


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