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

NFM modulator: use settings in GUI (1)

This commit is contained in:
f4exb 2017-10-11 08:33:53 +02:00
parent ccb2f7ff96
commit 0ee830f403
4 changed files with 51 additions and 25 deletions

View File

@ -93,7 +93,7 @@ void NFMMod::configure(MessageQueue* messageQueue,
bool audioMute,
bool playLoop,
bool ctcssOn,
float ctcssFrequency)
int ctcssFrequencyIndex)
{
Message* cmd = MsgConfigureNFMMod::create(rfBandwidth,
afBandwidth,
@ -103,7 +103,7 @@ void NFMMod::configure(MessageQueue* messageQueue,
audioMute,
playLoop,
ctcssOn,
ctcssFrequency);
ctcssFrequencyIndex);
messageQueue->push(cmd);
}
@ -316,7 +316,7 @@ bool NFMMod::handleMessage(const Message& cmd)
m_config.m_channelMute = cfg.getChannelMute();
m_config.m_playLoop = cfg.getPlayLoop();
m_config.m_ctcssOn = cfg.getCTCSSOn();
m_config.m_ctcssFrequency = cfg.getCTCSSFrequency();
m_config.m_ctcssFrequency = NFMModSettings::getCTCSSFreq(cfg.getCTCSSFrequencyIndex());
apply();

View File

@ -34,6 +34,8 @@
#include "audio/audiofifo.h"
#include "util/message.h"
#include "nfmmodsettings.h"
class NFMMod : public BasebandSampleSource {
Q_OBJECT
@ -187,7 +189,7 @@ public:
bool channelMute,
bool playLoop,
bool ctcssOn,
float ctcssFrequency);
int ctcssFrequencyIndex);
virtual void pull(Sample& sample);
virtual void pullAudio(int nbSamples);
@ -223,7 +225,7 @@ private:
bool getChannelMute() const { return m_channelMute; }
bool getPlayLoop() const { return m_playLoop; }
bool getCTCSSOn() const { return m_ctcssOn; }
float getCTCSSFrequency() const { return m_ctcssFrequency; }
float getCTCSSFrequencyIndex() const { return m_ctcssFrequencyIndex; }
static MsgConfigureNFMMod* create(Real rfBandwidth,
Real afBandwidth,
@ -233,7 +235,7 @@ private:
bool channelMute,
bool playLoop,
bool ctcssOn,
float ctcssFrequency)
int ctcssFrequencyIndex)
{
return new MsgConfigureNFMMod(rfBandwidth,
afBandwidth,
@ -243,7 +245,7 @@ private:
channelMute,
playLoop,
ctcssOn,
ctcssFrequency);
ctcssFrequencyIndex);
}
private:
@ -255,7 +257,7 @@ private:
bool m_channelMute;
bool m_playLoop;
bool m_ctcssOn;
float m_ctcssFrequency;
int m_ctcssFrequencyIndex;
MsgConfigureNFMMod(Real rfBandwidth,
Real afBandwidth,
@ -265,7 +267,7 @@ private:
bool channelMute,
bool playLoop,
bool ctcssOn,
float ctcssFrequency) :
int ctcssFrequencyIndex) :
Message(),
m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth),
@ -275,7 +277,7 @@ private:
m_channelMute(channelMute),
m_playLoop(playLoop),
m_ctcssOn(ctcssOn),
m_ctcssFrequency(ctcssFrequency)
m_ctcssFrequencyIndex(ctcssFrequencyIndex)
{ }
};

View File

@ -214,45 +214,54 @@ void NFMModGUI::handleSourceMessages()
void NFMModGUI::on_deltaFrequency_changed(qint64 value)
{
m_channelMarker.setCenterFrequency(value);
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
applySettings();
}
void NFMModGUI::on_rfBW_currentIndexChanged(int index)
{
m_channelMarker.setBandwidth(m_rfBW[index]);
m_channelMarker.setBandwidth(NFMModSettings::getRFBW(index));
m_settings.m_rfBandwidth = NFMModSettings::getRFBW(index);
applySettings();
}
void NFMModGUI::on_afBW_valueChanged(int value)
{
ui->afBWText->setText(QString("%1k").arg(value));
m_settings.m_afBandwidth = value * 1000.0;
applySettings();
}
void NFMModGUI::on_fmDev_valueChanged(int value)
{
ui->fmDevText->setText(QString("%1k").arg(value / 10.0, 0, 'f', 1));
m_settings.m_fmDeviation = value * 100.0;
applySettings();
}
void NFMModGUI::on_volume_valueChanged(int value)
{
ui->volumeText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
m_settings.m_volumeFactor = value / 10.0;
applySettings();
}
void NFMModGUI::on_toneFrequency_valueChanged(int value)
{
ui->toneFrequencyText->setText(QString("%1k").arg(value / 100.0, 0, 'f', 2));
m_settings.m_toneFrequency = value * 10.0;
applySettings();
}
void NFMModGUI::on_channelMute_toggled(bool checked __attribute__((unused)))
void NFMModGUI::on_channelMute_toggled(bool checked)
{
m_settings.m_channelMute = checked;
applySettings();
}
void NFMModGUI::on_playLoop_toggled(bool checked __attribute__((unused)))
void NFMModGUI::on_playLoop_toggled(bool checked)
{
m_settings.m_playLoop = checked;
applySettings();
}
@ -325,13 +334,15 @@ void NFMModGUI::on_showFileDialog_clicked(bool checked __attribute__((unused)))
}
}
void NFMModGUI::on_ctcss_currentIndexChanged(int index __attribute__((unused)))
void NFMModGUI::on_ctcss_currentIndexChanged(int index)
{
m_settings.m_ctcssIndex = index;
applySettings();
}
void NFMModGUI::on_ctcssOn_toggled(bool checked __attribute__((unused)))
void NFMModGUI::on_ctcssOn_toggled(bool checked)
{
m_settings.m_ctcssOn = checked;
applySettings();
}
@ -458,16 +469,27 @@ void NFMModGUI::applySettings()
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_nfmMod->configure(m_nfmMod->getInputMessageQueue(),
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->volume->value() / 10.0f,
ui->channelMute->isChecked(),
ui->playLoop->isChecked(),
ui->ctcssOn->isChecked(),
m_ctcssTones[ui->ctcss->currentIndex()]);
m_nfmMod->configure(m_nfmMod->getInputMessageQueue(),
m_settings.m_rfBandwidth,
m_settings.m_afBandwidth,
m_settings.m_fmDeviation, // value is in '100 Hz
m_settings.m_toneFrequency,
m_settings.m_volumeFactor,
m_settings.m_channelMute,
m_settings.m_playLoop,
m_settings.m_ctcssOn,
m_settings.m_ctcssIndex);
// m_nfmMod->configure(m_nfmMod->getInputMessageQueue(),
// 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->volume->value() / 10.0f,
// ui->channelMute->isChecked(),
// ui->playLoop->isChecked(),
// ui->ctcssOn->isChecked(),
// m_ctcssTones[ui->ctcss->currentIndex()]);
}
}

View File

@ -24,6 +24,7 @@
#include "util/messagequeue.h"
#include "nfmmod.h"
#include "nfmmodsettings.h"
class PluginAPI;
class DeviceSinkAPI;
@ -90,6 +91,7 @@ private:
PluginAPI* m_pluginAPI;
DeviceSinkAPI* m_deviceAPI;
ChannelMarker m_channelMarker;
NFMModSettings m_settings;
bool m_basicSettingsShown;
bool m_doApplySettings;