2015-12-06 04:30:51 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2015-12-06 13:47:55 -05:00
|
|
|
// Copyright (C) 2015 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
2015-12-06 04:30:51 -05: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
|
|
|
#include "../../channelrx/demodbfm/bfmdemod.h"
|
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
#include <QTime>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <complex.h>
|
|
|
|
#include "audio/audiooutput.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/pidcontroller.h"
|
|
|
|
#include "bfmdemod.h"
|
|
|
|
|
2016-10-02 15:52:39 -04:00
|
|
|
#include <dsp/downchannelizer.h>
|
|
|
|
|
2016-10-02 07:18:07 -04:00
|
|
|
#include "../../channelrx/demodbfm/rdsparser.h"
|
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(BFMDemod::MsgConfigureBFMDemod, Message)
|
|
|
|
|
2016-03-21 03:40:42 -04:00
|
|
|
const Real BFMDemod::default_deemphasis = 50.0; // 50 us
|
|
|
|
|
2016-10-02 16:29:04 -04:00
|
|
|
BFMDemod::BFMDemod(BasebandSampleSink* sampleSink, RDSParser *rdsParser) :
|
2015-12-06 04:30:51 -05:00
|
|
|
m_sampleSink(sampleSink),
|
2015-12-13 03:45:29 -05:00
|
|
|
m_rdsParser(rdsParser),
|
2015-12-06 04:30:51 -05:00
|
|
|
m_audioFifo(4, 250000),
|
2015-12-06 20:18:31 -05:00
|
|
|
m_settingsMutex(QMutex::Recursive),
|
2015-12-07 20:00:30 -05:00
|
|
|
m_pilotPLL(19000/384000, 50/384000, 0.01),
|
|
|
|
m_deemphasisFilterX(default_deemphasis * 48000 * 1.0e-6),
|
2015-12-11 20:17:41 -05:00
|
|
|
m_deemphasisFilterY(default_deemphasis * 48000 * 1.0e-6),
|
2015-12-16 19:13:42 -05:00
|
|
|
m_fmExcursion(default_excursion)
|
2015-12-06 04:30:51 -05:00
|
|
|
{
|
|
|
|
setObjectName("BFMDemod");
|
|
|
|
|
|
|
|
m_config.m_inputSampleRate = 384000;
|
|
|
|
m_config.m_inputFrequencyOffset = 0;
|
|
|
|
m_config.m_rfBandwidth = 180000;
|
|
|
|
m_config.m_afBandwidth = 15000;
|
|
|
|
m_config.m_squelch = -60.0;
|
|
|
|
m_config.m_volume = 2.0;
|
2015-12-06 13:47:55 -05:00
|
|
|
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); // normally 48 kHz
|
2015-12-07 20:00:30 -05:00
|
|
|
m_deemphasisFilterX.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6);
|
|
|
|
m_deemphasisFilterY.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6);
|
2015-12-25 18:19:41 -05:00
|
|
|
m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, filtFftLen);
|
2015-12-16 19:13:42 -05:00
|
|
|
m_phaseDiscri.setFMScaling(384000/m_fmExcursion);
|
2015-12-06 04:30:51 -05:00
|
|
|
|
|
|
|
apply();
|
|
|
|
|
|
|
|
m_audioBuffer.resize(16384);
|
|
|
|
m_audioBufferFill = 0;
|
|
|
|
|
|
|
|
m_movingAverage.resize(16, 0);
|
|
|
|
|
|
|
|
DSPEngine::instance()->addAudioSink(&m_audioFifo);
|
|
|
|
}
|
|
|
|
|
|
|
|
BFMDemod::~BFMDemod()
|
|
|
|
{
|
|
|
|
if (m_rfFilter)
|
|
|
|
{
|
|
|
|
delete m_rfFilter;
|
|
|
|
}
|
|
|
|
|
|
|
|
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
|
|
|
|
}
|
|
|
|
|
2015-12-08 18:04:46 -05:00
|
|
|
void BFMDemod::configure(MessageQueue* messageQueue,
|
|
|
|
Real rfBandwidth,
|
|
|
|
Real afBandwidth,
|
|
|
|
Real volume,
|
|
|
|
Real squelch,
|
|
|
|
bool audioStereo,
|
2015-12-25 18:19:41 -05:00
|
|
|
bool lsbStereo,
|
2015-12-08 22:13:13 -05:00
|
|
|
bool showPilot,
|
|
|
|
bool rdsActive)
|
2015-12-06 04:30:51 -05:00
|
|
|
{
|
2015-12-08 22:13:13 -05:00
|
|
|
Message* cmd = MsgConfigureBFMDemod::create(rfBandwidth,
|
|
|
|
afBandwidth,
|
|
|
|
volume,
|
|
|
|
squelch,
|
|
|
|
audioStereo,
|
2015-12-25 18:19:41 -05:00
|
|
|
lsbStereo,
|
2015-12-08 22:13:13 -05:00
|
|
|
showPilot,
|
|
|
|
rdsActive);
|
2015-12-06 04:30:51 -05:00
|
|
|
messageQueue->push(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
|
|
|
|
{
|
2015-12-12 09:14:26 -05:00
|
|
|
Complex ci, cs, cr;
|
2015-12-06 04:30:51 -05:00
|
|
|
fftfilt::cmplx *rf;
|
|
|
|
int rf_out;
|
|
|
|
Real msq, demod;
|
|
|
|
|
2015-12-06 13:47:55 -05:00
|
|
|
m_sampleBuffer.clear();
|
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
m_settingsMutex.lock();
|
|
|
|
|
|
|
|
for (SampleVector::const_iterator it = begin; it != end; ++it)
|
|
|
|
{
|
|
|
|
Complex c(it->real() / 32768.0f, it->imag() / 32768.0f);
|
|
|
|
c *= m_nco.nextIQ();
|
|
|
|
|
|
|
|
rf_out = m_rfFilter->runFilt(c, &rf); // filter RF before demod
|
|
|
|
|
|
|
|
for (int i =0 ; i <rf_out; i++)
|
|
|
|
{
|
|
|
|
msq = rf[i].real()*rf[i].real() + rf[i].imag()*rf[i].imag();
|
|
|
|
|
|
|
|
m_movingAverage.feed(msq);
|
|
|
|
|
|
|
|
if(m_movingAverage.average() >= m_squelchLevel)
|
|
|
|
m_squelchState = m_running.m_rfBandwidth / 20; // decay rate
|
|
|
|
|
|
|
|
if(m_squelchState > 0)
|
|
|
|
{
|
|
|
|
m_squelchState--;
|
|
|
|
|
2015-12-11 20:17:41 -05:00
|
|
|
//demod = phaseDiscriminator2(rf[i], msq);
|
2015-12-16 19:13:42 -05:00
|
|
|
demod = m_phaseDiscri.phaseDiscriminator(rf[i]);
|
2015-12-06 04:30:51 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
demod = 0;
|
|
|
|
}
|
|
|
|
|
2015-12-08 18:04:46 -05:00
|
|
|
if (!m_running.m_showPilot)
|
|
|
|
{
|
|
|
|
m_sampleBuffer.push_back(Sample(demod * (1<<15), 0.0));
|
|
|
|
}
|
|
|
|
|
2015-12-10 08:10:48 -05:00
|
|
|
if (m_running.m_rdsActive)
|
|
|
|
{
|
2015-12-25 18:19:41 -05:00
|
|
|
//Complex r(demod * 2.0 * std::cos(3.0 * m_pilotPLLSamples[3]), 0.0);
|
|
|
|
Complex r(demod * 2.0 * std::cos(3.0 * m_pilotPLLSamples[3]), 0.0);
|
2015-12-12 09:14:26 -05:00
|
|
|
|
2016-10-09 19:53:32 -04:00
|
|
|
if (m_interpolatorRDS.decimate(&m_interpolatorRDSDistanceRemain, r, &cr))
|
2015-12-12 09:14:26 -05:00
|
|
|
{
|
2015-12-12 20:54:22 -05:00
|
|
|
bool bit;
|
|
|
|
|
|
|
|
if (m_rdsDemod.process(cr.real(), bit))
|
|
|
|
{
|
2015-12-13 03:45:29 -05:00
|
|
|
if (m_rdsDecoder.frameSync(bit))
|
|
|
|
{
|
|
|
|
if (m_rdsParser)
|
|
|
|
{
|
|
|
|
m_rdsParser->parseGroup(m_rdsDecoder.getGroup());
|
|
|
|
}
|
|
|
|
}
|
2015-12-12 20:54:22 -05:00
|
|
|
}
|
|
|
|
|
2015-12-12 09:14:26 -05:00
|
|
|
m_interpolatorRDSDistanceRemain += m_interpolatorRDSDistance;
|
|
|
|
}
|
2015-12-10 08:10:48 -05:00
|
|
|
}
|
|
|
|
|
2015-12-07 20:00:30 -05:00
|
|
|
Real sampleStereo;
|
2015-12-06 22:16:05 -05:00
|
|
|
|
2015-12-07 02:55:22 -05:00
|
|
|
// Process stereo if stereo mode is selected
|
|
|
|
|
|
|
|
if (m_running.m_audioStereo)
|
2015-12-06 22:16:05 -05:00
|
|
|
{
|
2015-12-07 16:31:44 -05:00
|
|
|
m_pilotPLL.process(demod, m_pilotPLLSamples);
|
2015-12-08 18:04:46 -05:00
|
|
|
|
|
|
|
if (m_running.m_showPilot)
|
|
|
|
{
|
2015-12-10 08:10:48 -05:00
|
|
|
m_sampleBuffer.push_back(Sample(m_pilotPLLSamples[1] * (1<<15), 0.0)); // debug 38 kHz pilot
|
2015-12-08 18:04:46 -05:00
|
|
|
}
|
2015-12-07 02:55:22 -05:00
|
|
|
|
2015-12-25 18:19:41 -05:00
|
|
|
if (m_running.m_lsbStereo)
|
|
|
|
{
|
|
|
|
// 1.17 * 0.7 = 0.819
|
|
|
|
Complex s(demod * m_pilotPLLSamples[1], demod * m_pilotPLLSamples[2]);
|
2015-12-06 22:16:05 -05:00
|
|
|
|
2016-10-09 19:53:32 -04:00
|
|
|
if (m_interpolatorStereo.decimate(&m_interpolatorStereoDistanceRemain, s, &cs))
|
2015-12-25 18:19:41 -05:00
|
|
|
{
|
|
|
|
sampleStereo = cs.real() + cs.imag();
|
|
|
|
m_interpolatorStereoDistanceRemain += m_interpolatorStereoDistance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-12-07 02:55:22 -05:00
|
|
|
{
|
2015-12-25 18:19:41 -05:00
|
|
|
Complex s(demod * 1.17 * m_pilotPLLSamples[1], 0);
|
|
|
|
|
2016-10-09 19:53:32 -04:00
|
|
|
if (m_interpolatorStereo.decimate(&m_interpolatorStereoDistanceRemain, s, &cs))
|
2015-12-25 18:19:41 -05:00
|
|
|
{
|
|
|
|
sampleStereo = cs.real();
|
|
|
|
m_interpolatorStereoDistanceRemain += m_interpolatorStereoDistance;
|
|
|
|
}
|
2015-12-07 02:55:22 -05:00
|
|
|
}
|
|
|
|
}
|
2015-12-06 22:16:05 -05:00
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
Complex e(demod, 0);
|
|
|
|
|
2016-10-09 19:53:32 -04:00
|
|
|
if (m_interpolator.decimate(&m_interpolatorDistanceRemain, e, &ci))
|
2015-12-06 04:30:51 -05:00
|
|
|
{
|
2015-12-07 02:55:22 -05:00
|
|
|
if (m_running.m_audioStereo)
|
|
|
|
{
|
2015-12-07 20:00:30 -05:00
|
|
|
Real deemph_l, deemph_r; // Pre-emphasis is applied on each channel before multiplexing
|
|
|
|
m_deemphasisFilterX.process(ci.real() + sampleStereo, deemph_l);
|
|
|
|
m_deemphasisFilterY.process(ci.real() - sampleStereo, deemph_r);
|
2015-12-25 18:19:41 -05:00
|
|
|
if (m_running.m_lsbStereo)
|
|
|
|
{
|
|
|
|
m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_running.m_volume);
|
|
|
|
m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_running.m_volume);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_running.m_volume);
|
|
|
|
m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_running.m_volume);
|
|
|
|
}
|
2015-12-07 02:55:22 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-07 20:00:30 -05:00
|
|
|
Real deemph;
|
2015-12-08 02:30:45 -05:00
|
|
|
m_deemphasisFilterX.process(ci.real(), deemph);
|
2015-12-11 20:17:41 -05:00
|
|
|
quint16 sample = (qint16)(deemph * (1<<12) * m_running.m_volume);
|
2015-12-07 02:55:22 -05:00
|
|
|
m_audioBuffer[m_audioBufferFill].l = sample;
|
|
|
|
m_audioBuffer[m_audioBufferFill].r = sample;
|
|
|
|
}
|
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
++m_audioBufferFill;
|
|
|
|
|
|
|
|
if(m_audioBufferFill >= m_audioBuffer.size())
|
|
|
|
{
|
|
|
|
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
|
|
|
|
|
|
|
|
if(res != m_audioBufferFill)
|
|
|
|
{
|
|
|
|
qDebug("BFMDemod::feed: %u/%u audio samples written", res, m_audioBufferFill);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_audioBufferFill = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_interpolatorDistanceRemain += m_interpolatorDistance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_audioBufferFill > 0)
|
|
|
|
{
|
|
|
|
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
|
|
|
|
|
|
|
|
if(res != m_audioBufferFill)
|
|
|
|
{
|
|
|
|
qDebug("BFMDemod::feed: %u/%u tail samples written", res, m_audioBufferFill);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_audioBufferFill = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_sampleSink != 0)
|
|
|
|
{
|
2015-12-06 13:47:55 -05:00
|
|
|
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
|
2015-12-06 04:30:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_sampleBuffer.clear();
|
|
|
|
|
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BFMDemod::start()
|
|
|
|
{
|
|
|
|
m_squelchState = 0;
|
|
|
|
m_audioFifo.clear();
|
2015-12-16 19:13:42 -05:00
|
|
|
m_phaseDiscri.reset();
|
2015-12-06 04:30:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void BFMDemod::stop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BFMDemod::handleMessage(const Message& cmd)
|
|
|
|
{
|
2016-10-02 15:52:39 -04:00
|
|
|
if (DownChannelizer::MsgChannelizerNotification::match(cmd))
|
2015-12-06 04:30:51 -05:00
|
|
|
{
|
2016-10-02 15:52:39 -04:00
|
|
|
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
2015-12-06 04:30:51 -05:00
|
|
|
|
|
|
|
m_config.m_inputSampleRate = notif.getSampleRate();
|
|
|
|
m_config.m_inputFrequencyOffset = notif.getFrequencyOffset();
|
|
|
|
|
|
|
|
apply();
|
|
|
|
|
|
|
|
qDebug() << "BFMDemod::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << m_config.m_inputSampleRate
|
|
|
|
<< " m_inputFrequencyOffset: " << m_config.m_inputFrequencyOffset;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureBFMDemod::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureBFMDemod& cfg = (MsgConfigureBFMDemod&) cmd;
|
|
|
|
|
|
|
|
m_config.m_rfBandwidth = cfg.getRFBandwidth();
|
|
|
|
m_config.m_afBandwidth = cfg.getAFBandwidth();
|
|
|
|
m_config.m_volume = cfg.getVolume();
|
|
|
|
m_config.m_squelch = cfg.getSquelch();
|
2015-12-07 02:55:22 -05:00
|
|
|
m_config.m_audioStereo = cfg.getAudioStereo();
|
2015-12-25 18:19:41 -05:00
|
|
|
m_config.m_lsbStereo = cfg.getLsbStereo();
|
2015-12-08 18:04:46 -05:00
|
|
|
m_config.m_showPilot = cfg.getShowPilot();
|
2015-12-08 22:13:13 -05:00
|
|
|
m_config.m_rdsActive = cfg.getRDSActive();
|
2015-12-06 04:30:51 -05:00
|
|
|
|
|
|
|
apply();
|
|
|
|
|
|
|
|
qDebug() << "BFMDemod::handleMessage: MsgConfigureBFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth
|
|
|
|
<< " m_afBandwidth: " << m_config.m_afBandwidth
|
|
|
|
<< " m_volume: " << m_config.m_volume
|
2015-12-07 02:55:22 -05:00
|
|
|
<< " m_squelch: " << m_config.m_squelch
|
2015-12-08 18:04:46 -05:00
|
|
|
<< " m_audioStereo: " << m_config.m_audioStereo
|
2015-12-25 18:19:41 -05:00
|
|
|
<< " m_lsbStereo: " << m_config.m_lsbStereo
|
2015-12-08 22:13:13 -05:00
|
|
|
<< " m_showPilot: " << m_config.m_showPilot
|
|
|
|
<< " m_rdsActive: " << m_config.m_rdsActive;
|
2015-12-06 04:30:51 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-11 20:17:41 -05:00
|
|
|
qDebug() << "BFMDemod::handleMessage: none";
|
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
if (m_sampleSink != 0)
|
|
|
|
{
|
|
|
|
return m_sampleSink->handleMessage(cmd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BFMDemod::apply()
|
|
|
|
{
|
2015-12-07 02:55:22 -05:00
|
|
|
if ((m_config.m_inputSampleRate != m_running.m_inputSampleRate)
|
|
|
|
|| (m_config.m_audioStereo && (m_config.m_audioStereo != m_running.m_audioStereo)))
|
2015-12-06 20:18:31 -05:00
|
|
|
{
|
|
|
|
m_pilotPLL.configure(19000.0/m_config.m_inputSampleRate, 50.0/m_config.m_inputSampleRate, 0.01);
|
|
|
|
}
|
2015-12-06 04:30:51 -05:00
|
|
|
|
|
|
|
if((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) ||
|
|
|
|
(m_config.m_inputSampleRate != m_running.m_inputSampleRate))
|
|
|
|
{
|
|
|
|
qDebug() << "BFMDemod::handleMessage: m_nco.setFreq";
|
|
|
|
m_nco.setFreq(-m_config.m_inputFrequencyOffset, m_config.m_inputSampleRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if((m_config.m_inputSampleRate != m_running.m_inputSampleRate) ||
|
|
|
|
(m_config.m_afBandwidth != m_running.m_afBandwidth))
|
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
qDebug() << "BFMDemod::handleMessage: m_interpolator.create";
|
2015-12-12 09:14:26 -05:00
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_afBandwidth);
|
|
|
|
m_interpolatorDistanceRemain = (Real) m_config.m_inputSampleRate / m_config.m_audioSampleRate;
|
|
|
|
m_interpolatorDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_audioSampleRate;
|
2015-12-12 09:14:26 -05:00
|
|
|
|
2015-12-06 22:16:05 -05:00
|
|
|
m_interpolatorStereo.create(16, m_config.m_inputSampleRate, m_config.m_afBandwidth);
|
|
|
|
m_interpolatorStereoDistanceRemain = (Real) m_config.m_inputSampleRate / m_config.m_audioSampleRate;
|
|
|
|
m_interpolatorStereoDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_audioSampleRate;
|
2015-12-12 09:14:26 -05:00
|
|
|
|
|
|
|
m_interpolatorRDS.create(4, m_config.m_inputSampleRate, 600.0);
|
|
|
|
m_interpolatorRDSDistanceRemain = (Real) m_config.m_inputSampleRate / 250000.0;
|
|
|
|
m_interpolatorRDSDistance = (Real) m_config.m_inputSampleRate / 250000.0;
|
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
if((m_config.m_inputSampleRate != m_running.m_inputSampleRate) ||
|
|
|
|
(m_config.m_rfBandwidth != m_running.m_rfBandwidth) ||
|
|
|
|
(m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset))
|
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
Real lowCut = -(m_config.m_rfBandwidth / 2.0) / m_config.m_inputSampleRate;
|
|
|
|
Real hiCut = (m_config.m_rfBandwidth / 2.0) / m_config.m_inputSampleRate;
|
|
|
|
m_rfFilter->create_filter(lowCut, hiCut);
|
2015-12-16 19:13:42 -05:00
|
|
|
m_phaseDiscri.setFMScaling(m_config.m_inputSampleRate / m_fmExcursion);
|
2015-12-06 04:30:51 -05:00
|
|
|
m_settingsMutex.unlock();
|
2015-12-06 13:47:55 -05:00
|
|
|
|
|
|
|
qDebug() << "BFMDemod::handleMessage: m_rfFilter->create_filter: sampleRate: "
|
|
|
|
<< m_config.m_inputSampleRate
|
|
|
|
<< " lowCut: " << lowCut * m_config.m_inputSampleRate
|
|
|
|
<< " hiCut: " << hiCut * m_config.m_inputSampleRate;
|
2015-12-06 04:30:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if((m_config.m_afBandwidth != m_running.m_afBandwidth) ||
|
|
|
|
(m_config.m_audioSampleRate != m_running.m_audioSampleRate))
|
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
qDebug() << "BFMDemod::handleMessage: m_lowpass.create";
|
|
|
|
m_lowpass.create(21, m_config.m_audioSampleRate, m_config.m_afBandwidth);
|
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_config.m_squelch != m_running.m_squelch) {
|
|
|
|
qDebug() << "BFMDemod::handleMessage: set m_squelchLevel";
|
2015-12-11 20:17:41 -05:00
|
|
|
m_squelchLevel = std::pow(10.0, m_config.m_squelch / 20.0);
|
2015-12-06 04:30:51 -05:00
|
|
|
m_squelchLevel *= m_squelchLevel;
|
|
|
|
}
|
|
|
|
|
2015-12-07 20:00:30 -05:00
|
|
|
if (m_config.m_audioSampleRate != m_running.m_audioSampleRate)
|
|
|
|
{
|
|
|
|
m_deemphasisFilterX.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6);
|
|
|
|
m_deemphasisFilterY.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6);
|
|
|
|
}
|
|
|
|
|
2015-12-06 04:30:51 -05:00
|
|
|
m_running.m_inputSampleRate = m_config.m_inputSampleRate;
|
|
|
|
m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset;
|
|
|
|
m_running.m_rfBandwidth = m_config.m_rfBandwidth;
|
|
|
|
m_running.m_afBandwidth = m_config.m_afBandwidth;
|
|
|
|
m_running.m_squelch = m_config.m_squelch;
|
|
|
|
m_running.m_volume = m_config.m_volume;
|
|
|
|
m_running.m_audioSampleRate = m_config.m_audioSampleRate;
|
2015-12-07 02:55:22 -05:00
|
|
|
m_running.m_audioStereo = m_config.m_audioStereo;
|
2015-12-25 18:19:41 -05:00
|
|
|
m_running.m_lsbStereo = m_config.m_lsbStereo;
|
2015-12-08 18:04:46 -05:00
|
|
|
m_running.m_showPilot = m_config.m_showPilot;
|
2015-12-08 22:13:13 -05:00
|
|
|
m_running.m_rdsActive = m_config.m_rdsActive;
|
2015-12-06 04:30:51 -05:00
|
|
|
}
|