2015-12-06 18:47:55 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2015 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-11-19 07:55:58 +00:00
|
|
|
#ifndef INCLUDE_UDPSRC_H
|
|
|
|
#define INCLUDE_UDPSRC_H
|
2015-11-19 02:27:37 +00:00
|
|
|
|
2016-10-02 20:29:04 +00:00
|
|
|
#include <dsp/basebandsamplesink.h>
|
2015-11-19 02:27:37 +00:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QHostAddress>
|
|
|
|
#include "dsp/nco.h"
|
|
|
|
#include "dsp/fftfilt.h"
|
|
|
|
#include "dsp/interpolator.h"
|
2016-04-04 01:44:06 +00:00
|
|
|
#include "dsp/phasediscri.h"
|
2017-08-17 18:23:17 +00:00
|
|
|
#include "dsp/movingaverage.h"
|
2017-08-19 22:32:40 +00:00
|
|
|
#include "dsp/agc.h"
|
2017-08-20 20:18:33 +00:00
|
|
|
#include "dsp/bandpass.h"
|
2016-04-03 09:29:11 +00:00
|
|
|
#include "util/udpsink.h"
|
2015-11-19 02:27:37 +00:00
|
|
|
#include "util/message.h"
|
2015-12-03 03:02:21 +00:00
|
|
|
#include "audio/audiofifo.h"
|
|
|
|
|
2015-11-19 02:27:37 +00:00
|
|
|
|
2015-12-02 01:28:31 +00:00
|
|
|
class QUdpSocket;
|
2017-10-04 20:05:38 +00:00
|
|
|
class DeviceSourceAPI;
|
2017-10-04 20:41:58 +00:00
|
|
|
class ThreadedBasebandSampleSink;
|
|
|
|
class DownChannelizer;
|
2015-11-19 02:27:37 +00:00
|
|
|
|
2016-10-02 20:29:04 +00:00
|
|
|
class UDPSrc : public BasebandSampleSink {
|
2015-11-19 02:27:37 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-10-04 20:41:58 +00:00
|
|
|
class MsgConfigureChannelizer : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getSampleRate() const { return m_sampleRate; }
|
|
|
|
int getCenterFrequency() const { return m_centerFrequency; }
|
|
|
|
|
|
|
|
static MsgConfigureChannelizer* create(int sampleRate, int centerFrequency)
|
|
|
|
{
|
|
|
|
return new MsgConfigureChannelizer(sampleRate, centerFrequency);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_sampleRate;
|
|
|
|
int m_centerFrequency;
|
|
|
|
|
|
|
|
MsgConfigureChannelizer(int sampleRate, int centerFrequency) :
|
|
|
|
Message(),
|
|
|
|
m_sampleRate(sampleRate),
|
|
|
|
m_centerFrequency(centerFrequency)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2015-11-19 02:27:37 +00:00
|
|
|
enum SampleFormat {
|
|
|
|
FormatS16LE,
|
2016-04-05 15:02:24 +00:00
|
|
|
FormatNFM,
|
|
|
|
FormatNFMMono,
|
|
|
|
FormatLSB,
|
|
|
|
FormatUSB,
|
|
|
|
FormatLSBMono,
|
|
|
|
FormatUSBMono,
|
|
|
|
FormatAMMono,
|
2017-08-19 22:32:40 +00:00
|
|
|
FormatAMNoDCMono,
|
2017-08-20 20:18:33 +00:00
|
|
|
FormatAMBPFMono,
|
2015-11-19 02:27:37 +00:00
|
|
|
FormatNone
|
|
|
|
};
|
|
|
|
|
2017-10-04 20:05:38 +00:00
|
|
|
UDPSrc(DeviceSourceAPI *deviceAPI);
|
2015-11-19 02:27:37 +00:00
|
|
|
virtual ~UDPSrc();
|
2017-10-04 20:05:38 +00:00
|
|
|
void setSpectrum(BasebandSampleSink* spectrum) { m_spectrum = spectrum; }
|
2015-11-19 02:27:37 +00:00
|
|
|
|
2015-12-04 02:46:51 +00:00
|
|
|
void configure(MessageQueue* messageQueue,
|
|
|
|
SampleFormat sampleFormat,
|
|
|
|
Real outputSampleRate,
|
|
|
|
Real rfBandwidth,
|
2016-04-04 01:44:06 +00:00
|
|
|
int fmDeviation,
|
2017-08-25 10:12:46 +00:00
|
|
|
const QString& udpAddress,
|
2015-12-04 02:46:51 +00:00
|
|
|
int udpPort,
|
2017-08-18 22:12:56 +00:00
|
|
|
int audioPort,
|
|
|
|
bool force);
|
2015-12-04 02:46:51 +00:00
|
|
|
void configureImmediate(MessageQueue* messageQueue,
|
2015-12-05 11:03:26 +00:00
|
|
|
bool audioActive,
|
2015-12-05 11:23:55 +00:00
|
|
|
bool audioStereo,
|
2017-08-17 10:57:45 +00:00
|
|
|
Real gain,
|
2017-08-17 18:23:17 +00:00
|
|
|
int volume,
|
|
|
|
Real squelchDB,
|
2017-08-18 22:12:56 +00:00
|
|
|
Real squelchGate,
|
|
|
|
bool squelchEnabled,
|
2017-08-19 22:32:40 +00:00
|
|
|
bool agc,
|
2017-08-18 22:12:56 +00:00
|
|
|
bool force);
|
2015-11-19 02:27:37 +00:00
|
|
|
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
2017-05-16 21:39:49 +00:00
|
|
|
double getMagSq() const { return m_magsq; }
|
2017-08-17 18:23:17 +00:00
|
|
|
double getInMagSq() const { return m_inMagsq; }
|
2017-08-17 22:10:15 +00:00
|
|
|
bool getSquelchOpen() const { return m_squelchOpen; }
|
2015-11-19 02:27:37 +00:00
|
|
|
|
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& cmd);
|
|
|
|
|
2017-08-15 14:08:12 +00:00
|
|
|
static const int udpBlockSize = 512; // UDP block size in number of bytes
|
2016-04-03 09:29:11 +00:00
|
|
|
|
2015-12-03 03:02:21 +00:00
|
|
|
public slots:
|
|
|
|
void audioReadyRead();
|
|
|
|
|
2015-11-19 02:27:37 +00:00
|
|
|
protected:
|
|
|
|
class MsgUDPSrcConfigure : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
SampleFormat getSampleFormat() const { return m_sampleFormat; }
|
|
|
|
Real getOutputSampleRate() const { return m_outputSampleRate; }
|
|
|
|
Real getRFBandwidth() const { return m_rfBandwidth; }
|
2016-04-04 01:44:06 +00:00
|
|
|
int getFMDeviation() const { return m_fmDeviation; }
|
2015-12-02 01:28:31 +00:00
|
|
|
const QString& getUDPAddress() const { return m_udpAddress; }
|
2015-11-19 07:55:58 +00:00
|
|
|
int getUDPPort() const { return m_udpPort; }
|
2015-12-04 12:47:43 +00:00
|
|
|
int getAudioPort() const { return m_audioPort; }
|
2017-08-18 22:12:56 +00:00
|
|
|
bool getForce() const { return m_force; }
|
2015-12-04 02:46:51 +00:00
|
|
|
|
|
|
|
static MsgUDPSrcConfigure* create(SampleFormat
|
|
|
|
sampleFormat,
|
|
|
|
Real sampleRate,
|
|
|
|
Real rfBandwidth,
|
2016-04-04 01:44:06 +00:00
|
|
|
int fmDeviation,
|
2017-08-25 10:12:46 +00:00
|
|
|
const QString& udpAddress,
|
2015-12-04 02:46:51 +00:00
|
|
|
int udpPort,
|
2017-08-18 22:12:56 +00:00
|
|
|
int audioPort,
|
|
|
|
bool force)
|
2015-11-19 02:27:37 +00:00
|
|
|
{
|
2015-12-04 02:46:51 +00:00
|
|
|
return new MsgUDPSrcConfigure(sampleFormat,
|
|
|
|
sampleRate,
|
|
|
|
rfBandwidth,
|
2016-04-04 01:44:06 +00:00
|
|
|
fmDeviation,
|
2015-12-04 02:46:51 +00:00
|
|
|
udpAddress,
|
|
|
|
udpPort,
|
2017-08-18 22:12:56 +00:00
|
|
|
audioPort,
|
|
|
|
force);
|
2015-11-19 02:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SampleFormat m_sampleFormat;
|
|
|
|
Real m_outputSampleRate;
|
|
|
|
Real m_rfBandwidth;
|
2016-04-04 01:44:06 +00:00
|
|
|
int m_fmDeviation;
|
2015-12-02 01:28:31 +00:00
|
|
|
QString m_udpAddress;
|
2015-11-19 07:55:58 +00:00
|
|
|
int m_udpPort;
|
2015-12-04 12:47:43 +00:00
|
|
|
int m_audioPort;
|
2017-08-18 22:12:56 +00:00
|
|
|
bool m_force;
|
2015-12-04 02:46:51 +00:00
|
|
|
|
|
|
|
MsgUDPSrcConfigure(SampleFormat sampleFormat,
|
|
|
|
Real outputSampleRate,
|
|
|
|
Real rfBandwidth,
|
2016-04-04 01:44:06 +00:00
|
|
|
int fmDeviation,
|
2017-08-25 10:12:46 +00:00
|
|
|
const QString& udpAddress,
|
2015-12-04 02:46:51 +00:00
|
|
|
int udpPort,
|
2017-08-18 22:12:56 +00:00
|
|
|
int audioPort,
|
|
|
|
bool force) :
|
2015-11-19 02:27:37 +00:00
|
|
|
Message(),
|
|
|
|
m_sampleFormat(sampleFormat),
|
|
|
|
m_outputSampleRate(outputSampleRate),
|
|
|
|
m_rfBandwidth(rfBandwidth),
|
2016-04-04 01:44:06 +00:00
|
|
|
m_fmDeviation(fmDeviation),
|
2015-12-02 01:28:31 +00:00
|
|
|
m_udpAddress(udpAddress),
|
2015-11-19 07:55:58 +00:00
|
|
|
m_udpPort(udpPort),
|
2017-08-18 22:12:56 +00:00
|
|
|
m_audioPort(audioPort),
|
|
|
|
m_force(force)
|
2015-12-04 02:46:51 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgUDPSrcConfigureImmediate : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2017-08-17 10:57:45 +00:00
|
|
|
Real getGain() const { return m_gain; }
|
2015-12-04 02:46:51 +00:00
|
|
|
int getVolume() const { return m_volume; }
|
2015-12-05 11:03:26 +00:00
|
|
|
bool getAudioActive() const { return m_audioActive; }
|
2015-12-05 11:23:55 +00:00
|
|
|
bool getAudioStereo() const { return m_audioStereo; }
|
2017-08-17 18:23:17 +00:00
|
|
|
Real getSquelchDB() const { return m_squelchDB; }
|
2017-08-18 22:12:56 +00:00
|
|
|
Real getSquelchGate() const { return m_squelchGate; }
|
2017-08-17 18:23:17 +00:00
|
|
|
bool getSquelchEnabled() const { return m_squelchEnabled; }
|
2017-08-19 22:32:40 +00:00
|
|
|
bool getAGC() const { return m_agc; }
|
2017-08-18 22:12:56 +00:00
|
|
|
bool getForce() const { return m_force; }
|
2015-12-04 02:46:51 +00:00
|
|
|
|
|
|
|
static MsgUDPSrcConfigureImmediate* create(
|
2015-12-05 11:03:26 +00:00
|
|
|
bool audioActive,
|
2015-12-05 11:23:55 +00:00
|
|
|
bool audioStereo,
|
2017-08-17 22:10:15 +00:00
|
|
|
int gain,
|
2017-08-17 18:23:17 +00:00
|
|
|
int volume,
|
|
|
|
Real squelchDB,
|
2017-08-18 22:12:56 +00:00
|
|
|
Real squelchGate,
|
|
|
|
bool squelchEnabled,
|
2017-08-19 22:32:40 +00:00
|
|
|
bool agc,
|
2017-08-18 22:12:56 +00:00
|
|
|
bool force)
|
2015-12-04 02:46:51 +00:00
|
|
|
{
|
|
|
|
return new MsgUDPSrcConfigureImmediate(
|
2015-12-05 11:03:26 +00:00
|
|
|
audioActive,
|
2015-12-05 11:23:55 +00:00
|
|
|
audioStereo,
|
2017-08-17 22:10:15 +00:00
|
|
|
gain,
|
2017-08-17 18:23:17 +00:00
|
|
|
volume,
|
|
|
|
squelchDB,
|
2017-08-18 22:12:56 +00:00
|
|
|
squelchGate,
|
|
|
|
squelchEnabled,
|
2017-08-19 22:32:40 +00:00
|
|
|
agc,
|
2017-08-18 22:12:56 +00:00
|
|
|
force);
|
2015-12-04 02:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-08-17 10:57:45 +00:00
|
|
|
Real m_gain;
|
2017-08-17 18:23:17 +00:00
|
|
|
int m_volume;
|
2015-12-05 11:03:26 +00:00
|
|
|
bool m_audioActive;
|
2015-12-05 11:23:55 +00:00
|
|
|
bool m_audioStereo;
|
2017-08-17 18:23:17 +00:00
|
|
|
Real m_squelchDB;
|
2017-08-18 22:12:56 +00:00
|
|
|
Real m_squelchGate; // seconds
|
2017-08-17 18:23:17 +00:00
|
|
|
bool m_squelchEnabled;
|
2017-08-19 22:32:40 +00:00
|
|
|
bool m_agc;
|
2017-08-18 22:12:56 +00:00
|
|
|
bool m_force;
|
2015-12-04 02:46:51 +00:00
|
|
|
|
|
|
|
MsgUDPSrcConfigureImmediate(
|
2015-12-05 11:03:26 +00:00
|
|
|
bool audioActive,
|
2015-12-05 11:23:55 +00:00
|
|
|
bool audioStereo,
|
2017-08-17 10:57:45 +00:00
|
|
|
Real gain,
|
2017-08-17 18:23:17 +00:00
|
|
|
int volume,
|
|
|
|
Real squelchDB,
|
2017-08-18 22:12:56 +00:00
|
|
|
Real squelchGate,
|
|
|
|
bool squelchEnabled,
|
2017-08-19 22:32:40 +00:00
|
|
|
bool agc,
|
2017-08-18 22:12:56 +00:00
|
|
|
bool force) :
|
2015-12-04 02:46:51 +00:00
|
|
|
Message(),
|
2017-08-17 10:57:45 +00:00
|
|
|
m_gain(gain),
|
2017-05-25 18:13:34 +00:00
|
|
|
m_volume(volume),
|
2015-12-05 11:03:26 +00:00
|
|
|
m_audioActive(audioActive),
|
2017-08-17 18:23:17 +00:00
|
|
|
m_audioStereo(audioStereo),
|
|
|
|
m_squelchDB(squelchDB),
|
2017-08-18 22:12:56 +00:00
|
|
|
m_squelchGate(squelchGate),
|
|
|
|
m_squelchEnabled(squelchEnabled),
|
2017-08-19 22:32:40 +00:00
|
|
|
m_agc(agc),
|
2017-08-18 22:12:56 +00:00
|
|
|
m_force(force)
|
2015-11-19 02:27:37 +00:00
|
|
|
{ }
|
|
|
|
};
|
2015-12-04 02:46:51 +00:00
|
|
|
|
2015-11-19 02:27:37 +00:00
|
|
|
class MsgUDPSrcSpectrum : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getEnabled() const { return m_enabled; }
|
|
|
|
|
|
|
|
static MsgUDPSrcSpectrum* create(bool enabled)
|
|
|
|
{
|
|
|
|
return new MsgUDPSrcSpectrum(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_enabled;
|
|
|
|
|
|
|
|
MsgUDPSrcSpectrum(bool enabled) :
|
|
|
|
Message(),
|
|
|
|
m_enabled(enabled)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-08-18 22:12:56 +00:00
|
|
|
struct Config {
|
|
|
|
Real m_outputSampleRate;
|
|
|
|
SampleFormat m_sampleFormat;
|
|
|
|
Real m_inputSampleRate;
|
|
|
|
qint64 m_inputFrequencyOffset;
|
|
|
|
Real m_rfBandwidth;
|
|
|
|
int m_fmDeviation;
|
|
|
|
bool m_channelMute;
|
|
|
|
Real m_gain;
|
|
|
|
Real m_squelch; //!< squared magnitude
|
|
|
|
Real m_squelchGate; //!< seconds
|
|
|
|
bool m_squelchEnabled;
|
2017-08-19 22:32:40 +00:00
|
|
|
bool m_agc;
|
2017-08-18 22:12:56 +00:00
|
|
|
bool m_audioActive;
|
|
|
|
bool m_audioStereo;
|
|
|
|
int m_volume;
|
|
|
|
|
|
|
|
QString m_udpAddressStr;
|
|
|
|
quint16 m_udpPort;
|
|
|
|
quint16 m_audioPort;
|
|
|
|
|
|
|
|
Config() :
|
|
|
|
m_outputSampleRate(48000),
|
|
|
|
m_sampleFormat(FormatS16LE),
|
|
|
|
m_inputSampleRate(48000),
|
|
|
|
m_inputFrequencyOffset(0),
|
|
|
|
m_rfBandwidth(12500),
|
|
|
|
m_fmDeviation(2500),
|
|
|
|
m_channelMute(false),
|
|
|
|
m_gain(1.0),
|
|
|
|
m_squelch(1e-6),
|
|
|
|
m_squelchGate(0.0),
|
|
|
|
m_squelchEnabled(true),
|
2017-08-19 22:32:40 +00:00
|
|
|
m_agc(false),
|
2017-08-18 22:12:56 +00:00
|
|
|
m_audioActive(false),
|
|
|
|
m_audioStereo(false),
|
|
|
|
m_volume(20),
|
|
|
|
m_udpAddressStr("127.0.0.1"),
|
|
|
|
m_udpPort(9999),
|
|
|
|
m_audioPort(9998)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
Config m_config;
|
|
|
|
Config m_running;
|
|
|
|
|
2017-10-04 20:05:38 +00:00
|
|
|
DeviceSourceAPI *m_deviceAPI;
|
2017-10-04 20:41:58 +00:00
|
|
|
ThreadedBasebandSampleSink* m_threadedChannelizer;
|
|
|
|
DownChannelizer* m_channelizer;
|
2017-10-04 20:05:38 +00:00
|
|
|
|
2015-12-03 03:02:21 +00:00
|
|
|
QUdpSocket *m_audioSocket;
|
2015-11-19 02:27:37 +00:00
|
|
|
|
2017-05-16 21:39:49 +00:00
|
|
|
double m_magsq;
|
2017-08-17 18:23:17 +00:00
|
|
|
double m_inMagsq;
|
|
|
|
MovingAverage<double> m_outMovingAverage;
|
|
|
|
MovingAverage<double> m_inMovingAverage;
|
2017-08-19 22:32:40 +00:00
|
|
|
MovingAverage<double> m_amMovingAverage;
|
2015-11-19 02:27:37 +00:00
|
|
|
|
|
|
|
Real m_scale;
|
|
|
|
Complex m_last, m_this;
|
|
|
|
|
|
|
|
NCO m_nco;
|
|
|
|
Interpolator m_interpolator;
|
|
|
|
Real m_sampleDistanceRemain;
|
2015-11-19 07:55:58 +00:00
|
|
|
fftfilt* UDPFilter;
|
2015-11-19 02:27:37 +00:00
|
|
|
|
|
|
|
SampleVector m_sampleBuffer;
|
2016-04-03 09:29:11 +00:00
|
|
|
UDPSink<Sample> *m_udpBuffer;
|
2016-04-05 15:02:24 +00:00
|
|
|
UDPSink<FixReal> *m_udpBufferMono;
|
2015-12-03 03:02:21 +00:00
|
|
|
|
|
|
|
AudioVector m_audioBuffer;
|
|
|
|
uint m_audioBufferFill;
|
|
|
|
AudioFifo m_audioFifo;
|
|
|
|
|
2016-10-02 20:29:04 +00:00
|
|
|
BasebandSampleSink* m_spectrum;
|
2015-11-19 02:27:37 +00:00
|
|
|
bool m_spectrumEnabled;
|
|
|
|
|
|
|
|
quint32 m_nextSSBId;
|
|
|
|
quint32 m_nextS16leId;
|
|
|
|
|
2016-04-06 07:33:29 +00:00
|
|
|
char *m_udpAudioBuf;
|
|
|
|
static const int m_udpAudioPayloadSize = 8192; //!< UDP audio samples buffer. No UDP block on Earth is larger than this
|
2017-08-21 11:10:54 +00:00
|
|
|
static const Real m_agcTarget;
|
2016-04-06 07:33:29 +00:00
|
|
|
|
2016-04-04 01:44:06 +00:00
|
|
|
PhaseDiscriminators m_phaseDiscri;
|
|
|
|
|
2017-08-17 22:10:15 +00:00
|
|
|
bool m_squelchOpen;
|
|
|
|
int m_squelchOpenCount;
|
|
|
|
int m_squelchCloseCount;
|
2017-08-20 21:44:40 +00:00
|
|
|
int m_squelchGate; //!< number of samples computed from given gate
|
|
|
|
int m_squelchRelease;
|
2017-08-17 22:10:15 +00:00
|
|
|
|
2017-08-19 22:32:40 +00:00
|
|
|
MagAGC m_agc;
|
2017-08-20 20:18:33 +00:00
|
|
|
Bandpass<double> m_bandpass;
|
2017-08-19 22:32:40 +00:00
|
|
|
|
2015-11-19 02:27:37 +00:00
|
|
|
QMutex m_settingsMutex;
|
2017-08-17 22:10:15 +00:00
|
|
|
|
2017-08-18 22:12:56 +00:00
|
|
|
void apply(bool force);
|
|
|
|
|
2017-08-17 22:10:15 +00:00
|
|
|
inline void calculateSquelch(double value)
|
|
|
|
{
|
2017-08-18 22:12:56 +00:00
|
|
|
if ((!m_running.m_squelchEnabled) || (value > m_running.m_squelch))
|
2017-08-17 22:10:15 +00:00
|
|
|
{
|
2017-08-20 21:44:40 +00:00
|
|
|
if (m_squelchGate == 0)
|
2017-08-18 22:12:56 +00:00
|
|
|
{
|
2017-08-17 22:10:15 +00:00
|
|
|
m_squelchOpen = true;
|
|
|
|
}
|
2017-08-18 22:12:56 +00:00
|
|
|
else
|
|
|
|
{
|
2017-08-20 21:44:40 +00:00
|
|
|
if (m_squelchOpenCount < m_squelchGate)
|
2017-08-18 22:12:56 +00:00
|
|
|
{
|
|
|
|
m_squelchOpenCount++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-20 21:44:40 +00:00
|
|
|
m_squelchCloseCount = m_squelchRelease;
|
2017-08-18 22:12:56 +00:00
|
|
|
m_squelchOpen = true;
|
|
|
|
}
|
|
|
|
}
|
2017-08-17 22:10:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-20 21:44:40 +00:00
|
|
|
if (m_squelchGate == 0)
|
2017-08-18 22:12:56 +00:00
|
|
|
{
|
2017-08-17 22:10:15 +00:00
|
|
|
m_squelchOpen = false;
|
|
|
|
}
|
2017-08-18 22:12:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_squelchCloseCount > 0)
|
|
|
|
{
|
|
|
|
m_squelchCloseCount--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_squelchOpenCount = 0;
|
|
|
|
m_squelchOpen = false;
|
|
|
|
}
|
|
|
|
}
|
2017-08-17 22:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void initSquelch(bool open)
|
|
|
|
{
|
|
|
|
if (open)
|
|
|
|
{
|
|
|
|
m_squelchOpen = true;
|
2017-08-20 21:44:40 +00:00
|
|
|
m_squelchOpenCount = m_squelchGate;
|
|
|
|
m_squelchCloseCount = m_squelchRelease;
|
2017-08-17 22:10:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_squelchOpen = false;
|
|
|
|
m_squelchOpenCount = 0;
|
|
|
|
m_squelchCloseCount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-19 02:27:37 +00:00
|
|
|
};
|
|
|
|
|
2015-11-19 07:55:58 +00:00
|
|
|
#endif // INCLUDE_UDPSRC_H
|