SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
BaseBandTX.hxx
Go to the documentation of this file.
1/*
2Copyright (c) 2012,2013,2014,2025 Matthew H. Reilly (kb1vc)
3All rights reserved.
4
5 FM modulator features based on code contributed by and
6 Copyright (c) 2014, Aaron Yankey Antwi (aaronyan2001@gmail.com)
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are
10met:
11
12 Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in
16 the documentation and/or other materials provided with the
17 distribution.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30*/
31#pragma once
32
33#include "SoDaBase.hxx"
34#include "SoDaThread.hxx"
35#include "Params.hxx"
36#include "Command.hxx"
38#include "AudioIfc.hxx"
39
40#include <SoDa/MailBox.hxx>
41#include <SoDa/ReSampler.hxx>
42#include <SoDa/OSFilter.hxx>
43
44namespace SoDa {
54 class BaseBandRX;
55
56 class BaseBandTX;
57 typedef std::shared_ptr<BaseBandTX> BaseBandTXPtr;
58 typedef std::weak_ptr<BaseBandTX> BaseBandTXWeakPtr;
59
60 class BaseBandTX : public SoDa::Thread {
61 protected:
70 );
71
72 public:
75 ) {
76 auto ret = std::shared_ptr<BaseBandTX>(new BaseBandTX(params, audio_ifc));
77 ret->registerThread(ret);
78 return ret;
79 }
80
82 void subscribeToMailBoxes(const std::vector<MailBoxBasePtr> & mailboxes);
83
84
88 void run();
89 private:
105
115 SoDa::CBufPtr modulateAM(std::vector<float> & audio_buf,
116 bool is_usb, bool is_lsb);
117
126 SoDa::CBufPtr modulateFM(std::vector<float> & audio_buf,
127 double deviation);
128
129 double fm_phase;
132 double fm_mic_gain;
133
134
137 CmdMBox::Subscription cmd_subs;
138
139 // The interpolator
140 SoDa::ReSamplerPtr interpolator;
141
142 // parameters
143 unsigned int audio_buffer_size;
145 unsigned int tx_buffer_size;
146
149 bool tx_on;
150
151
152 float af_gain;
153
154 // audio server state
156
158
159 // we need some intermediate storage for things like
160 // the IQ buffer
161 std::vector<std::complex<float>> audio_IQ_buf;
162
167 std::vector<float> noise_buffer;
168
174
179
183 SoDa::OSFilterPtr tx_audio_filter;
184
189
193 float mic_gain;
194
197 };
198}
199
200
The Baseclass for all SoDa objects, and useful commonly used classes.
The Baseclass for all SoDa thread objects.
void execGetCommand(CommandPtr cmd)
execute GET commands from the command channel
bool tx_audio_filter_ena
There is an audio filter in the chain, by default.
void execSetCommand(CommandPtr cmd)
handle SET commands from the command channel
double wbfm_deviation
phase advance for 75kHz deviation
SoDa::HilbertTransformerPtr hilbert
The hilbert transformer to create an analytic (I/Q) signal.
SoDa::ReSamplerPtr interpolator
Upsample from 48KHz to 625KHz.
bool debug_mode
if true, print extra debug info
void subscribeToMailBoxes(const std::vector< MailBoxBasePtr > &mailboxes)
implement the subscription method
double fm_mic_gain
separate gain control for FM deviation....
CDatMBoxPtr tx_stream
outbound RF stream to USRPTX transmit chain
void run()
the run method – does the work of the audio transmitter process
std::vector< float > noise_buffer
This is a buffer that holds a set of "noise" samples (uniform random) for testing the TX audio chain.
float mic_gain
mic gain is adjustable, to make sure we aren't noxious.
BaseBandTX(ParamsPtr params, AudioIfcPtr audio_ifc)
constructor
unsigned int audio_buffer_size
length (in samples) of an input audio buffer
static BaseBandTXPtr make(ParamsPtr params, AudioIfcPtr audio_ifc)
SoDa::Command::ModulationType tx_mode
what modulation scheme? USB? LSB? CW_U?...
double audio_sample_rate
wired in lots of places as 48KHz
CmdMBox::Subscription cmd_subs
subscription ID for command stream
unsigned int tx_buffer_size
how long is the outbound RF buffer
bool cw_tx_mode
if true, tx_mode is CW_L or CW_U
std::vector< std::complex< float > > audio_IQ_buf
temporary storage for outbound modulation envelope
bool tx_noise_source_ena
When this is TRUE, audio modes (USB,LSB,AM,NBFM,WBFM) use a noise source for input.
bool tx_stream_on
if true, we are transmitting.
float af_gain
local microphone gain.
double nbfm_deviation
phase advance for 2.5kHz deviation.
AudioIfcPtr audio_ifc
pointer to an AudioIfc object for the microphone input
CmdMBoxPtr cmd_stream
command stream from UI and other units
SoDa::CBufPtr modulateFM(std::vector< float > &audio_buf, double deviation)
create a narrowband/wideband FM modulation envelope
SoDa::CBufPtr modulateAM(std::vector< float > &audio_buf, bool is_usb, bool is_lsb)
create an AM/SSB modulation envelope
void execRepCommand(CommandPtr cmd)
handle Report commands from the command channel
bool tx_on
set by Command::TX_STATE to on or off
SoDa::OSFilterPtr tx_audio_filter
TX audio filter.
ModulationType
modulation selector targets take one of these values
Definition Command.hxx:532
The Thread baseclass for all SoDa thread objects.
std::shared_ptr< HilbertTransformer > HilbertTransformerPtr
std::shared_ptr< Params > ParamsPtr
Definition Params.hxx:42
std::shared_ptr< Command > CommandPtr
Definition Command.hxx:41
std::shared_ptr< AudioIfc > AudioIfcPtr
Definition AudioIfc.hxx:36
std::shared_ptr< CmdMBox > CmdMBoxPtr
Definition SoDaBase.hxx:79
std::shared_ptr< CDatMBox > CDatMBoxPtr
Definition SoDaBase.hxx:91
std::shared_ptr< CBuf > CBufPtr
Definition SoDaBase.hxx:64
std::weak_ptr< BaseBandTX > BaseBandTXWeakPtr
std::shared_ptr< BaseBandTX > BaseBandTXPtr