2016-04-07 07:05:53 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2016-04-21 21:53:16 -04:00
|
|
|
// Copyright (C) 2016 F4EXB //
|
2016-04-08 12:14:50 -04:00
|
|
|
// written by Edouard Griffiths //
|
2016-04-07 07:05:53 -04:00
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-10-02 07:18:07 -04:00
|
|
|
|
2016-04-07 07:05:53 -04:00
|
|
|
#include <QTime>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <complex.h>
|
2017-10-02 07:56:40 -04:00
|
|
|
|
2016-10-02 15:52:39 -04:00
|
|
|
#include <dsp/downchannelizer.h>
|
2016-04-07 07:05:53 -04:00
|
|
|
#include "audio/audiooutput.h"
|
|
|
|
#include "dsp/pidcontroller.h"
|
|
|
|
#include "dsp/dspengine.h"
|
2017-10-02 07:56:40 -04:00
|
|
|
#include "dsp/threadedbasebandsamplesink.h"
|
|
|
|
#include <dsp/downchannelizer.h>
|
|
|
|
#include <device/devicesourceapi.h>
|
|
|
|
|
|
|
|
#include "dsddemod.h"
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2017-10-02 07:56:40 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureChannelizer, Message)
|
2016-04-07 07:05:53 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureDSDDemod, Message)
|
2016-09-28 11:58:29 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureMyPosition, Message)
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2017-11-08 08:23:49 -05:00
|
|
|
const QString DSDDemod::m_channelID = "sdrangel.channel.dsddemod";
|
2017-08-24 02:46:14 -04:00
|
|
|
const int DSDDemod::m_udpBlockSize = 512;
|
|
|
|
|
2017-10-02 07:56:40 -04:00
|
|
|
DSDDemod::DSDDemod(DeviceSourceAPI *deviceAPI) :
|
|
|
|
m_deviceAPI(deviceAPI),
|
2017-11-19 12:18:17 -05:00
|
|
|
m_absoluteFrequencyOffset(0),
|
2017-10-03 18:29:47 -04:00
|
|
|
m_interpolatorDistance(0.0f),
|
|
|
|
m_interpolatorDistanceRemain(0.0f),
|
|
|
|
m_sampleCount(0),
|
|
|
|
m_squelchCount(0),
|
|
|
|
m_squelchGate(0),
|
|
|
|
m_squelchLevel(1e-4),
|
|
|
|
m_squelchOpen(false),
|
2017-05-25 14:13:34 -04:00
|
|
|
m_movingAverage(40, 0),
|
|
|
|
m_fmExcursion(24),
|
2017-10-03 18:29:47 -04:00
|
|
|
m_audioFifo1(48000),
|
2017-08-24 18:02:49 -04:00
|
|
|
m_audioFifo2(48000),
|
2017-10-02 07:56:40 -04:00
|
|
|
m_scope(0),
|
2017-05-25 14:13:34 -04:00
|
|
|
m_scopeEnabled(true),
|
|
|
|
m_dsdDecoder(),
|
|
|
|
m_settingsMutex(QMutex::Recursive)
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
setObjectName("DSDDemod");
|
|
|
|
|
|
|
|
m_audioBuffer.resize(1<<14);
|
|
|
|
m_audioBufferFill = 0;
|
|
|
|
|
2016-04-11 21:32:42 -04:00
|
|
|
m_sampleBuffer = new qint16[1<<17]; // 128 kS
|
|
|
|
m_sampleBufferIndex = 0;
|
|
|
|
|
2016-12-14 12:46:31 -05:00
|
|
|
m_movingAverage.resize(16, 0);
|
2016-12-06 13:06:38 -05:00
|
|
|
m_magsq = 0.0f;
|
|
|
|
m_magsqSum = 0.0f;
|
|
|
|
m_magsqPeak = 0.0f;
|
|
|
|
m_magsqCount = 0;
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2016-09-03 19:06:10 -04:00
|
|
|
DSPEngine::instance()->addAudioSink(&m_audioFifo1);
|
|
|
|
DSPEngine::instance()->addAudioSink(&m_audioFifo2);
|
2017-08-24 02:46:14 -04:00
|
|
|
|
2017-10-03 18:29:47 -04:00
|
|
|
m_udpBufferAudio = new UDPSink<AudioSample>(this, m_udpBlockSize, m_settings.m_udpPort);
|
2017-08-24 07:51:24 -04:00
|
|
|
m_audioFifo1.setUDPSink(m_udpBufferAudio);
|
|
|
|
m_audioFifo2.setUDPSink(m_udpBufferAudio);
|
|
|
|
|
2017-10-02 07:56:40 -04:00
|
|
|
m_channelizer = new DownChannelizer(this);
|
|
|
|
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
|
|
|
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
2017-11-19 05:36:20 -05:00
|
|
|
m_deviceAPI->addChannelAPI(this);
|
2017-10-02 07:56:40 -04:00
|
|
|
|
2017-10-03 18:29:47 -04:00
|
|
|
applySettings(m_settings, true);
|
2016-04-07 07:05:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
DSDDemod::~DSDDemod()
|
|
|
|
{
|
2016-04-11 21:32:42 -04:00
|
|
|
delete[] m_sampleBuffer;
|
2016-09-03 19:06:10 -04:00
|
|
|
DSPEngine::instance()->removeAudioSink(&m_audioFifo1);
|
|
|
|
DSPEngine::instance()->removeAudioSink(&m_audioFifo2);
|
2017-08-25 23:32:01 -04:00
|
|
|
delete m_udpBufferAudio;
|
2017-10-02 07:56:40 -04:00
|
|
|
|
2017-11-19 05:36:20 -05:00
|
|
|
m_deviceAPI->removeChannelAPI(this);
|
2017-10-02 07:56:40 -04:00
|
|
|
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
|
|
|
delete m_threadedChannelizer;
|
|
|
|
delete m_channelizer;
|
2016-04-07 07:05:53 -04:00
|
|
|
}
|
|
|
|
|
2016-09-28 11:58:29 -04:00
|
|
|
void DSDDemod::configureMyPosition(MessageQueue* messageQueue, float myLatitude, float myLongitude)
|
|
|
|
{
|
|
|
|
Message* cmd = MsgConfigureMyPosition::create(myLatitude, myLongitude);
|
|
|
|
messageQueue->push(cmd);
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst __attribute__((unused)))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
Complex ci;
|
2016-04-23 00:27:28 -04:00
|
|
|
int samplesPerSymbol = m_dsdDecoder.getSamplesPerSymbol();
|
2016-04-07 07:05:53 -04:00
|
|
|
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
m_scopeSampleBuffer.clear();
|
|
|
|
|
2016-05-09 03:24:28 -04:00
|
|
|
m_dsdDecoder.enableMbelib(!DSPEngine::instance()->hasDVSerialSupport()); // disable mbelib if DV serial support is present and activated else enable it
|
|
|
|
|
2016-04-07 07:05:53 -04:00
|
|
|
for (SampleVector::const_iterator it = begin; it != end; ++it)
|
|
|
|
{
|
|
|
|
Complex c(it->real(), it->imag());
|
|
|
|
c *= m_nco.nextIQ();
|
|
|
|
|
2016-10-09 19:53:32 -04:00
|
|
|
if (m_interpolator.decimate(&m_interpolatorDistanceRemain, c, &ci))
|
2016-04-09 13:14:19 -04:00
|
|
|
{
|
2016-04-11 21:32:42 -04:00
|
|
|
qint16 sample, delayedSample;
|
2016-04-09 13:14:19 -04:00
|
|
|
|
2016-12-06 13:06:38 -05:00
|
|
|
Real magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())) / (1<<30);
|
2016-12-14 12:46:31 -05:00
|
|
|
m_movingAverage.feed(magsq);
|
2016-12-06 13:06:38 -05:00
|
|
|
|
|
|
|
m_magsqSum += magsq;
|
|
|
|
|
|
|
|
if (magsq > m_magsqPeak)
|
|
|
|
{
|
|
|
|
m_magsqPeak = magsq;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_magsqCount++;
|
2016-04-09 13:14:19 -04:00
|
|
|
|
2017-10-03 18:02:59 -04:00
|
|
|
Real demod = 32768.0f * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_demodGain;
|
2016-04-09 13:14:19 -04:00
|
|
|
m_sampleCount++;
|
|
|
|
|
|
|
|
// AF processing
|
|
|
|
|
2016-12-14 12:46:31 -05:00
|
|
|
if (m_movingAverage.average() > m_squelchLevel)
|
2016-04-09 13:14:19 -04:00
|
|
|
{
|
2016-04-23 00:58:54 -04:00
|
|
|
if (m_squelchGate > 0)
|
2016-04-09 13:14:19 -04:00
|
|
|
{
|
2016-04-23 00:58:54 -04:00
|
|
|
if (m_squelchCount < m_squelchGate) {
|
|
|
|
m_squelchCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_squelchOpen = m_squelchCount == m_squelchGate;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_squelchOpen = true;
|
2016-04-09 13:14:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_squelchCount = 0;
|
2016-04-23 00:58:54 -04:00
|
|
|
m_squelchOpen = false;
|
2016-04-09 13:14:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_squelchOpen)
|
|
|
|
{
|
|
|
|
sample = demod;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sample = 0;
|
|
|
|
}
|
|
|
|
|
2016-08-19 13:30:32 -04:00
|
|
|
m_dsdDecoder.pushSample(sample);
|
|
|
|
|
2017-10-03 18:02:59 -04:00
|
|
|
if (m_settings.m_enableCosineFiltering) { // show actual input to FSK demod
|
2016-08-19 13:30:32 -04:00
|
|
|
sample = m_dsdDecoder.getFilteredSample();
|
|
|
|
}
|
|
|
|
|
2016-04-11 21:32:42 -04:00
|
|
|
if (m_sampleBufferIndex < (1<<17)) {
|
|
|
|
m_sampleBufferIndex++;
|
|
|
|
} else {
|
|
|
|
m_sampleBufferIndex = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sampleBuffer[m_sampleBufferIndex] = sample;
|
|
|
|
|
2016-04-23 00:27:28 -04:00
|
|
|
if (m_sampleBufferIndex < samplesPerSymbol) {
|
|
|
|
delayedSample = m_sampleBuffer[(1<<17) - samplesPerSymbol + m_sampleBufferIndex]; // wrap
|
2016-04-11 21:32:42 -04:00
|
|
|
} else {
|
2016-04-23 00:27:28 -04:00
|
|
|
delayedSample = m_sampleBuffer[m_sampleBufferIndex - samplesPerSymbol];
|
2016-04-11 21:32:42 -04:00
|
|
|
}
|
|
|
|
|
2017-10-03 18:02:59 -04:00
|
|
|
if (m_settings.m_syncOrConstellation)
|
2016-08-24 19:06:42 -04:00
|
|
|
{
|
|
|
|
Sample s(sample, m_dsdDecoder.getSymbolSyncSample());
|
|
|
|
m_scopeSampleBuffer.push_back(s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sample s(sample, delayedSample); // I=signal, Q=signal delayed by 20 samples (2400 baud: lowest rate)
|
|
|
|
m_scopeSampleBuffer.push_back(s);
|
|
|
|
}
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2016-09-03 19:06:10 -04:00
|
|
|
if (DSPEngine::instance()->hasDVSerialSupport())
|
2016-05-09 04:13:11 -04:00
|
|
|
{
|
2017-10-03 18:02:59 -04:00
|
|
|
if ((m_settings.m_slot1On) && m_dsdDecoder.mbeDVReady1())
|
2016-09-03 19:06:10 -04:00
|
|
|
{
|
2017-10-03 18:02:59 -04:00
|
|
|
if (!m_settings.m_audioMute)
|
2016-09-06 18:47:51 -04:00
|
|
|
{
|
|
|
|
DSPEngine::instance()->pushMbeFrame(
|
|
|
|
m_dsdDecoder.getMbeDVFrame1(),
|
|
|
|
m_dsdDecoder.getMbeRateIndex(),
|
2017-10-06 23:06:44 -04:00
|
|
|
m_settings.m_volume * 10.0,
|
2017-10-03 18:02:59 -04:00
|
|
|
m_settings.m_tdmaStereo ? 1 : 3, // left or both channels
|
2016-09-06 18:47:51 -04:00
|
|
|
&m_audioFifo1);
|
2016-09-03 19:06:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_dsdDecoder.resetMbeDV1();
|
|
|
|
}
|
|
|
|
|
2017-10-03 18:02:59 -04:00
|
|
|
if ((m_settings.m_slot2On) && m_dsdDecoder.mbeDVReady2())
|
2016-09-03 19:06:10 -04:00
|
|
|
{
|
2017-10-03 18:02:59 -04:00
|
|
|
if (!m_settings.m_audioMute)
|
2016-09-06 18:47:51 -04:00
|
|
|
{
|
|
|
|
DSPEngine::instance()->pushMbeFrame(
|
|
|
|
m_dsdDecoder.getMbeDVFrame2(),
|
|
|
|
m_dsdDecoder.getMbeRateIndex(),
|
2017-10-06 23:06:44 -04:00
|
|
|
m_settings.m_volume * 10.0,
|
2017-10-03 18:02:59 -04:00
|
|
|
m_settings.m_tdmaStereo ? 2 : 3, // right or both channels
|
2016-09-06 18:47:51 -04:00
|
|
|
&m_audioFifo2);
|
2016-09-03 19:06:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_dsdDecoder.resetMbeDV2();
|
2016-05-10 02:27:54 -04:00
|
|
|
}
|
2016-05-09 04:13:11 -04:00
|
|
|
}
|
|
|
|
|
2016-09-03 19:06:10 -04:00
|
|
|
// if (DSPEngine::instance()->hasDVSerialSupport() && m_dsdDecoder.mbeDVReady1())
|
|
|
|
// {
|
2017-10-03 18:02:59 -04:00
|
|
|
// if (!m_settings.m_audioMute)
|
2016-09-03 19:06:10 -04:00
|
|
|
// {
|
2017-10-03 18:02:59 -04:00
|
|
|
// DSPEngine::instance()->pushMbeFrame(m_dsdDecoder.getMbeDVFrame1(), m_dsdDecoder.getMbeRateIndex(), m_settings.m_volume, &m_audioFifo1);
|
2016-09-03 19:06:10 -04:00
|
|
|
// }
|
|
|
|
//
|
|
|
|
// m_dsdDecoder.resetMbeDV1();
|
|
|
|
// }
|
|
|
|
|
2016-04-09 13:14:19 -04:00
|
|
|
m_interpolatorDistanceRemain += m_interpolatorDistance;
|
|
|
|
}
|
2016-04-07 07:05:53 -04:00
|
|
|
}
|
|
|
|
|
2016-05-09 04:13:11 -04:00
|
|
|
if (!DSPEngine::instance()->hasDVSerialSupport())
|
2016-05-08 00:00:37 -04:00
|
|
|
{
|
2017-10-03 18:02:59 -04:00
|
|
|
if (m_settings.m_slot1On)
|
2016-05-08 00:00:37 -04:00
|
|
|
{
|
2016-09-03 19:06:10 -04:00
|
|
|
int nbAudioSamples;
|
|
|
|
short *dsdAudio = m_dsdDecoder.getAudio1(nbAudioSamples);
|
2016-05-08 00:00:37 -04:00
|
|
|
|
2016-09-03 19:06:10 -04:00
|
|
|
if (nbAudioSamples > 0)
|
|
|
|
{
|
2017-10-03 18:02:59 -04:00
|
|
|
if (!m_settings.m_audioMute) {
|
2017-05-25 14:13:34 -04:00
|
|
|
m_audioFifo1.write((const quint8*) dsdAudio, nbAudioSamples, 10);
|
2016-09-03 19:06:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_dsdDecoder.resetAudio1();
|
|
|
|
}
|
2016-05-08 00:00:37 -04:00
|
|
|
}
|
2016-09-03 19:06:10 -04:00
|
|
|
|
2017-10-03 18:02:59 -04:00
|
|
|
if (m_settings.m_slot2On)
|
2016-09-03 19:06:10 -04:00
|
|
|
{
|
|
|
|
int nbAudioSamples;
|
|
|
|
short *dsdAudio = m_dsdDecoder.getAudio2(nbAudioSamples);
|
|
|
|
|
|
|
|
if (nbAudioSamples > 0)
|
|
|
|
{
|
2017-10-03 18:02:59 -04:00
|
|
|
if (!m_settings.m_audioMute) {
|
2017-05-25 14:13:34 -04:00
|
|
|
m_audioFifo2.write((const quint8*) dsdAudio, nbAudioSamples, 10);
|
2016-09-03 19:06:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_dsdDecoder.resetAudio2();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// int nbAudioSamples;
|
|
|
|
// short *dsdAudio = m_dsdDecoder.getAudio1(nbAudioSamples);
|
|
|
|
//
|
|
|
|
// if (nbAudioSamples > 0)
|
|
|
|
// {
|
2017-10-03 18:02:59 -04:00
|
|
|
// if (!m_settings.m_audioMute) {
|
2016-09-03 19:06:10 -04:00
|
|
|
// uint res = m_audioFifo1.write((const quint8*) dsdAudio, nbAudioSamples, 10);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// m_dsdDecoder.resetAudio1();
|
|
|
|
// }
|
2016-04-21 21:53:16 -04:00
|
|
|
}
|
2016-04-11 21:32:42 -04:00
|
|
|
|
2016-05-08 00:00:37 -04:00
|
|
|
|
2016-04-09 13:14:19 -04:00
|
|
|
if ((m_scope != 0) && (m_scopeEnabled))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
m_scope->feed(m_scopeSampleBuffer.begin(), m_scopeSampleBuffer.end(), true); // true = real samples for what it's worth
|
|
|
|
}
|
|
|
|
|
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemod::start()
|
|
|
|
{
|
2016-09-03 19:06:10 -04:00
|
|
|
m_audioFifo1.clear();
|
|
|
|
m_audioFifo2.clear();
|
2016-04-07 07:05:53 -04:00
|
|
|
m_phaseDiscri.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemod::stop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DSDDemod::handleMessage(const Message& cmd)
|
|
|
|
{
|
|
|
|
qDebug() << "DSDDemod::handleMessage";
|
|
|
|
|
2016-10-02 15:52:39 -04:00
|
|
|
if (DownChannelizer::MsgChannelizerNotification::match(cmd))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
2016-10-02 15:52:39 -04:00
|
|
|
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2017-10-03 18:29:47 -04:00
|
|
|
DSDDemodSettings settings = m_settings;
|
|
|
|
settings.m_inputSampleRate = notif.getSampleRate();
|
|
|
|
settings.m_inputFrequencyOffset = notif.getFrequencyOffset();
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2017-10-03 18:29:47 -04:00
|
|
|
applySettings(settings);
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2017-10-03 18:29:47 -04:00
|
|
|
qDebug() << "DSDDemod::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << settings.m_inputSampleRate
|
|
|
|
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset;
|
2016-04-07 07:05:53 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-02 07:56:40 -04:00
|
|
|
else if (MsgConfigureChannelizer::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
|
|
|
|
|
|
|
|
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
|
|
|
cfg.getSampleRate(),
|
|
|
|
cfg.getCenterFrequency());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-03 18:02:59 -04:00
|
|
|
else if (MsgConfigureDSDDemod::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureDSDDemod& cfg = (MsgConfigureDSDDemod&) cmd;
|
|
|
|
|
|
|
|
DSDDemodSettings settings = cfg.getSettings();
|
|
|
|
|
|
|
|
// These settings are set with DownChannelizer::MsgChannelizerNotification
|
2017-11-19 12:18:17 -05:00
|
|
|
m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset;
|
2017-10-03 18:02:59 -04:00
|
|
|
settings.m_inputSampleRate = m_settings.m_inputSampleRate;
|
|
|
|
settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset;
|
|
|
|
|
|
|
|
applySettings(settings, cfg.getForce());
|
|
|
|
|
|
|
|
qDebug() << "DSDDemod::handleMessage: MsgConfigureDSDDemod: m_rfBandwidth: " << m_settings.m_rfBandwidth
|
|
|
|
<< " m_fmDeviation: " << m_settings.m_fmDeviation
|
|
|
|
<< " m_demodGain: " << m_settings.m_demodGain
|
|
|
|
<< " m_volume: " << m_settings.m_volume
|
|
|
|
<< " m_baudRate: " << m_settings.m_baudRate
|
|
|
|
<< " m_squelchGate" << m_settings.m_squelchGate
|
|
|
|
<< " m_squelch: " << m_settings.m_squelch
|
|
|
|
<< " m_audioMute: " << m_settings.m_audioMute
|
|
|
|
<< " m_enableCosineFiltering: " << m_settings.m_enableCosineFiltering
|
|
|
|
<< " m_syncOrConstellation: " << m_settings.m_syncOrConstellation
|
|
|
|
<< " m_slot1On: " << m_settings.m_slot1On
|
|
|
|
<< " m_slot2On: " << m_settings.m_slot2On
|
|
|
|
<< " m_tdmaStereo: " << m_settings.m_tdmaStereo
|
|
|
|
<< " m_pllLock: " << m_settings.m_pllLock
|
|
|
|
<< " m_udpCopyAudio: " << m_settings.m_udpCopyAudio
|
|
|
|
<< " m_udpAddress: " << m_settings.m_udpAddress
|
|
|
|
<< " m_udpPort: " << m_settings.m_udpPort
|
|
|
|
<< " force: " << cfg.getForce();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-28 11:58:29 -04:00
|
|
|
else if (MsgConfigureMyPosition::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureMyPosition& cfg = (MsgConfigureMyPosition&) cmd;
|
|
|
|
m_dsdDecoder.setMyPoint(cfg.getMyLatitude(), cfg.getMyLongitude());
|
|
|
|
return true;
|
|
|
|
}
|
2016-04-07 07:05:53 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-03 18:02:59 -04:00
|
|
|
void DSDDemod::applySettings(DSDDemodSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) ||
|
|
|
|
(settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force)
|
|
|
|
{
|
|
|
|
m_nco.setFreq(-settings.m_inputFrequencyOffset, settings.m_inputSampleRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) ||
|
|
|
|
(settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force)
|
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
m_interpolator.create(16, settings.m_inputSampleRate, (settings.m_rfBandwidth) / 2.2);
|
|
|
|
m_interpolatorDistanceRemain = 0;
|
|
|
|
m_interpolatorDistance = (Real) settings.m_inputSampleRate / (Real) settings.m_audioSampleRate;
|
|
|
|
m_phaseDiscri.setFMScaling((float) settings.m_rfBandwidth / (float) settings.m_fmDeviation);
|
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force)
|
|
|
|
{
|
|
|
|
m_phaseDiscri.setFMScaling((float) settings.m_rfBandwidth / (float) settings.m_fmDeviation);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_squelchGate != m_settings.m_squelchGate) || force)
|
|
|
|
{
|
|
|
|
m_squelchGate = 480 * settings.m_squelchGate; // gate is given in 10s of ms at 48000 Hz audio sample rate
|
|
|
|
m_squelchCount = 0; // reset squelch open counter
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_squelch != m_settings.m_squelch) || force)
|
|
|
|
{
|
|
|
|
// input is a value in dB
|
|
|
|
m_squelchLevel = std::pow(10.0, settings.m_squelch / 10.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_volume != m_settings.m_volume) || force)
|
|
|
|
{
|
|
|
|
m_dsdDecoder.setAudioGain(settings.m_volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_baudRate != m_settings.m_baudRate) || force)
|
|
|
|
{
|
|
|
|
m_dsdDecoder.setBaudRate(settings.m_baudRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_enableCosineFiltering != m_settings.m_enableCosineFiltering) || force)
|
|
|
|
{
|
|
|
|
m_dsdDecoder.enableCosineFiltering(settings.m_enableCosineFiltering);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_tdmaStereo != m_settings.m_tdmaStereo) || force)
|
|
|
|
{
|
|
|
|
m_dsdDecoder.setTDMAStereo(settings.m_tdmaStereo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_pllLock != m_settings.m_pllLock) || force)
|
|
|
|
{
|
|
|
|
m_dsdDecoder.setSymbolPLLLock(settings.m_pllLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_udpAddress != m_settings.m_udpAddress)
|
|
|
|
|| (settings.m_udpPort != m_settings.m_udpPort) || force)
|
|
|
|
{
|
|
|
|
m_udpBufferAudio->setAddress(settings.m_udpAddress);
|
|
|
|
m_udpBufferAudio->setPort(settings.m_udpPort);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_udpCopyAudio != m_settings.m_udpCopyAudio)
|
|
|
|
|| (settings.m_slot1On != m_settings.m_slot1On)
|
|
|
|
|| (settings.m_slot2On != m_settings.m_slot2On) || force)
|
|
|
|
{
|
|
|
|
m_audioFifo1.setCopyToUDP(settings.m_slot1On && settings.m_udpCopyAudio);
|
|
|
|
m_audioFifo2.setCopyToUDP(settings.m_slot2On && !settings.m_slot1On && settings.m_udpCopyAudio);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_settings = settings;
|
|
|
|
}
|