Skip to content

Commit

Permalink
Implemented a DDR pre-demod signal level detector
Browse files Browse the repository at this point in the history
  • Loading branch information
sm0svx committed Jul 17, 2014
1 parent 45dfeda commit 7248e1d
Show file tree
Hide file tree
Showing 7 changed files with 516 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/svxlink/siglevdetcal/siglevdetcal.cpp
Expand Up @@ -290,7 +290,7 @@ int main(int argc, char **argv)
cfg.setValue(rx_name, "CTCSS_OPEN_THRESH", "100");

// Make sure we are using the "Noise" siglev detector
cfg.setValue(rx_name, "SIGLEV_DET", "NOISE");
//cfg.setValue(rx_name, "SIGLEV_DET", "NOISE");

// Read the configured siglev slope and offset, then clear them so that
// they cannot affect the measurement.
Expand Down
2 changes: 1 addition & 1 deletion src/svxlink/trx/CMakeLists.txt
Expand Up @@ -15,7 +15,7 @@ set(LIBSRC
SquelchEvDev.cpp Macho.cpp SquelchGpio.cpp Ptt.cpp
PttGpio.cpp PttSerialPin.cpp Pty.cpp PttPty.cpp
PtyDtmfDecoder.cpp LocalRxBase.cpp Ddr.cpp RtlTcp.cpp WbRxRtlTcp.cpp
SigLevDet.cpp
SigLevDet.cpp SigLevDetDdr.cpp
)

# Which other libraries this library depends on
Expand Down
37 changes: 36 additions & 1 deletion src/svxlink/trx/Ddr.cpp
Expand Up @@ -429,6 +429,7 @@ namespace {
iq_dec1.decimate(dec_samp1, samples);
iq_dec2.decimate(dec_samp2, dec_samp1);
ch_filt.decimate(ch_samp, dec_samp2);
preDemod(ch_samp);
//dec_samp = samples;
#if 0
outfile.write(reinterpret_cast<char*>(&ch_samp[0]),
Expand Down Expand Up @@ -493,6 +494,8 @@ namespace {
*/
}

sigc::signal<void, const std::vector<RtlTcp::Sample>&> preDemod;

private:
float iold;
float qold;
Expand Down Expand Up @@ -572,12 +575,13 @@ namespace {
}; /* anonymous namespace */


class Ddr::Channel
class Ddr::Channel : public sigc::trackable
{
public:
Channel(AudioSink &audio_sink, int fq_offset)
: fm_demod(audio_sink), trans(960000, fq_offset)
{
fm_demod.preDemod.connect(preDemod.make_slot());
}

void iq_received(vector<WbRxRtlTcp::Sample> samples)
Expand All @@ -587,6 +591,8 @@ class Ddr::Channel
fm_demod.iq_received(translated);
};

sigc::signal<void, const std::vector<RtlTcp::Sample>&> preDemod;

private:
FmDemod fm_demod;
Translate trans;
Expand Down Expand Up @@ -615,6 +621,7 @@ class Ddr::Channel
*
****************************************************************************/

Ddr::DdrMap Ddr::ddr_map;


/****************************************************************************
Expand All @@ -623,6 +630,17 @@ class Ddr::Channel
*
****************************************************************************/

Ddr *Ddr::find(const std::string &name)
{
DdrMap::iterator it = ddr_map.find(name);
if (it != ddr_map.end())
{
return (*it).second;
}
return 0;
} /* Ddr::find */


Ddr::Ddr(Config &cfg, const std::string& name)
: LocalRxBase(cfg, name), cfg(cfg), audio_pipe(0), channel(0), rtl(0)
{
Expand All @@ -631,6 +649,12 @@ Ddr::Ddr(Config &cfg, const std::string& name)

Ddr::~Ddr(void)
{
DdrMap::iterator it = ddr_map.find(name());
if (it != ddr_map.end())
{
ddr_map.erase(it);
}

delete channel;
delete rtl;
delete audio_pipe;
Expand All @@ -639,6 +663,16 @@ Ddr::~Ddr(void)

bool Ddr::initialize(void)
{
DdrMap::iterator it = ddr_map.find(name());
if (it != ddr_map.end())
{
cout << "*** ERROR: The name for a Digital Drop Receiver (DDR) must be "
<< "unique. There already is a receiver named \"" << name()
<< "\".\n";
return false;
}
ddr_map[name()] = this;

double fq = 0.0;
if (!cfg.getValue(name(), "FQ", fq))
{
Expand All @@ -665,6 +699,7 @@ bool Ddr::initialize(void)
}

channel = new Channel(*audio_pipe, fq-rtl->centerFq());
channel->preDemod.connect(preDemod.make_slot());
rtl->iqReceived.connect(mem_fun(*channel, &Channel::iq_received));

if (!LocalRxBase::initialize())
Expand Down
8 changes: 8 additions & 0 deletions src/svxlink/trx/Ddr.h
Expand Up @@ -54,6 +54,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/

#include "LocalRxBase.h"
#include "RtlTcp.h"


/****************************************************************************
Expand Down Expand Up @@ -122,6 +123,8 @@ extracted from this wideband signal and a demodulator is applied.
class Ddr : public LocalRxBase
{
public:
static Ddr *find(const std::string &name);

/**
* @brief Default constuctor
*/
Expand All @@ -137,6 +140,8 @@ class Ddr : public LocalRxBase
* @return Return \em true on success, or \em false on failure
*/
virtual bool initialize(void);

sigc::signal<void, const std::vector<RtlTcp::Sample>&> preDemod;

protected:
/**
Expand Down Expand Up @@ -180,6 +185,9 @@ class Ddr : public LocalRxBase

private:
class Channel;
typedef std::map<std::string, Ddr*> DdrMap;

static DdrMap ddr_map;

Async::Config &cfg;
Async::AudioPassthrough *audio_pipe;
Expand Down
2 changes: 2 additions & 0 deletions src/svxlink/trx/SigLevDet.cpp
Expand Up @@ -53,6 +53,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "SigLevDet.h"
#include "SigLevDetNoise.h"
#include "SigLevDetTone.h"
#include "SigLevDetDdr.h"



Expand Down Expand Up @@ -141,6 +142,7 @@ SigLevDet *SigLevDetFactoryBase::createNamedSigLevDet(Config& cfg,
SigLevDetNone::Factory none_siglev_factory;
SigLevDetNoise::Factory noise_siglev_factory;
SigLevDetTone::Factory tone_siglev_factory;
SigLevDetDdr::Factory ddr_siglev_factory;

string det_name;
if (!cfg.getValue(name, "SIGLEV_DET", det_name) || det_name.empty())
Expand Down

0 comments on commit 7248e1d

Please sign in to comment.