From 6095cf549c5baadeef8916a166ed31a0795c68ce Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 1 Oct 2017 20:17:20 +0200 Subject: [PATCH] BFM demod: use settings in the demod --- plugins/channelrx/demodbfm/bfmdemod.cpp | 301 ++++++++---------- plugins/channelrx/demodbfm/bfmdemod.h | 167 ++-------- plugins/channelrx/demodbfm/bfmdemodgui.cpp | 22 +- .../channelrx/demodbfm/bfmdemodsettings.cpp | 7 +- 4 files changed, 170 insertions(+), 327 deletions(-) diff --git a/plugins/channelrx/demodbfm/bfmdemod.cpp b/plugins/channelrx/demodbfm/bfmdemod.cpp index 8fb23a96c..0e9115879 100644 --- a/plugins/channelrx/demodbfm/bfmdemod.cpp +++ b/plugins/channelrx/demodbfm/bfmdemod.cpp @@ -54,6 +54,7 @@ BFMDemod::BFMDemod(DeviceSourceAPI *deviceAPI) : m_magsqCount = 0; m_squelchLevel = 0; + m_squelchState = 0; m_interpolatorDistance = 0.0f; m_interpolatorDistanceRemain = 0.0f; @@ -74,24 +75,17 @@ BFMDemod::BFMDemod(DeviceSourceAPI *deviceAPI) : connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged())); m_deviceAPI->addThreadedSink(m_threadedChannelizer); - 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; - m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); // normally 48 kHz - m_deemphasisFilterX.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6); - m_deemphasisFilterY.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6); + m_deemphasisFilterX.configure(default_deemphasis * m_settings.m_audioSampleRate * 1.0e-6); + m_deemphasisFilterY.configure(default_deemphasis * m_settings.m_audioSampleRate * 1.0e-6); m_phaseDiscri.setFMScaling(384000/m_fmExcursion); - apply(); - m_audioBuffer.resize(16384); m_audioBufferFill = 0; DSPEngine::instance()->addAudioSink(&m_audioFifo); - m_udpBufferAudio = new UDPSink(this, m_udpBlockSize, m_config.m_udpPort); + m_udpBufferAudio = new UDPSink(this, m_udpBlockSize, m_settings.m_udpPort); + + applySettings(m_settings, true); } BFMDemod::~BFMDemod() @@ -109,35 +103,6 @@ BFMDemod::~BFMDemod() delete m_channelizer; } -void BFMDemod::configure(MessageQueue* messageQueue, - Real rfBandwidth, - Real afBandwidth, - Real volume, - Real squelch, - bool audioStereo, - bool lsbStereo, - bool showPilot, - bool rdsActive, - bool copyAudioToUDP, - const QString& udpAddress, - quint16 udpPort, - bool force) -{ - Message* cmd = MsgConfigureBFMDemod::create(rfBandwidth, - afBandwidth, - volume, - squelch, - audioStereo, - lsbStereo, - showPilot, - rdsActive, - copyAudioToUDP, - udpAddress, - udpPort, - force); - messageQueue->push(cmd); -} - void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst __attribute__((unused))) { Complex ci, cs, cr; @@ -173,7 +138,7 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto // m_movingAverage.feed(msq); if(m_magsq >= m_squelchLevel) { - m_squelchState = m_running.m_rfBandwidth / 20; // decay rate + m_squelchState = m_settings.m_rfBandwidth / 20; // decay rate } if(m_squelchState > 0) @@ -188,12 +153,12 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto demod = 0; } - if (!m_running.m_showPilot) + if (!m_settings.m_showPilot) { m_sampleBuffer.push_back(Sample(demod * (1<<15), 0.0)); } - if (m_running.m_rdsActive) + if (m_settings.m_rdsActive) { //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); @@ -218,16 +183,16 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto // Process stereo if stereo mode is selected - if (m_running.m_audioStereo) + if (m_settings.m_audioStereo) { m_pilotPLL.process(demod, m_pilotPLLSamples); - if (m_running.m_showPilot) + if (m_settings.m_showPilot) { m_sampleBuffer.push_back(Sample(m_pilotPLLSamples[1] * (1<<15), 0.0)); // debug 38 kHz pilot } - if (m_running.m_lsbStereo) + if (m_settings.m_lsbStereo) { // 1.17 * 0.7 = 0.819 Complex s(demod * m_pilotPLLSamples[1], demod * m_pilotPLLSamples[2]); @@ -254,32 +219,32 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto if (m_interpolator.decimate(&m_interpolatorDistanceRemain, e, &ci)) { - if (m_running.m_audioStereo) + if (m_settings.m_audioStereo) { 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); - if (m_running.m_lsbStereo) + if (m_settings.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); - if (m_running.m_copyAudioToUDP) m_udpBufferAudio->write(m_audioBuffer[m_audioBufferFill]); + m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_settings.m_volume); + m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_settings.m_volume); + if (m_settings.m_copyAudioToUDP) m_udpBufferAudio->write(m_audioBuffer[m_audioBufferFill]); } 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); - if (m_running.m_copyAudioToUDP) m_udpBufferAudio->write(m_audioBuffer[m_audioBufferFill]); + m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_settings.m_volume); + m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_settings.m_volume); + if (m_settings.m_copyAudioToUDP) m_udpBufferAudio->write(m_audioBuffer[m_audioBufferFill]); } } else { Real deemph; m_deemphasisFilterX.process(ci.real(), deemph); - quint16 sample = (qint16)(deemph * (1<<12) * m_running.m_volume); + quint16 sample = (qint16)(deemph * (1<<12) * m_settings.m_volume); m_audioBuffer[m_audioBufferFill].l = sample; m_audioBuffer[m_audioBufferFill].r = sample; - if (m_running.m_copyAudioToUDP) m_udpBufferAudio->write(m_audioBuffer[m_audioBufferFill]); + if (m_settings.m_copyAudioToUDP) m_udpBufferAudio->write(m_audioBuffer[m_audioBufferFill]); } ++m_audioBufferFill; @@ -346,48 +311,46 @@ bool BFMDemod::handleMessage(const Message& cmd) { DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd; - m_config.m_inputSampleRate = notif.getSampleRate(); - m_config.m_inputFrequencyOffset = notif.getFrequencyOffset(); + BFMDemodSettings settings = m_settings; - apply(); + settings.m_inputSampleRate = notif.getSampleRate(); + settings.m_inputFrequencyOffset = notif.getFrequencyOffset(); - qDebug() << "BFMDemod::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << m_config.m_inputSampleRate - << " m_inputFrequencyOffset: " << m_config.m_inputFrequencyOffset; + applySettings(settings); + + qDebug() << "BFMDemod::handleMessage: MsgChannelizerNotification:" + << " m_inputSampleRate: " << settings.m_inputSampleRate + << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset; return true; } - else if (MsgConfigureBFMDemod::match(cmd)) - { - MsgConfigureBFMDemod& cfg = (MsgConfigureBFMDemod&) cmd; + 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(); - m_config.m_audioStereo = cfg.getAudioStereo(); - m_config.m_lsbStereo = cfg.getLsbStereo(); - m_config.m_showPilot = cfg.getShowPilot(); - m_config.m_rdsActive = cfg.getRDSActive(); - m_config.m_copyAudioToUDP= cfg.getCopyAudioToUDP(); - m_config.m_udpAddress = cfg.getUDPAddress(); - m_config.m_udpPort = cfg.getUDPPort(); + BFMDemodSettings settings = cfg.getSettings(); - apply(cfg.getForce()); + // These settings are set with DownChannelizer::MsgChannelizerNotification + settings.m_inputSampleRate = m_settings.m_inputSampleRate; + settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; - qDebug() << "BFMDemod::handleMessage: MsgConfigureBFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth - << " m_afBandwidth: " << m_config.m_afBandwidth - << " m_volume: " << m_config.m_volume - << " m_squelch: " << m_config.m_squelch - << " m_audioStereo: " << m_config.m_audioStereo - << " m_lsbStereo: " << m_config.m_lsbStereo - << " m_showPilot: " << m_config.m_showPilot - << " m_rdsActive: " << m_config.m_rdsActive - << " m_copyAudioToUDP: " << m_config.m_copyAudioToUDP - << " m_udpAddress: " << m_config.m_udpAddress - << " m_udpPort: " << m_config.m_udpPort; + applySettings(settings, cfg.getForce()); - return true; - } + qDebug() << "BFMDemod::handleMessage: MsgConfigureBFMDemod:" + << " m_rfBandwidth: " << settings.m_rfBandwidth + << " m_volume: " << settings.m_volume + << " m_squelch: " << settings.m_squelch + << " m_audioStereo: " << settings.m_audioStereo + << " m_lsbStereo: " << settings.m_lsbStereo + << " m_showPilot: " << settings.m_showPilot + << " m_rdsActive: " << settings.m_rdsActive + << " m_copyAudioToUDP: " << settings.m_copyAudioToUDP + << " m_udpAddress: " << settings.m_udpAddress + << " m_udpPort: " << settings.m_udpPort + << " force: " << cfg.getForce(); + + return true; + } else { qDebug() << "BFMDemod::handleMessage: none"; @@ -403,87 +366,87 @@ bool BFMDemod::handleMessage(const Message& cmd) } } -void BFMDemod::apply(bool force) +void BFMDemod::applySettings(const BFMDemodSettings& settings, bool force) { - if ((m_config.m_inputSampleRate != m_running.m_inputSampleRate) - || (m_config.m_audioStereo && (m_config.m_audioStereo != m_running.m_audioStereo)) || force) - { - m_pilotPLL.configure(19000.0/m_config.m_inputSampleRate, 50.0/m_config.m_inputSampleRate, 0.01); - } - - if((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) || - (m_config.m_inputSampleRate != m_running.m_inputSampleRate) || force) - { - 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) || force) - { - m_settingsMutex.lock(); - qDebug() << "BFMDemod::handleMessage: m_interpolator.create"; - - 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; - - 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; - - 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; - - 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) || force) - { - 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); - m_phaseDiscri.setFMScaling(m_config.m_inputSampleRate / m_fmExcursion); - m_settingsMutex.unlock(); - - qDebug() << "BFMDemod::handleMessage: m_rfFilter->create_filter: sampleRate: " - << m_config.m_inputSampleRate - << " lowCut: " << lowCut * m_config.m_inputSampleRate - << " hiCut: " << hiCut * m_config.m_inputSampleRate; - } - - if ((m_config.m_afBandwidth != m_running.m_afBandwidth) || - (m_config.m_audioSampleRate != m_running.m_audioSampleRate) || force) - { - 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) || force) - { - qDebug() << "BFMDemod::handleMessage: set m_squelchLevel"; - m_squelchLevel = std::pow(10.0, m_config.m_squelch / 20.0); - m_squelchLevel *= m_squelchLevel; - } - - if ((m_config.m_audioSampleRate != m_running.m_audioSampleRate) || force) - { - m_deemphasisFilterX.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6); - m_deemphasisFilterY.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6); - } - - if ((m_config.m_udpAddress != m_running.m_udpAddress) - || (m_config.m_udpPort != m_running.m_udpPort) || force) + if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) + || (settings.m_audioStereo && (settings.m_audioStereo != m_settings.m_audioStereo)) || force) { - m_udpBufferAudio->setAddress(m_config.m_udpAddress); - m_udpBufferAudio->setPort(m_config.m_udpPort); + m_pilotPLL.configure(19000.0/settings.m_inputSampleRate, 50.0/settings.m_inputSampleRate, 0.01); } - m_running = m_config; + if((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || + (settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force) + { + qDebug() << "BFMDemod::handleMessage: m_nco.setFreq"; + m_nco.setFreq(-settings.m_inputFrequencyOffset, settings.m_inputSampleRate); + } + + if((settings.m_inputSampleRate != m_settings.m_inputSampleRate) || + (settings.m_afBandwidth != m_settings.m_afBandwidth) || force) + { + m_settingsMutex.lock(); + qDebug() << "BFMDemod::handleMessage: m_interpolator.create"; + + m_interpolator.create(16, settings.m_inputSampleRate, settings.m_afBandwidth); + m_interpolatorDistanceRemain = (Real) settings.m_inputSampleRate / settings.m_audioSampleRate; + m_interpolatorDistance = (Real) settings.m_inputSampleRate / (Real) settings.m_audioSampleRate; + + m_interpolatorStereo.create(16, settings.m_inputSampleRate, settings.m_afBandwidth); + m_interpolatorStereoDistanceRemain = (Real) settings.m_inputSampleRate / settings.m_audioSampleRate; + m_interpolatorStereoDistance = (Real) settings.m_inputSampleRate / (Real) settings.m_audioSampleRate; + + m_interpolatorRDS.create(4, settings.m_inputSampleRate, 600.0); + m_interpolatorRDSDistanceRemain = (Real) settings.m_inputSampleRate / 250000.0; + m_interpolatorRDSDistance = (Real) settings.m_inputSampleRate / 250000.0; + + m_settingsMutex.unlock(); + } + + if((settings.m_inputSampleRate != m_settings.m_inputSampleRate) || + (settings.m_rfBandwidth != m_settings.m_rfBandwidth) || + (settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) + { + m_settingsMutex.lock(); + Real lowCut = -(settings.m_rfBandwidth / 2.0) / settings.m_inputSampleRate; + Real hiCut = (settings.m_rfBandwidth / 2.0) / settings.m_inputSampleRate; + m_rfFilter->create_filter(lowCut, hiCut); + m_phaseDiscri.setFMScaling(settings.m_inputSampleRate / m_fmExcursion); + m_settingsMutex.unlock(); + + qDebug() << "BFMDemod::handleMessage: m_rfFilter->create_filter: sampleRate: " + << settings.m_inputSampleRate + << " lowCut: " << lowCut * settings.m_inputSampleRate + << " hiCut: " << hiCut * settings.m_inputSampleRate; + } + + if ((settings.m_afBandwidth != m_settings.m_afBandwidth) || + (settings.m_audioSampleRate != m_settings.m_audioSampleRate) || force) + { + m_settingsMutex.lock(); + qDebug() << "BFMDemod::handleMessage: m_lowpass.create"; + m_lowpass.create(21, settings.m_audioSampleRate, settings.m_afBandwidth); + m_settingsMutex.unlock(); + } + + if ((settings.m_squelch != m_settings.m_squelch) || force) + { + qDebug() << "BFMDemod::handleMessage: set m_squelchLevel"; + m_squelchLevel = std::pow(10.0, settings.m_squelch / 20.0); + m_squelchLevel *= m_squelchLevel; + } + + if ((settings.m_audioSampleRate != m_settings.m_audioSampleRate) || force) + { + m_deemphasisFilterX.configure(default_deemphasis * settings.m_audioSampleRate * 1.0e-6); + m_deemphasisFilterY.configure(default_deemphasis * settings.m_audioSampleRate * 1.0e-6); + } + + if ((settings.m_udpAddress != m_settings.m_udpAddress) + || (settings.m_udpPort != m_settings.m_udpPort) || force) + { + m_udpBufferAudio->setAddress(const_cast(settings.m_udpAddress)); + m_udpBufferAudio->setPort(settings.m_udpPort); + } + + m_settings = settings; } diff --git a/plugins/channelrx/demodbfm/bfmdemod.h b/plugins/channelrx/demodbfm/bfmdemod.h index 0d9322246..3c403bb19 100644 --- a/plugins/channelrx/demodbfm/bfmdemod.h +++ b/plugins/channelrx/demodbfm/bfmdemod.h @@ -36,6 +36,7 @@ #include "rdsparser.h" #include "rdsdecoder.h" #include "rdsdemod.h" +#include "bfmdemodsettings.h" class DeviceSourceAPI; class ThreadedBasebandSampleSink; @@ -43,6 +44,29 @@ class DownChannelizer; class BFMDemod : public BasebandSampleSink { public: + class MsgConfigureBFMDemod : public Message { + MESSAGE_CLASS_DECLARATION + + public: + const BFMDemodSettings& getSettings() const { return m_settings; } + bool getForce() const { return m_force; } + + static MsgConfigureBFMDemod* create(const BFMDemodSettings& settings, bool force) + { + return new MsgConfigureBFMDemod(settings, force); + } + + private: + BFMDemodSettings m_settings; + bool m_force; + + MsgConfigureBFMDemod(const BFMDemodSettings& settings, bool force) : + Message(), + m_settings(settings), + m_force(force) + { } + }; + class MsgConfigureChannelizer : public Message { MESSAGE_CLASS_DECLARATION @@ -90,21 +114,7 @@ public: virtual ~BFMDemod(); void setSampleSink(BasebandSampleSink* sampleSink) { m_sampleSink = sampleSink; } - void configure(MessageQueue* messageQueue, - Real rfBandwidth, - Real afBandwidth, - Real volume, - Real squelch, - bool audioStereo, - bool lsbStereo, - bool showPilot, - bool rdsActive, - bool copyAudioUDP, - const QString& m_udpAddress, - quint16 udpPort, - bool force = false); - - int getSampleRate() const { return m_config.m_inputSampleRate; } + int getSampleRate() const { return m_settings.m_inputSampleRate; } virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void start(); virtual void stop(); @@ -138,138 +148,17 @@ private slots: void channelSampleRateChanged(); private: - class MsgConfigureBFMDemod : public Message { - MESSAGE_CLASS_DECLARATION - - public: - Real getRFBandwidth() const { return m_rfBandwidth; } - Real getAFBandwidth() const { return m_afBandwidth; } - Real getVolume() const { return m_volume; } - Real getSquelch() const { return m_squelch; } - bool getAudioStereo() const { return m_audioStereo; } - bool getLsbStereo() const { return m_lsbStereo; } - bool getShowPilot() const { return m_showPilot; } - bool getRDSActive() const { return m_rdsActive; } - bool getCopyAudioToUDP() const { return m_copyAudioToUDP; } - const QString& getUDPAddress() const { return m_udpAddress; } - quint16 getUDPPort() const { return m_udpPort; } - bool getForce() const { return m_force; } - - static MsgConfigureBFMDemod* create(Real rfBandwidth, - Real afBandwidth, - Real volume, - Real squelch, - bool audioStereo, - bool lsbStereo, - bool showPilot, - bool rdsActive, - bool copyAudioToUDP, - const QString& udpAddress, - quint16 udpPort, - bool force) - { - return new MsgConfigureBFMDemod(rfBandwidth, - afBandwidth, - volume, - squelch, - audioStereo, - lsbStereo, - showPilot, - rdsActive, - copyAudioToUDP, - udpAddress, - udpPort, - force); - } - - private: - Real m_rfBandwidth; - Real m_afBandwidth; - Real m_volume; - Real m_squelch; - bool m_audioStereo; - bool m_lsbStereo; - bool m_showPilot; - bool m_rdsActive; - bool m_copyAudioToUDP; - QString m_udpAddress; - quint16 m_udpPort; - bool m_force; - - MsgConfigureBFMDemod(Real rfBandwidth, - Real afBandwidth, - Real volume, - Real squelch, - bool audioStereo, - bool lsbStereo, - bool showPilot, - bool rdsActive, - bool copyAudioToUDP, - const QString& udpAddress, - quint16 udpPort, - bool force) : - Message(), - m_rfBandwidth(rfBandwidth), - m_afBandwidth(afBandwidth), - m_volume(volume), - m_squelch(squelch), - m_audioStereo(audioStereo), - m_lsbStereo(lsbStereo), - m_showPilot(showPilot), - m_rdsActive(rdsActive), - m_copyAudioToUDP(copyAudioToUDP), - m_udpAddress(udpAddress), - m_udpPort(udpPort), - m_force(force) - { } - }; - enum RateState { RSInitialFill, RSRunning }; - struct Config { - int m_inputSampleRate; - qint64 m_inputFrequencyOffset; - Real m_rfBandwidth; - Real m_afBandwidth; - Real m_squelch; - Real m_volume; - quint32 m_audioSampleRate; - bool m_audioStereo; - bool m_lsbStereo; - bool m_showPilot; - bool m_rdsActive; - bool m_copyAudioToUDP; - QString m_udpAddress; - quint16 m_udpPort; - - Config() : - m_inputSampleRate(-1), - m_inputFrequencyOffset(0), - m_rfBandwidth(-1), - m_afBandwidth(-1), - m_squelch(0), - m_volume(0), - m_audioSampleRate(0), - m_audioStereo(false), - m_lsbStereo(false), - m_showPilot(false), - m_rdsActive(false), - m_copyAudioToUDP(false), - m_udpAddress("127.0.0.1"), - m_udpPort(9999) - { } - }; - - Config m_config; - Config m_running; - DeviceSourceAPI *m_deviceAPI; ThreadedBasebandSampleSink* m_threadedChannelizer; DownChannelizer* m_channelizer; + BFMDemodSettings m_settings; + NCO m_nco; Interpolator m_interpolator; //!< Interpolator between fixed demod bandwidth and audio bandwidth (rational) Real m_interpolatorDistance; @@ -324,7 +213,7 @@ private: static const int m_udpBlockSize; - void apply(bool force = false); + void applySettings(const BFMDemodSettings& settings, bool force = false); }; #endif // INCLUDE_BFMDEMOD_H diff --git a/plugins/channelrx/demodbfm/bfmdemodgui.cpp b/plugins/channelrx/demodbfm/bfmdemodgui.cpp index 7a7a932e4..02c86f2ff 100644 --- a/plugins/channelrx/demodbfm/bfmdemodgui.cpp +++ b/plugins/channelrx/demodbfm/bfmdemodgui.cpp @@ -298,7 +298,6 @@ void BFMDemodGUI::on_g14AltFrequencies_activated(int index __attribute__((unused changeFrequency(f); } - void BFMDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused))) { } @@ -345,12 +344,12 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); m_channelMarker.setTitle("Broadcast FM Demod"); - m_channelMarker.setColor(QColor(80, 120, 228)); m_channelMarker.setBandwidth(12500); m_channelMarker.setCenterFrequency(0); m_channelMarker.setUDPAddress("127.0.0.1"); m_channelMarker.setUDPSendPort(9999); m_channelMarker.setVisible(true); + m_channelMarker.setColor(m_settings.m_rgbColor); setTitleColor(m_channelMarker.getColor()); m_settings.setChannelMarker(&m_channelMarker); @@ -405,26 +404,15 @@ void BFMDemodGUI::applySettings(bool force) { setTitleColor(m_channelMarker.getColor()); - BFMDemod::MsgConfigureChannelizer *message = BFMDemod::MsgConfigureChannelizer::create( + BFMDemod::MsgConfigureChannelizer *msgChan = BFMDemod::MsgConfigureChannelizer::create( requiredBW(BFMDemodSettings::getRFBW(ui->rfBW->value())), m_channelMarker.getCenterFrequency()); - m_bfmDemod->getInputMessageQueue()->push(message); + m_bfmDemod->getInputMessageQueue()->push(msgChan); ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); - m_bfmDemod->configure(m_bfmDemod->getInputMessageQueue(), - BFMDemodSettings::getRFBW(ui->rfBW->value()), - ui->afBW->value() * 1000.0, - ui->volume->value() / 10.0, - ui->squelch->value(), - ui->audioStereo->isChecked(), - ui->lsbStereo->isChecked(), - ui->showPilot->isChecked(), - ui->rds->isChecked(), - ui->copyAudioToUDP->isChecked(), - m_channelMarker.getUDPAddress(), - m_channelMarker.getUDPSendPort(), - force); + BFMDemod::MsgConfigureBFMDemod* msgConfig = BFMDemod::MsgConfigureBFMDemod::create( m_settings, force); + m_bfmDemod->getInputMessageQueue()->push(msgConfig); } } diff --git a/plugins/channelrx/demodbfm/bfmdemodsettings.cpp b/plugins/channelrx/demodbfm/bfmdemodsettings.cpp index 38a8bcd06..6efa0385c 100644 --- a/plugins/channelrx/demodbfm/bfmdemodsettings.cpp +++ b/plugins/channelrx/demodbfm/bfmdemodsettings.cpp @@ -14,6 +14,8 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#include + #include "dsp/dspengine.h" #include "util/simpleserializer.h" #include "settings/serializable.h" @@ -36,8 +38,8 @@ void BFMDemodSettings::resetToDefaults() { m_inputSampleRate = 384000; m_inputFrequencyOffset = 0; - m_rfBandwidth = getRFBW(4); - m_afBandwidth = 3000; + m_rfBandwidth = getRFBW(5); + m_afBandwidth = 15000; m_volume = 2.0; m_squelch = -60.0; m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); @@ -48,6 +50,7 @@ void BFMDemodSettings::resetToDefaults() m_copyAudioToUDP = false; m_udpAddress = "127.0.0.1"; m_udpPort = 9999; + m_rgbColor = QColor(80, 120, 228).rgb(); } QByteArray BFMDemodSettings::serialize() const