FM Modulator: reflect GUI changes. Use FM Deviation in place of modulation percentage

This commit is contained in:
f4exb 2016-11-30 00:55:35 +01:00
parent 332f0172ca
commit 4ffe502e44
5 changed files with 76 additions and 73 deletions

View File

@ -41,13 +41,13 @@ NFMMod::NFMMod() :
m_sampleRate(48000),
m_afInput(NFMModInputNone)
{
setObjectName("AMMod");
setObjectName("NFMod");
m_config.m_outputSampleRate = 48000;
m_config.m_inputFrequencyOffset = 0;
m_config.m_rfBandwidth = 12500;
m_config.m_afBandwidth = 3000;
m_config.m_modFactor = 20;
m_config.m_fmDeviation = 20;
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
apply();
@ -71,12 +71,12 @@ NFMMod::~NFMMod()
void NFMMod::configure(MessageQueue* messageQueue,
Real rfBandwidth,
Real afBandwidth,
float modFactor,
float fmDeviation,
int volumeTenths,
bool audioMute,
bool playLoop)
{
Message* cmd = MsgConfigureNFMMod::create(rfBandwidth, afBandwidth, modFactor, volumeTenths, audioMute, playLoop);
Message* cmd = MsgConfigureNFMMod::create(rfBandwidth, afBandwidth, fmDeviation, volumeTenths, audioMute, playLoop);
messageQueue->push(cmd);
}
@ -90,13 +90,13 @@ void NFMMod::pull(Sample& sample)
if (m_interpolatorDistance > 1.0f) // decimate
{
pullAF(t);
m_modSample.real(((t+1.0f) * m_running.m_modFactor * 16384.0f)); // modulate and scale zero frequency carrier
m_modSample.real(((t+1.0f) * m_running.m_fmDeviation * 16384.0f)); // modulate and scale zero frequency carrier
m_modSample.imag(0.0f);
while (!m_interpolator.decimate(&m_interpolatorDistanceRemain, m_modSample, &ci))
{
pullAF(t);
m_modSample.real(((t+1.0f) * m_running.m_modFactor * 16384.0f)); // modulate and scale zero frequency carrier
m_modSample.real(((t+1.0f) * m_running.m_fmDeviation * 16384.0f)); // modulate and scale zero frequency carrier
m_modSample.imag(0.0f);
}
}
@ -105,7 +105,7 @@ void NFMMod::pull(Sample& sample)
if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, m_modSample, &ci))
{
pullAF(t);
m_modSample.real(((t+1.0f) * m_running.m_modFactor * 16384.0f)); // modulate and scale zero frequency carrier
m_modSample.real(((t+1.0f) * m_running.m_fmDeviation * 16384.0f)); // modulate and scale zero frequency carrier
m_modSample.imag(0.0f);
}
}
@ -210,17 +210,17 @@ bool NFMMod::handleMessage(const Message& cmd)
m_config.m_rfBandwidth = cfg.getRFBandwidth();
m_config.m_afBandwidth = cfg.getAFBandwidth();
m_config.m_modFactor = cfg.getModFactor();
m_config.m_fmDeviation = cfg.getFMDeviation();
m_config.m_volumeFactor = cfg.getVolumeFactor();
m_config.m_audioMute = cfg.getAudioMute();
m_config.m_playLoop = cfg.getPlayLoop();
apply();
qDebug() << "NFMMod::handleMessage: MsgConfigureAMMod:"
qDebug() << "NFMMod::handleMessage: MsgConfigureNFMMod:"
<< " m_rfBandwidth: " << m_config.m_rfBandwidth
<< " m_afBandwidth: " << m_config.m_afBandwidth
<< " m_modFactor: " << m_config.m_modFactor
<< " m_fmDeviation: " << m_config.m_fmDeviation
<< " m_volumeFactor: " << m_config.m_volumeFactor
<< " m_audioMute: " << m_config.m_audioMute
<< " m_playLoop: " << m_config.m_playLoop;
@ -305,7 +305,7 @@ void NFMMod::apply()
m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset;
m_running.m_rfBandwidth = m_config.m_rfBandwidth;
m_running.m_afBandwidth = m_config.m_afBandwidth;
m_running.m_modFactor = m_config.m_modFactor;
m_running.m_fmDeviation = m_config.m_fmDeviation;
m_running.m_volumeFactor = m_config.m_volumeFactor;
m_running.m_audioSampleRate = m_config.m_audioSampleRate;
m_running.m_audioMute = m_config.m_audioMute;
@ -325,7 +325,7 @@ void NFMMod::openFileStream()
m_sampleRate = 48000; // fixed rate
m_recordLength = m_fileSize / (sizeof(Real) * m_sampleRate);
qDebug() << "AMMod::openFileStream: " << m_fileName.toStdString().c_str()
qDebug() << "NFMMod::openFileStream: " << m_fileName.toStdString().c_str()
<< " fileSize: " << m_fileSize << "bytes"
<< " length: " << m_recordLength << " seconds";

View File

@ -174,7 +174,7 @@ public:
NFMMod();
~NFMMod();
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, float modFactor, int volumeFactor, bool audioMute, bool playLoop);
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, float fmDeviation, int volumeFactor, bool audioMute, bool playLoop);
virtual void pull(Sample& sample);
virtual void start();
@ -191,29 +191,29 @@ private:
public:
Real getRFBandwidth() const { return m_rfBandwidth; }
Real getAFBandwidth() const { return m_afBandwidth; }
float getModFactor() const { return m_modFactor; }
float getFMDeviation() const { return m_fmDeviation; }
int getVolumeFactor() const { return m_volumeFactor; }
bool getAudioMute() const { return m_audioMute; }
bool getPlayLoop() const { return m_playLoop; }
static MsgConfigureNFMMod* create(Real rfBandwidth, Real afBandwidth, float modFactor, int volumeFactor, bool audioMute, bool playLoop)
static MsgConfigureNFMMod* create(Real rfBandwidth, Real afBandwidth, float fmDeviation, int volumeFactor, bool audioMute, bool playLoop)
{
return new MsgConfigureNFMMod(rfBandwidth, afBandwidth, modFactor, volumeFactor, audioMute, playLoop);
return new MsgConfigureNFMMod(rfBandwidth, afBandwidth, fmDeviation, volumeFactor, audioMute, playLoop);
}
private:
Real m_rfBandwidth;
Real m_afBandwidth;
float m_modFactor;
float m_fmDeviation;
int m_volumeFactor;
bool m_audioMute;
bool m_playLoop;
MsgConfigureNFMMod(Real rfBandwidth, Real afBandwidth, float modFactor, int volumeFactor, bool audioMute, bool playLoop) :
MsgConfigureNFMMod(Real rfBandwidth, Real afBandwidth, float fmDeviation, int volumeFactor, bool audioMute, bool playLoop) :
Message(),
m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth),
m_modFactor(modFactor),
m_fmDeviation(fmDeviation),
m_volumeFactor(volumeFactor),
m_audioMute(audioMute),
m_playLoop(playLoop)
@ -238,7 +238,7 @@ private:
qint64 m_inputFrequencyOffset;
Real m_rfBandwidth;
Real m_afBandwidth;
float m_modFactor;
float m_fmDeviation;
int m_volumeFactor;
quint32 m_audioSampleRate;
bool m_audioMute;
@ -249,7 +249,7 @@ private:
m_inputFrequencyOffset(0),
m_rfBandwidth(-1),
m_afBandwidth(-1),
m_modFactor(0.2f),
m_fmDeviation(5.0f),
m_volumeFactor(20),
m_audioSampleRate(0),
m_audioMute(false),

View File

@ -38,6 +38,7 @@ const QString NFMModGUI::m_channelID = "sdrangel.channeltx.modnfm";
const int NFMModGUI::m_rfBW[] = {
3000, 4000, 5000, 6250, 8330, 10000, 12500, 15000, 20000, 25000, 40000
};
const int NFMModGUI::m_nbRfBW = 11;
NFMModGUI* NFMModGUI::create(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI)
{
@ -73,9 +74,9 @@ void NFMModGUI::resetToDefaults()
{
blockApplySettings(true);
ui->rfBW->setValue(6);
ui->rfBW->setCurrentIndex(6);
ui->afBW->setValue(3);
ui->modPercent->setValue(20);
ui->fmDev->setValue(50);
ui->micVolume->setValue(50);
ui->deltaFrequency->setValue(0);
@ -87,9 +88,9 @@ QByteArray NFMModGUI::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_channelMarker.getCenterFrequency());
s.writeS32(2, ui->rfBW->value());
s.writeS32(2, ui->rfBW->currentIndex());
s.writeS32(3, ui->afBW->value());
s.writeS32(4, ui->modPercent->value());
s.writeS32(4, ui->fmDev->value());
s.writeU32(5, m_channelMarker.getColor().rgb());
return s.final();
}
@ -115,12 +116,12 @@ bool NFMModGUI::deserialize(const QByteArray& data)
d.readS32(1, &tmp, 0);
m_channelMarker.setCenterFrequency(tmp);
d.readS32(2, &tmp, 4);
ui->rfBW->setValue(tmp);
d.readS32(2, &tmp, 6);
ui->rfBW->setCurrentIndex(tmp);
d.readS32(3, &tmp, 3);
ui->afBW->setValue(tmp);
d.readS32(4, &tmp, 20);
ui->modPercent->setValue(tmp);
d.readS32(4, &tmp, 50);
ui->fmDev->setValue(tmp);
if(d.readU32(5, &u32tmp))
{
@ -202,7 +203,6 @@ void NFMModGUI::on_deltaFrequency_changed(quint64 value)
void NFMModGUI::on_rfBW_valueChanged(int value)
{
ui->rfBWText->setText(QString("%1 kHz").arg(m_rfBW[value] / 1000.0));
m_channelMarker.setBandwidth(m_rfBW[value]);
applySettings();
}
@ -215,7 +215,7 @@ void NFMModGUI::on_afBW_valueChanged(int value)
void NFMModGUI::on_modPercent_valueChanged(int value)
{
ui->modPercentText->setText(QString("%1").arg(value));
ui->fmDevText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
applySettings();
}
@ -329,6 +329,14 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
blockApplySettings(true);
ui->rfBW->clear();
for (int i = 0; i < m_nbRfBW; i++) {
ui->rfBW->addItem(QString("%1").arg(m_rfBW[i] / 1000.0, 0, 'f', 2));
}
blockApplySettings(false);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
@ -394,9 +402,9 @@ void NFMModGUI::applySettings()
ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
m_nfmMod->configure(m_nfmMod->getInputMessageQueue(),
m_rfBW[ui->rfBW->value()],
m_rfBW[ui->rfBW->currentIndex()],
ui->afBW->value() * 1000.0,
ui->modPercent->value() / 100.0f,
ui->fmDev->value() / 100.0f,
ui->micVolume->value(),
ui->audioMute->isChecked(),
ui->playLoop->isChecked());

View File

@ -102,6 +102,7 @@ private:
NFMMod::NFMModInputAF m_modAFInput;
static const int m_rfBW[];
static const int m_nbRfBW;
explicit NFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* parent = NULL);
virtual ~NFMModGUI();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>266</width>
<height>190</height>
<width>295</width>
<height>181</height>
</rect>
</property>
<property name="font">
@ -27,7 +27,7 @@
<rect>
<x>10</x>
<y>10</y>
<width>251</width>
<width>271</width>
<height>161</height>
</rect>
</property>
@ -164,55 +164,49 @@
<item>
<layout class="QHBoxLayout" name="rfBandwidthLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="rfBwLabel">
<property name="text">
<string>RF BW</string>
<string>RFBW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="rfBW">
<property name="toolTip">
<string>Demodulator (RF) bandwidth</string>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>6</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QComboBox" name="rfBW">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rfBWText">
<widget class="QLabel" name="rfBWUnit">
<property name="minimumSize">
<size>
<width>50</width>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>12.5kHz</string>
<string>k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="afBandwidthLayout">
<item>
<widget class="QLabel" name="label_2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="afBwLabel">
<property name="text">
<string>AF BW</string>
<string>AFBW</string>
</property>
</widget>
</item>
@ -242,12 +236,12 @@
<widget class="QLabel" name="afBWText">
<property name="minimumSize">
<size>
<width>50</width>
<width>25</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>3 kHz</string>
<string>3k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -257,16 +251,16 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="modPercentLayout">
<layout class="QHBoxLayout" name="fmDeviationLayout">
<item>
<widget class="QLabel" name="pLabel">
<widget class="QLabel" name="fmDevLabel">
<property name="text">
<string>Mod%</string>
<string>Dev</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="modPercent">
<widget class="QSlider" name="fmDev">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
@ -283,13 +277,13 @@
<string>Modulation percentage</string>
</property>
<property name="maximum">
<number>100</number>
<number>250</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>20</number>
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -297,7 +291,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="modPercentText">
<widget class="QLabel" name="fmDevText">
<property name="minimumSize">
<size>
<width>30</width>
@ -305,7 +299,7 @@
</size>
</property>
<property name="text">
<string>20</string>
<string>5k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>