diff --git a/plugins/channeltx/modam/ammod.cpp b/plugins/channeltx/modam/ammod.cpp index 8e026f88b..852b4fedf 100644 --- a/plugins/channeltx/modam/ammod.cpp +++ b/plugins/channeltx/modam/ammod.cpp @@ -67,8 +67,7 @@ AMMod::AMMod() : m_toneNco.setFreq(1000.0, m_config.m_audioSampleRate); DSPEngine::instance()->addAudioSource(&m_audioFifo); - // test CW keyer - // TODO: link to CW keyer GUI + // CW keyer m_cwKeyer.setSampleRate(m_config.m_audioSampleRate); m_cwKeyer.setWPM(13); m_cwKeyer.setMode(CWKeyer::CWNone); diff --git a/plugins/channeltx/modam/ammodgui.cpp b/plugins/channeltx/modam/ammodgui.cpp index 5b4a11e2d..2bab8e783 100644 --- a/plugins/channeltx/modam/ammodgui.cpp +++ b/plugins/channeltx/modam/ammodgui.cpp @@ -270,13 +270,6 @@ void AMModGUI::on_morseKeyer_toggled(bool checked) ui->play->setEnabled(!checked); // release other source inputs ui->tone->setEnabled(!checked); // release other source inputs ui->mic->setEnabled(!checked); - - if (checked) { - ui->cwKeyerGUI->grabKeyboard(); - } else { - ui->cwKeyerGUI->releaseKeyboard(); - } - m_modAFInput = checked ? AMMod::AMModInputCWTone : AMMod::AMModInputNone; AMMod::MsgConfigureAFInput* message = AMMod::MsgConfigureAFInput::create(m_modAFInput); m_amMod->getInputMessageQueue()->push(message); diff --git a/plugins/channeltx/modnfm/nfmmod.cpp b/plugins/channeltx/modnfm/nfmmod.cpp index 495779951..67efc9c43 100644 --- a/plugins/channeltx/modnfm/nfmmod.cpp +++ b/plugins/channeltx/modnfm/nfmmod.cpp @@ -68,6 +68,11 @@ NFMMod::NFMMod() : m_toneNco.setFreq(1000.0, m_config.m_audioSampleRate); DSPEngine::instance()->addAudioSource(&m_audioFifo); + + // CW keyer + m_cwKeyer.setSampleRate(m_config.m_audioSampleRate); + m_cwKeyer.setWPM(13); + m_cwKeyer.setMode(CWKeyer::CWNone); } NFMMod::~NFMMod() @@ -182,6 +187,17 @@ void NFMMod::pullAF(Real& sample) m_audioFifo.read(reinterpret_cast(audioSample), 1, 10); sample = ((audioSample[0] + audioSample[1]) / 65536.0f) * m_running.m_volumeFactor; break; + case NFMModInputCWTone: + if (m_cwKeyer.getSample()) + { + sample = m_toneNco.next(); + } + else + { + sample = 0.0f; + m_toneNco.setPhase(0); + } + break; case NFMModInputNone: default: sample = 0.0f; @@ -347,6 +363,11 @@ void NFMMod::apply() m_settingsMutex.unlock(); } + if (m_config.m_audioSampleRate != m_running.m_audioSampleRate) + { + m_cwKeyer.setSampleRate(m_config.m_audioSampleRate); + } + 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 72bc09e08..3c2fd6505 100644 --- a/plugins/channeltx/modnfm/nfmmod.h +++ b/plugins/channeltx/modnfm/nfmmod.h @@ -29,6 +29,7 @@ #include "dsp/bandpass.h" #include "dsp/movingaverage.h" #include "dsp/agc.h" +#include "dsp/cwkeyer.h" #include "audio/audiofifo.h" #include "util/message.h" @@ -41,7 +42,8 @@ public: NFMModInputNone, NFMModInputTone, NFMModInputFile, - NFMModInputAudio + NFMModInputAudio, + NFMModInputCWTone } NFMModInputAF; class MsgConfigureFileSourceName : public Message @@ -191,6 +193,8 @@ public: Real getMagSq() const { return m_magsq; } + CWKeyer *getCWKeyer() { return &m_cwKeyer; } + signals: /** * Level changed @@ -317,6 +321,7 @@ private: quint32 m_levelCalcCount; Real m_peakLevel; Real m_levelSum; + CWKeyer m_cwKeyer; static const int m_levelNbSamples; void apply(); diff --git a/plugins/channeltx/modnfm/nfmmodgui.cpp b/plugins/channeltx/modnfm/nfmmodgui.cpp index f6dee3915..6dcf5d7db 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.cpp +++ b/plugins/channeltx/modnfm/nfmmodgui.cpp @@ -253,6 +253,7 @@ void NFMModGUI::on_play_toggled(bool checked) { ui->tone->setEnabled(!checked); // release other source inputs ui->mic->setEnabled(!checked); + ui->morseKeyer->setEnabled(!checked); m_modAFInput = checked ? NFMMod::NFMModInputFile : NFMMod::NFMModInputNone; NFMMod::MsgConfigureAFInput* message = NFMMod::MsgConfigureAFInput::create(m_modAFInput); m_nfmMod->getInputMessageQueue()->push(message); @@ -264,15 +265,27 @@ void NFMModGUI::on_tone_toggled(bool checked) { ui->play->setEnabled(!checked); // release other source inputs ui->mic->setEnabled(!checked); + ui->morseKeyer->setEnabled(!checked); m_modAFInput = checked ? NFMMod::NFMModInputTone : NFMMod::NFMModInputNone; NFMMod::MsgConfigureAFInput* message = NFMMod::MsgConfigureAFInput::create(m_modAFInput); m_nfmMod->getInputMessageQueue()->push(message); } +void NFMModGUI::on_morseKeyer_toggled(bool checked) +{ + ui->tone->setEnabled(!checked); // release other source inputs + ui->mic->setEnabled(!checked); + ui->play->setEnabled(!checked); + m_modAFInput = checked ? NFMMod::NFMModInputCWTone : NFMMod::NFMModInputNone; + NFMMod::MsgConfigureAFInput* message = NFMMod::MsgConfigureAFInput::create(m_modAFInput); + m_nfmMod->getInputMessageQueue()->push(message); +} + void NFMModGUI::on_mic_toggled(bool checked) { ui->play->setEnabled(!checked); // release other source inputs ui->tone->setEnabled(!checked); // release other source inputs + ui->morseKeyer->setEnabled(!checked); m_modAFInput = checked ? NFMMod::NFMModInputAudio : NFMMod::NFMModInputNone; NFMMod::MsgConfigureAFInput* message = NFMMod::MsgConfigureAFInput::create(m_modAFInput); m_nfmMod->getInputMessageQueue()->push(message); @@ -383,6 +396,8 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa ui->tone->setChecked(false); ui->mic->setChecked(false); + ui->cwKeyerGUI->setBuddies(m_nfmMod->getInputMessageQueue(), m_nfmMod->getCWKeyer()); + applySettings(); connect(m_nfmMod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); diff --git a/plugins/channeltx/modnfm/nfmmodgui.h b/plugins/channeltx/modnfm/nfmmodgui.h index 0f0091b29..d7e1535ba 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.h +++ b/plugins/channeltx/modnfm/nfmmodgui.h @@ -68,6 +68,7 @@ private slots: void on_volume_valueChanged(int value); void on_audioMute_toggled(bool checked); void on_tone_toggled(bool checked); + void on_morseKeyer_toggled(bool checked); void on_mic_toggled(bool checked); void on_play_toggled(bool checked); diff --git a/plugins/channeltx/modnfm/nfmmodgui.ui b/plugins/channeltx/modnfm/nfmmodgui.ui index b86d3f03e..bc40332b1 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.ui +++ b/plugins/channeltx/modnfm/nfmmodgui.ui @@ -7,7 +7,7 @@ 0 0 298 - 182 + 300 @@ -37,10 +37,10 @@ - 10 - 10 + 2 + 2 280 - 161 + 271 @@ -417,6 +417,20 @@ + + + + Morse keyer at tone frequency + + + ... + + + + :/morsekey.png:/morsekey.png + + + @@ -507,6 +521,13 @@ + + + + + + + @@ -697,6 +718,12 @@
gui/levelmeter.h
1 + + CWKeyerGUI + QWidget +
gui/cwkeyergui.h
+ 1 +