diff --git a/plugins/channeltx/modnfm/nfmmod.cpp b/plugins/channeltx/modnfm/nfmmod.cpp index 07c549828..41ddba3fc 100644 --- a/plugins/channeltx/modnfm/nfmmod.cpp +++ b/plugins/channeltx/modnfm/nfmmod.cpp @@ -48,7 +48,8 @@ NFMMod::NFMMod() : m_config.m_inputFrequencyOffset = 0; m_config.m_rfBandwidth = 12500; m_config.m_afBandwidth = 3000; - m_config.m_fmDeviation = 5000; + m_config.m_fmDeviation = 5000.0f; + m_config.m_toneFrequency = 1000.0f; m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); apply(); @@ -73,11 +74,12 @@ void NFMMod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, float fmDeviation, + float toneFrequency, int volumeTenths, bool audioMute, bool playLoop) { - Message* cmd = MsgConfigureNFMMod::create(rfBandwidth, afBandwidth, fmDeviation, volumeTenths, audioMute, playLoop); + Message* cmd = MsgConfigureNFMMod::create(rfBandwidth, afBandwidth, fmDeviation, toneFrequency, volumeTenths, audioMute, playLoop); messageQueue->push(cmd); } @@ -126,7 +128,7 @@ void NFMMod::modulateSample() pullAF(t); - m_modPhasor += (m_running.m_fmDeviation / (float) m_running.m_audioSampleRate) * m_bandpass.filter(t) * (M_PI / 302.0f); + m_modPhasor += (m_running.m_fmDeviation / (float) m_running.m_audioSampleRate) * m_bandpass.filter(t) * (M_PI / 1208.0f); m_modSample.real(cos(m_modPhasor) * 32678.0f); m_modSample.imag(sin(m_modPhasor) * 32678.0f); } @@ -217,6 +219,7 @@ bool NFMMod::handleMessage(const Message& cmd) m_config.m_rfBandwidth = cfg.getRFBandwidth(); m_config.m_afBandwidth = cfg.getAFBandwidth(); m_config.m_fmDeviation = cfg.getFMDeviation(); + m_config.m_toneFrequency = cfg.getToneFrequency(); m_config.m_volumeFactor = cfg.getVolumeFactor(); m_config.m_audioMute = cfg.getAudioMute(); m_config.m_playLoop = cfg.getPlayLoop(); @@ -227,6 +230,7 @@ bool NFMMod::handleMessage(const Message& cmd) << " m_rfBandwidth: " << m_config.m_rfBandwidth << " m_afBandwidth: " << m_config.m_afBandwidth << " m_fmDeviation: " << m_config.m_fmDeviation + << " m_toneFrequency: " << m_config.m_toneFrequency << " m_volumeFactor: " << m_config.m_volumeFactor << " m_audioMute: " << m_config.m_audioMute << " m_playLoop: " << m_config.m_playLoop; @@ -308,6 +312,14 @@ void NFMMod::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; diff --git a/plugins/channeltx/modnfm/nfmmod.h b/plugins/channeltx/modnfm/nfmmod.h index 6f7e8fd9d..5a5a92e03 100644 --- a/plugins/channeltx/modnfm/nfmmod.h +++ b/plugins/channeltx/modnfm/nfmmod.h @@ -175,7 +175,14 @@ public: NFMMod(); ~NFMMod(); - void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, float fmDeviation, int volumeFactor, bool audioMute, bool playLoop); + void configure(MessageQueue* messageQueue, + Real rfBandwidth, + Real afBandwidth, + float fmDeviation, + float toneFrequency, + int volumeFactor, + bool audioMute, + bool playLoop); virtual void pull(Sample& sample); virtual void start(); @@ -193,28 +200,31 @@ private: Real getRFBandwidth() const { return m_rfBandwidth; } Real getAFBandwidth() const { return m_afBandwidth; } float getFMDeviation() const { return m_fmDeviation; } + 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 MsgConfigureNFMMod* create(Real rfBandwidth, Real afBandwidth, float fmDeviation, int volumeFactor, bool audioMute, bool playLoop) + static MsgConfigureNFMMod* create(Real rfBandwidth, Real afBandwidth, float fmDeviation, float toneFrequency, int volumeFactor, bool audioMute, bool playLoop) { - return new MsgConfigureNFMMod(rfBandwidth, afBandwidth, fmDeviation, volumeFactor, audioMute, playLoop); + return new MsgConfigureNFMMod(rfBandwidth, afBandwidth, fmDeviation, toneFrequency, volumeFactor, audioMute, playLoop); } private: Real m_rfBandwidth; Real m_afBandwidth; float m_fmDeviation; + float m_toneFrequency; int m_volumeFactor; bool m_audioMute; bool m_playLoop; - MsgConfigureNFMMod(Real rfBandwidth, Real afBandwidth, float fmDeviation, int volumeFactor, bool audioMute, bool playLoop) : + MsgConfigureNFMMod(Real rfBandwidth, Real afBandwidth, float fmDeviation, float toneFrequency, int volumeFactor, bool audioMute, bool playLoop) : Message(), m_rfBandwidth(rfBandwidth), m_afBandwidth(afBandwidth), m_fmDeviation(fmDeviation), + m_toneFrequency(toneFrequency), m_volumeFactor(volumeFactor), m_audioMute(audioMute), m_playLoop(playLoop) @@ -240,6 +250,7 @@ private: Real m_rfBandwidth; Real m_afBandwidth; float m_fmDeviation; + float m_toneFrequency; int m_volumeFactor; quint32 m_audioSampleRate; bool m_audioMute; @@ -250,7 +261,8 @@ private: m_inputFrequencyOffset(0), m_rfBandwidth(-1), m_afBandwidth(-1), - m_fmDeviation(5.0f), + m_fmDeviation(5000.0f), + m_toneFrequency(1000.0f), m_volumeFactor(20), m_audioSampleRate(0), m_audioMute(false), diff --git a/plugins/channeltx/modnfm/nfmmodgui.cpp b/plugins/channeltx/modnfm/nfmmodgui.cpp index 235d2117b..a8d58fd7a 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.cpp +++ b/plugins/channeltx/modnfm/nfmmodgui.cpp @@ -77,6 +77,7 @@ void NFMModGUI::resetToDefaults() ui->rfBW->setCurrentIndex(6); ui->afBW->setValue(3); ui->fmDev->setValue(50); + ui->toneFrequency->setValue(100); ui->micVolume->setValue(50); ui->deltaFrequency->setValue(0); @@ -92,6 +93,7 @@ QByteArray NFMModGUI::serialize() const s.writeS32(3, ui->afBW->value()); s.writeS32(4, ui->fmDev->value()); s.writeU32(5, m_channelMarker.getColor().rgb()); + s.writeS32(6, ui->toneFrequency->value()); return s.final(); } @@ -128,6 +130,9 @@ bool NFMModGUI::deserialize(const QByteArray& data) m_channelMarker.setColor(u32tmp); } + d.readS32(6, &tmp, 100); + ui->toneFrequency->setValue(tmp); + blockApplySettings(false); m_channelMarker.blockSignals(false); @@ -219,9 +224,9 @@ void NFMModGUI::on_fmDev_valueChanged(int value) applySettings(); } -void NFMModGUI::on_micVolume_valueChanged(int value) +void NFMModGUI::on_toneFrequency_valueChanged(int value) { - ui->micVolumeText->setText(QString("%1").arg(value)); + ui->toneFrequencyText->setText(QString("%1k").arg(value / 100.0, 0, 'f', 2)); applySettings(); } @@ -407,6 +412,7 @@ void NFMModGUI::applySettings() m_rfBW[ui->rfBW->currentIndex()], ui->afBW->value() * 1000.0, ui->fmDev->value() * 100.0f, // value is in '100 Hz + ui->toneFrequency->value() * 10.0f, ui->micVolume->value(), ui->audioMute->isChecked(), ui->playLoop->isChecked()); diff --git a/plugins/channeltx/modnfm/nfmmodgui.h b/plugins/channeltx/modnfm/nfmmodgui.h index ad220b23c..0ea90e0f2 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.h +++ b/plugins/channeltx/modnfm/nfmmodgui.h @@ -63,8 +63,9 @@ private slots: void on_deltaMinus_toggled(bool minus); void on_rfBW_currentIndexChanged(int index); void on_afBW_valueChanged(int value); + void on_modPercent_valueChanged(int value); void on_fmDev_valueChanged(int value); - void on_micVolume_valueChanged(int value); + void on_toneFrequency_valueChanged(int value); void on_audioMute_toggled(bool checked); void on_tone_toggled(bool checked); void on_mic_toggled(bool checked); diff --git a/plugins/channeltx/modnfm/nfmmodgui.ui b/plugins/channeltx/modnfm/nfmmodgui.ui index d62ed148c..2e3cfdbdc 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.ui +++ b/plugins/channeltx/modnfm/nfmmodgui.ui @@ -6,10 +6,16 @@ 0 0 - 295 - 181 + 298 + 182 + + + 290 + 0 + + Sans Serif @@ -27,10 +33,16 @@ 10 10 - 271 + 280 161 + + + 280 + 0 + + Settings @@ -299,7 +311,69 @@ - 5k + 5.0k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + Tone modulation (1 kHz) + + + ... + + + + :/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 @@ -307,7 +381,7 @@ - + Qt::Vertical @@ -335,11 +409,28 @@ + + + + Audio input + + + ... + + + + :/microphone.png:/microphone.png + + + true + + + - 30 + 20 0 @@ -357,41 +448,34 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + - + - - - Tone modulation (1 kHz) - + ... - - - :/carrier.png:/carrier.png - - - - - - - Audio input - - - ... - - - - :/microphone.png:/microphone.png - - - true - + + + + @@ -418,17 +502,6 @@ - - - - ... - - - - - - -