AM Modulator: variable tone frequency

This commit is contained in:
f4exb 2016-12-01 00:10:34 +01:00
parent c6a61cb94c
commit 9fdaa29544
7 changed files with 176 additions and 83 deletions

View File

@ -171,7 +171,7 @@ void AMDemodGUI::on_deltaFrequency_changed(quint64 value)
void AMDemodGUI::on_rfBW_valueChanged(int 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); m_channelMarker.setBandwidth(value * 100);
applySettings(); applySettings();
} }

View File

@ -38,16 +38,7 @@
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
@ -188,7 +179,7 @@
<number>10</number> <number>10</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>200</number> <number>400</number>
</property> </property>
<property name="pageStep"> <property name="pageStep">
<number>1</number> <number>1</number>
@ -210,7 +201,7 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>5 kHz</string> <string>5.0 kHz</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>

View File

@ -47,7 +47,8 @@ AMMod::AMMod() :
m_config.m_outputSampleRate = 48000; m_config.m_outputSampleRate = 48000;
m_config.m_inputFrequencyOffset = 0; m_config.m_inputFrequencyOffset = 0;
m_config.m_rfBandwidth = 12500; 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(); m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
apply(); apply();
@ -71,11 +72,12 @@ AMMod::~AMMod()
void AMMod::configure(MessageQueue* messageQueue, void AMMod::configure(MessageQueue* messageQueue,
Real rfBandwidth, Real rfBandwidth,
float modFactor, float modFactor,
float toneFrequency,
int volumeTenths, int volumeTenths,
bool audioMute, bool audioMute,
bool playLoop) bool playLoop)
{ {
Message* cmd = MsgConfigureAMMod::create(rfBandwidth, modFactor, volumeTenths, audioMute, playLoop); Message* cmd = MsgConfigureAMMod::create(rfBandwidth, modFactor, toneFrequency, volumeTenths, audioMute, playLoop);
messageQueue->push(cmd); messageQueue->push(cmd);
} }
@ -212,6 +214,7 @@ bool AMMod::handleMessage(const Message& cmd)
m_config.m_rfBandwidth = cfg.getRFBandwidth(); m_config.m_rfBandwidth = cfg.getRFBandwidth();
m_config.m_modFactor = cfg.getModFactor(); m_config.m_modFactor = cfg.getModFactor();
m_config.m_toneFrequency = cfg.getToneFrequency();
m_config.m_volumeFactor = cfg.getVolumeFactor(); m_config.m_volumeFactor = cfg.getVolumeFactor();
m_config.m_audioMute = cfg.getAudioMute(); m_config.m_audioMute = cfg.getAudioMute();
m_config.m_playLoop = cfg.getPlayLoop(); m_config.m_playLoop = cfg.getPlayLoop();
@ -221,6 +224,7 @@ bool AMMod::handleMessage(const Message& cmd)
qDebug() << "AMMod::handleMessage: MsgConfigureAMMod:" qDebug() << "AMMod::handleMessage: MsgConfigureAMMod:"
<< " m_rfBandwidth: " << m_config.m_rfBandwidth << " m_rfBandwidth: " << m_config.m_rfBandwidth
<< " m_modFactor: " << m_config.m_modFactor << " m_modFactor: " << m_config.m_modFactor
<< " m_toneFrequency: " << m_config.m_toneFrequency
<< " m_volumeFactor: " << m_config.m_volumeFactor << " m_volumeFactor: " << m_config.m_volumeFactor
<< " m_audioMute: " << m_config.m_audioMute << " m_audioMute: " << m_config.m_audioMute
<< " m_playLoop: " << m_config.m_playLoop; << " m_playLoop: " << m_config.m_playLoop;
@ -283,8 +287,8 @@ void AMMod::apply()
} }
if((m_config.m_outputSampleRate != m_running.m_outputSampleRate) || if((m_config.m_outputSampleRate != m_running.m_outputSampleRate) ||
(m_config.m_rfBandwidth != m_running.m_rfBandwidth) || (m_config.m_rfBandwidth != m_running.m_rfBandwidth) ||
(m_config.m_audioSampleRate != m_running.m_audioSampleRate)) (m_config.m_audioSampleRate != m_running.m_audioSampleRate))
{ {
m_settingsMutex.lock(); m_settingsMutex.lock();
m_interpolatorDistanceRemain = 0; m_interpolatorDistanceRemain = 0;
@ -294,10 +298,19 @@ void AMMod::apply()
m_settingsMutex.unlock(); 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_outputSampleRate = m_config.m_outputSampleRate;
m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset; m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset;
m_running.m_rfBandwidth = m_config.m_rfBandwidth; m_running.m_rfBandwidth = m_config.m_rfBandwidth;
m_running.m_modFactor = m_config.m_modFactor; 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_volumeFactor = m_config.m_volumeFactor;
m_running.m_audioSampleRate = m_config.m_audioSampleRate; m_running.m_audioSampleRate = m_config.m_audioSampleRate;
m_running.m_audioMute = m_config.m_audioMute; m_running.m_audioMute = m_config.m_audioMute;

View File

@ -173,7 +173,13 @@ public:
AMMod(); AMMod();
~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 pull(Sample& sample);
virtual void start(); virtual void start();
@ -190,26 +196,29 @@ private:
public: public:
Real getRFBandwidth() const { return m_rfBandwidth; } Real getRFBandwidth() const { return m_rfBandwidth; }
float getModFactor() const { return m_modFactor; } float getModFactor() const { return m_modFactor; }
float getToneFrequency() const { return m_toneFrequency; }
int getVolumeFactor() const { return m_volumeFactor; } int getVolumeFactor() const { return m_volumeFactor; }
bool getAudioMute() const { return m_audioMute; } bool getAudioMute() const { return m_audioMute; }
bool getPlayLoop() const { return m_playLoop; } 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: private:
Real m_rfBandwidth; Real m_rfBandwidth;
float m_modFactor; float m_modFactor;
float m_toneFrequency;
int m_volumeFactor; int m_volumeFactor;
bool m_audioMute; bool m_audioMute;
bool m_playLoop; 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(), Message(),
m_rfBandwidth(rfBandwidth), m_rfBandwidth(rfBandwidth),
m_modFactor(modFactor), m_modFactor(modFactor),
m_toneFrequency(toneFrequency),
m_volumeFactor(volumeFactor), m_volumeFactor(volumeFactor),
m_audioMute(audioMute), m_audioMute(audioMute),
m_playLoop(playLoop) m_playLoop(playLoop)
@ -234,6 +243,7 @@ private:
qint64 m_inputFrequencyOffset; qint64 m_inputFrequencyOffset;
Real m_rfBandwidth; Real m_rfBandwidth;
float m_modFactor; float m_modFactor;
float m_toneFrequency;
int m_volumeFactor; int m_volumeFactor;
quint32 m_audioSampleRate; quint32 m_audioSampleRate;
bool m_audioMute; bool m_audioMute;
@ -244,6 +254,7 @@ private:
m_inputFrequencyOffset(0), m_inputFrequencyOffset(0),
m_rfBandwidth(-1), m_rfBandwidth(-1),
m_modFactor(0.2f), m_modFactor(0.2f),
m_toneFrequency(100),
m_volumeFactor(20), m_volumeFactor(20),
m_audioSampleRate(0), m_audioSampleRate(0),
m_audioMute(false), m_audioMute(false),

View File

@ -73,6 +73,7 @@ void AMModGUI::resetToDefaults()
ui->rfBW->setValue(50); ui->rfBW->setValue(50);
ui->modPercent->setValue(20); ui->modPercent->setValue(20);
ui->micVolume->setValue(50); ui->micVolume->setValue(50);
ui->toneFrequency->setValue(100);
ui->deltaFrequency->setValue(0); ui->deltaFrequency->setValue(0);
blockApplySettings(false); blockApplySettings(false);
@ -84,7 +85,7 @@ QByteArray AMModGUI::serialize() const
SimpleSerializer s(1); SimpleSerializer s(1);
s.writeS32(1, m_channelMarker.getCenterFrequency()); s.writeS32(1, m_channelMarker.getCenterFrequency());
s.writeS32(2, ui->rfBW->value()); 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.writeS32(4, ui->modPercent->value());
s.writeU32(5, m_channelMarker.getColor().rgb()); s.writeU32(5, m_channelMarker.getColor().rgb());
return s.final(); return s.final();
@ -113,8 +114,8 @@ bool AMModGUI::deserialize(const QByteArray& data)
m_channelMarker.setCenterFrequency(tmp); m_channelMarker.setCenterFrequency(tmp);
d.readS32(2, &tmp, 4); d.readS32(2, &tmp, 4);
ui->rfBW->setValue(tmp); ui->rfBW->setValue(tmp);
d.readS32(3, &tmp, 3); d.readS32(3, &tmp, 100);
//ui->afBW->setValue(tmp); ui->toneFrequency->setValue(tmp);
d.readS32(4, &tmp, 20); d.readS32(4, &tmp, 20);
ui->modPercent->setValue(tmp); ui->modPercent->setValue(tmp);
@ -198,7 +199,7 @@ void AMModGUI::on_deltaFrequency_changed(quint64 value)
void AMModGUI::on_rfBW_valueChanged(int 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); m_channelMarker.setBandwidth(value * 100);
applySettings(); applySettings();
} }
@ -215,6 +216,13 @@ void AMModGUI::on_micVolume_valueChanged(int value)
applySettings(); 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) void AMModGUI::on_audioMute_toggled(bool checked)
{ {
applySettings(); applySettings();
@ -386,6 +394,7 @@ void AMModGUI::applySettings()
m_amMod->configure(m_amMod->getInputMessageQueue(), m_amMod->configure(m_amMod->getInputMessageQueue(),
ui->rfBW->value() * 100.0, ui->rfBW->value() * 100.0,
ui->modPercent->value() / 100.0f, ui->modPercent->value() / 100.0f,
ui->toneFrequency->value() * 10.0f,
ui->micVolume->value(), ui->micVolume->value(),
ui->audioMute->isChecked(), ui->audioMute->isChecked(),
ui->playLoop->isChecked()); ui->playLoop->isChecked());

View File

@ -65,6 +65,7 @@ private slots:
void on_micVolume_valueChanged(int value); void on_micVolume_valueChanged(int value);
void on_audioMute_toggled(bool checked); void on_audioMute_toggled(bool checked);
void on_tone_toggled(bool checked); void on_tone_toggled(bool checked);
void on_toneFrequency_valueChanged(int value);
void on_mic_toggled(bool checked); void on_mic_toggled(bool checked);
void on_play_toggled(bool checked); void on_play_toggled(bool checked);

View File

@ -6,10 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>266</width> <width>342</width>
<height>169</height> <height>195</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>290</width>
<height>0</height>
</size>
</property>
<property name="font"> <property name="font">
<font> <font>
<family>Sans Serif</family> <family>Sans Serif</family>
@ -27,10 +33,16 @@
<rect> <rect>
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>251</width> <width>320</width>
<height>151</height> <height>161</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>280</width>
<height>0</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Settings</string> <string>Settings</string>
</property> </property>
@ -38,16 +50,7 @@
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
@ -175,7 +178,7 @@
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>RF BW</string> <string>RFBW</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -188,7 +191,7 @@
<number>10</number> <number>10</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>200</number> <number>400</number>
</property> </property>
<property name="pageStep"> <property name="pageStep">
<number>1</number> <number>1</number>
@ -210,7 +213,7 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>5 kHz</string> <string>5.0 kHz</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -282,6 +285,92 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="recordFileSelectLayout">
<item>
<widget class="ButtonSwitch" name="tone">
<property name="toolTip">
<string>Tone modulation</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/carrier.png</normaloff>:/carrier.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="toneFrequency">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Tone frequency</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>250</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="toneFrequencyText">
<property name="minimumSize">
<size>
<width>36</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Tone frequency (kHz)</string>
</property>
<property name="text">
<string>1.00k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="mic">
<property name="toolTip">
<string>Audio input</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/microphone.png</normaloff>:/microphone.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QDial" name="micVolume"> <widget class="QDial" name="micVolume">
<property name="maximumSize"> <property name="maximumSize">
@ -308,16 +397,13 @@
<widget class="QLabel" name="micVolumeText"> <widget class="QLabel" name="micVolumeText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>20</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Audio input volume level</string> <string>Audio input volume level</string>
</property> </property>
<property name="statusTip">
<string/>
</property>
<property name="text"> <property name="text">
<string>50</string> <string>50</string>
</property> </property>
@ -326,41 +412,34 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="recordFileSelectLayout"> <layout class="QHBoxLayout" name="fileNameLayout">
<item> <item>
<widget class="ButtonSwitch" name="tone"> <widget class="QLabel" name="recordFileText">
<property name="toolTip">
<string>Tone modulation (1 kHz)</string>
</property>
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/carrier.png</normaloff>:/carrier.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="mic">
<property name="toolTip">
<string>Audio input</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/microphone.png</normaloff>:/microphone.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="playControllLayout">
<item> <item>
<widget class="QPushButton" name="showFileDialog"> <widget class="QPushButton" name="showFileDialog">
<property name="minimumSize"> <property name="minimumSize">
@ -387,17 +466,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="recordFileText">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="playControllLayout">
<item> <item>
<widget class="ButtonSwitch" name="playLoop"> <widget class="ButtonSwitch" name="playLoop">
<property name="toolTip"> <property name="toolTip">