1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 04:11:48 -05:00

NFM Modulator: added CW keyer

This commit is contained in:
f4exb 2016-12-11 22:47:42 +01:00
parent e4e2eea9d5
commit cfce93c498
7 changed files with 75 additions and 14 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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<quint8*>(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;

View File

@ -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();

View File

@ -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()));

View File

@ -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);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>298</width>
<height>182</height>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
@ -37,10 +37,10 @@
<widget class="QWidget" name="settingsContainer" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<x>2</x>
<y>2</y>
<width>280</width>
<height>161</height>
<height>271</height>
</rect>
</property>
<property name="minimumSize">
@ -417,6 +417,20 @@
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="morseKeyer">
<property name="toolTip">
<string>Morse keyer at tone frequency</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/morsekey.png</normaloff>:/morsekey.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="toneFrequency">
<property name="maximumSize">
@ -507,6 +521,13 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="cwKeyerLayout">
<item>
<widget class="CWKeyerGUI" name="cwKeyerGUI" native="true"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="fileNameLayout">
<item>
@ -697,6 +718,12 @@
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>CWKeyerGUI</class>
<extends>QWidget</extends>
<header>gui/cwkeyergui.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>