From 9fdaa2954486b0b6ac31e0946f3faf5b6a527638 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 1 Dec 2016 00:10:34 +0100 Subject: [PATCH] AM Modulator: variable tone frequency --- plugins/channelrx/demodam/amdemodgui.cpp | 2 +- plugins/channelrx/demodam/amdemodgui.ui | 15 +- plugins/channeltx/modam/ammod.cpp | 21 ++- plugins/channeltx/modam/ammod.h | 19 ++- plugins/channeltx/modam/ammodgui.cpp | 17 ++- plugins/channeltx/modam/ammodgui.h | 1 + plugins/channeltx/modam/ammodgui.ui | 184 ++++++++++++++++------- 7 files changed, 176 insertions(+), 83 deletions(-) diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index 1f8f5707c..2b68eaffe 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -171,7 +171,7 @@ void AMDemodGUI::on_deltaFrequency_changed(quint64 value) void AMDemodGUI::on_rfBW_valueChanged(int value) { - ui->rfBWText->setText(QString("%1 kHz").arg(value / 10.0)); + ui->rfBWText->setText(QString("%1 kHz").arg(value / 10.0, 0, 'f', 1)); m_channelMarker.setBandwidth(value * 100); applySettings(); } diff --git a/plugins/channelrx/demodam/amdemodgui.ui b/plugins/channelrx/demodam/amdemodgui.ui index a18e7c7d8..2012a93ea 100644 --- a/plugins/channelrx/demodam/amdemodgui.ui +++ b/plugins/channelrx/demodam/amdemodgui.ui @@ -38,16 +38,7 @@ 3 - - 2 - - - 2 - - - 2 - - + 2 @@ -188,7 +179,7 @@ 10 - 200 + 400 1 @@ -210,7 +201,7 @@ - 5 kHz + 5.0 kHz Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter diff --git a/plugins/channeltx/modam/ammod.cpp b/plugins/channeltx/modam/ammod.cpp index ceed7b315..7b33982cb 100644 --- a/plugins/channeltx/modam/ammod.cpp +++ b/plugins/channeltx/modam/ammod.cpp @@ -47,7 +47,8 @@ AMMod::AMMod() : m_config.m_outputSampleRate = 48000; m_config.m_inputFrequencyOffset = 0; m_config.m_rfBandwidth = 12500; - m_config.m_modFactor = 20; + m_config.m_modFactor = 0.2f; + m_config.m_toneFrequency = 1000.0f; m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); apply(); @@ -71,11 +72,12 @@ AMMod::~AMMod() void AMMod::configure(MessageQueue* messageQueue, Real rfBandwidth, float modFactor, + float toneFrequency, int volumeTenths, bool audioMute, bool playLoop) { - Message* cmd = MsgConfigureAMMod::create(rfBandwidth, modFactor, volumeTenths, audioMute, playLoop); + Message* cmd = MsgConfigureAMMod::create(rfBandwidth, modFactor, toneFrequency, volumeTenths, audioMute, playLoop); messageQueue->push(cmd); } @@ -212,6 +214,7 @@ bool AMMod::handleMessage(const Message& cmd) m_config.m_rfBandwidth = cfg.getRFBandwidth(); m_config.m_modFactor = cfg.getModFactor(); + m_config.m_toneFrequency = cfg.getToneFrequency(); m_config.m_volumeFactor = cfg.getVolumeFactor(); m_config.m_audioMute = cfg.getAudioMute(); m_config.m_playLoop = cfg.getPlayLoop(); @@ -221,6 +224,7 @@ bool AMMod::handleMessage(const Message& cmd) qDebug() << "AMMod::handleMessage: MsgConfigureAMMod:" << " m_rfBandwidth: " << m_config.m_rfBandwidth << " m_modFactor: " << m_config.m_modFactor + << " m_toneFrequency: " << m_config.m_toneFrequency << " m_volumeFactor: " << m_config.m_volumeFactor << " m_audioMute: " << m_config.m_audioMute << " m_playLoop: " << m_config.m_playLoop; @@ -283,8 +287,8 @@ void AMMod::apply() } if((m_config.m_outputSampleRate != m_running.m_outputSampleRate) || - (m_config.m_rfBandwidth != m_running.m_rfBandwidth) || - (m_config.m_audioSampleRate != m_running.m_audioSampleRate)) + (m_config.m_rfBandwidth != m_running.m_rfBandwidth) || + (m_config.m_audioSampleRate != m_running.m_audioSampleRate)) { m_settingsMutex.lock(); m_interpolatorDistanceRemain = 0; @@ -294,10 +298,19 @@ void AMMod::apply() m_settingsMutex.unlock(); } + if ((m_config.m_toneFrequency != m_running.m_toneFrequency) || + (m_config.m_audioSampleRate != m_running.m_audioSampleRate)) + { + m_settingsMutex.lock(); + m_toneNco.setFreq(m_config.m_toneFrequency, m_config.m_audioSampleRate); + m_settingsMutex.unlock(); + } + m_running.m_outputSampleRate = m_config.m_outputSampleRate; m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset; m_running.m_rfBandwidth = m_config.m_rfBandwidth; m_running.m_modFactor = m_config.m_modFactor; + m_running.m_toneFrequency = m_config.m_toneFrequency; m_running.m_volumeFactor = m_config.m_volumeFactor; m_running.m_audioSampleRate = m_config.m_audioSampleRate; m_running.m_audioMute = m_config.m_audioMute; diff --git a/plugins/channeltx/modam/ammod.h b/plugins/channeltx/modam/ammod.h index d5937e573..0a2bd211a 100644 --- a/plugins/channeltx/modam/ammod.h +++ b/plugins/channeltx/modam/ammod.h @@ -173,7 +173,13 @@ public: AMMod(); ~AMMod(); - void configure(MessageQueue* messageQueue, Real rfBandwidth, float modFactor, int volumeFactor, bool audioMute, bool playLoop); + void configure(MessageQueue* messageQueue, + Real rfBandwidth, + float modFactor, + float toneFrequency, + int volumeFactor, + bool audioMute, + bool playLoop); virtual void pull(Sample& sample); virtual void start(); @@ -190,26 +196,29 @@ private: public: Real getRFBandwidth() const { return m_rfBandwidth; } float getModFactor() const { return m_modFactor; } + float getToneFrequency() const { return m_toneFrequency; } int getVolumeFactor() const { return m_volumeFactor; } bool getAudioMute() const { return m_audioMute; } bool getPlayLoop() const { return m_playLoop; } - static MsgConfigureAMMod* create(Real rfBandwidth, float modFactor, int volumeFactor, bool audioMute, bool playLoop) + static MsgConfigureAMMod* create(Real rfBandwidth, float modFactor, float toneFreqeuncy, int volumeFactor, bool audioMute, bool playLoop) { - return new MsgConfigureAMMod(rfBandwidth, modFactor, volumeFactor, audioMute, playLoop); + return new MsgConfigureAMMod(rfBandwidth, modFactor, toneFreqeuncy, volumeFactor, audioMute, playLoop); } private: Real m_rfBandwidth; float m_modFactor; + float m_toneFrequency; int m_volumeFactor; bool m_audioMute; bool m_playLoop; - MsgConfigureAMMod(Real rfBandwidth, float modFactor, int volumeFactor, bool audioMute, bool playLoop) : + MsgConfigureAMMod(Real rfBandwidth, float modFactor, float toneFrequency, int volumeFactor, bool audioMute, bool playLoop) : Message(), m_rfBandwidth(rfBandwidth), m_modFactor(modFactor), + m_toneFrequency(toneFrequency), m_volumeFactor(volumeFactor), m_audioMute(audioMute), m_playLoop(playLoop) @@ -234,6 +243,7 @@ private: qint64 m_inputFrequencyOffset; Real m_rfBandwidth; float m_modFactor; + float m_toneFrequency; int m_volumeFactor; quint32 m_audioSampleRate; bool m_audioMute; @@ -244,6 +254,7 @@ private: m_inputFrequencyOffset(0), m_rfBandwidth(-1), m_modFactor(0.2f), + m_toneFrequency(100), m_volumeFactor(20), m_audioSampleRate(0), m_audioMute(false), diff --git a/plugins/channeltx/modam/ammodgui.cpp b/plugins/channeltx/modam/ammodgui.cpp index c57fce2c5..656f15ace 100644 --- a/plugins/channeltx/modam/ammodgui.cpp +++ b/plugins/channeltx/modam/ammodgui.cpp @@ -73,6 +73,7 @@ void AMModGUI::resetToDefaults() ui->rfBW->setValue(50); ui->modPercent->setValue(20); ui->micVolume->setValue(50); + ui->toneFrequency->setValue(100); ui->deltaFrequency->setValue(0); blockApplySettings(false); @@ -84,7 +85,7 @@ QByteArray AMModGUI::serialize() const SimpleSerializer s(1); s.writeS32(1, m_channelMarker.getCenterFrequency()); s.writeS32(2, ui->rfBW->value()); - //s.writeS32(3, ui->afBW->value()); + s.writeS32(3, ui->toneFrequency->value()); s.writeS32(4, ui->modPercent->value()); s.writeU32(5, m_channelMarker.getColor().rgb()); return s.final(); @@ -113,8 +114,8 @@ bool AMModGUI::deserialize(const QByteArray& data) m_channelMarker.setCenterFrequency(tmp); d.readS32(2, &tmp, 4); ui->rfBW->setValue(tmp); - d.readS32(3, &tmp, 3); - //ui->afBW->setValue(tmp); + d.readS32(3, &tmp, 100); + ui->toneFrequency->setValue(tmp); d.readS32(4, &tmp, 20); ui->modPercent->setValue(tmp); @@ -198,7 +199,7 @@ void AMModGUI::on_deltaFrequency_changed(quint64 value) void AMModGUI::on_rfBW_valueChanged(int value) { - ui->rfBWText->setText(QString("%1 kHz").arg(value / 10.0)); + ui->rfBWText->setText(QString("%1 kHz").arg(value / 10.0, 0, 'f', 1)); m_channelMarker.setBandwidth(value * 100); applySettings(); } @@ -215,6 +216,13 @@ void AMModGUI::on_micVolume_valueChanged(int value) applySettings(); } +void AMModGUI::on_toneFrequency_valueChanged(int value) +{ + ui->toneFrequencyText->setText(QString("%1k").arg(value / 100.0, 0, 'f', 2)); + applySettings(); +} + + void AMModGUI::on_audioMute_toggled(bool checked) { applySettings(); @@ -386,6 +394,7 @@ void AMModGUI::applySettings() m_amMod->configure(m_amMod->getInputMessageQueue(), ui->rfBW->value() * 100.0, ui->modPercent->value() / 100.0f, + ui->toneFrequency->value() * 10.0f, ui->micVolume->value(), ui->audioMute->isChecked(), ui->playLoop->isChecked()); diff --git a/plugins/channeltx/modam/ammodgui.h b/plugins/channeltx/modam/ammodgui.h index c5a7e3946..f27d57a8b 100644 --- a/plugins/channeltx/modam/ammodgui.h +++ b/plugins/channeltx/modam/ammodgui.h @@ -65,6 +65,7 @@ private slots: void on_micVolume_valueChanged(int value); void on_audioMute_toggled(bool checked); void on_tone_toggled(bool checked); + void on_toneFrequency_valueChanged(int value); void on_mic_toggled(bool checked); void on_play_toggled(bool checked); diff --git a/plugins/channeltx/modam/ammodgui.ui b/plugins/channeltx/modam/ammodgui.ui index 32cb2031f..ec5cbf2e1 100644 --- a/plugins/channeltx/modam/ammodgui.ui +++ b/plugins/channeltx/modam/ammodgui.ui @@ -6,10 +6,16 @@ 0 0 - 266 - 169 + 342 + 195 + + + 290 + 0 + + Sans Serif @@ -27,10 +33,16 @@ 10 10 - 251 - 151 + 320 + 161 + + + 280 + 0 + + Settings @@ -38,16 +50,7 @@ 3 - - 2 - - - 2 - - - 2 - - + 2 @@ -175,7 +178,7 @@ - RF BW + RFBW @@ -188,7 +191,7 @@ 10 - 200 + 400 1 @@ -210,7 +213,7 @@ - 5 kHz + 5.0 kHz Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -282,6 +285,92 @@ + + + + + + + + Tone modulation + + + ... + + + + :/carrier.png:/carrier.png + + + + + + + + 24 + 24 + + + + Tone frequency + + + 10 + + + 250 + + + 1 + + + 100 + + + + + + + + 36 + 0 + + + + Tone frequency (kHz) + + + 1.00k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + + + + Audio input + + + ... + + + + :/microphone.png:/microphone.png + + + true + + + @@ -308,16 +397,13 @@ - 30 + 20 0 Audio input volume level - - - 50 @@ -326,41 +412,34 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + - + - - - Tone modulation (1 kHz) - + ... - - - :/carrier.png:/carrier.png - - - - - - - Audio input - - - ... - - - - :/microphone.png:/microphone.png - - - true - + + + + @@ -387,17 +466,6 @@ - - - - ... - - - - - - -