AM Modulator: variable tone frequency

pull/27/head
f4exb 2016-12-01 00:10:34 +01:00
rodzic c6a61cb94c
commit 9fdaa29544
7 zmienionych plików z 176 dodań i 83 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>266</width>
<height>169</height>
<width>342</width>
<height>195</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>290</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
@ -27,10 +33,16 @@
<rect>
<x>10</x>
<y>10</y>
<width>251</width>
<height>151</height>
<width>320</width>
<height>161</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>280</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
@ -38,16 +50,7 @@
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>2</number>
</property>
<item>
@ -175,7 +178,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>RF BW</string>
<string>RFBW</string>
</property>
</widget>
</item>
@ -188,7 +191,7 @@
<number>10</number>
</property>
<property name="maximum">
<number>200</number>
<number>400</number>
</property>
<property name="pageStep">
<number>1</number>
@ -210,7 +213,7 @@
</size>
</property>
<property name="text">
<string>5 kHz</string>
<string>5.0 kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -282,6 +285,92 @@
</property>
</widget>
</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>
<widget class="QDial" name="micVolume">
<property name="maximumSize">
@ -308,16 +397,13 @@
<widget class="QLabel" name="micVolumeText">
<property name="minimumSize">
<size>
<width>30</width>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Audio input volume level</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>50</string>
</property>
@ -326,41 +412,34 @@
</property>
</widget>
</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>
</item>
<item>
<layout class="QHBoxLayout" name="recordFileSelectLayout">
<layout class="QHBoxLayout" name="fileNameLayout">
<item>
<widget class="ButtonSwitch" name="tone">
<property name="toolTip">
<string>Tone modulation (1 kHz)</string>
</property>
<widget class="QLabel" name="recordFileText">
<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="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>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="playControllLayout">
<item>
<widget class="QPushButton" name="showFileDialog">
<property name="minimumSize">
@ -387,17 +466,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="recordFileText">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="playControllLayout">
<item>
<widget class="ButtonSwitch" name="playLoop">
<property name="toolTip">