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

NFM Modulator: corrected volume setting

This commit is contained in:
f4exb 2016-12-01 08:45:09 +01:00
parent 328e0ad630
commit ab60cac358
5 changed files with 91 additions and 57 deletions

View File

@ -75,11 +75,11 @@ void NFMMod::configure(MessageQueue* messageQueue,
Real afBandwidth,
float fmDeviation,
float toneFrequency,
int volumeTenths,
float volumeFactor,
bool audioMute,
bool playLoop)
{
Message* cmd = MsgConfigureNFMMod::create(rfBandwidth, afBandwidth, fmDeviation, toneFrequency, volumeTenths, audioMute, playLoop);
Message* cmd = MsgConfigureNFMMod::create(rfBandwidth, afBandwidth, fmDeviation, toneFrequency, volumeFactor, audioMute, playLoop);
messageQueue->push(cmd);
}
@ -163,6 +163,7 @@ void NFMMod::pullAF(Real& sample)
else
{
m_ifstream.read(reinterpret_cast<char*>(&sample), sizeof(Real));
sample *= m_running.m_volumeFactor;
}
}
else
@ -172,7 +173,7 @@ void NFMMod::pullAF(Real& sample)
break;
case NFMModInputAudio:
m_audioFifo.read(reinterpret_cast<quint8*>(audioSample), 1, 10);
sample = ((audioSample[0] + audioSample[1]) * m_running.m_volumeFactor) / 6553600.0f;
sample = ((audioSample[0] + audioSample[1]) / 131072.0f) * m_running.m_volumeFactor;
break;
case NFMModInputNone:
default:

View File

@ -180,7 +180,7 @@ public:
Real afBandwidth,
float fmDeviation,
float toneFrequency,
int volumeFactor,
float volumeFactor,
bool audioMute,
bool playLoop);
@ -201,7 +201,7 @@ private:
Real getAFBandwidth() const { return m_afBandwidth; }
float getFMDeviation() const { return m_fmDeviation; }
float getToneFrequency() const { return m_toneFrequency; }
int getVolumeFactor() const { return m_volumeFactor; }
float getVolumeFactor() const { return m_volumeFactor; }
bool getAudioMute() const { return m_audioMute; }
bool getPlayLoop() const { return m_playLoop; }
@ -215,11 +215,11 @@ private:
Real m_afBandwidth;
float m_fmDeviation;
float m_toneFrequency;
int m_volumeFactor;
float m_volumeFactor;
bool m_audioMute;
bool m_playLoop;
MsgConfigureNFMMod(Real rfBandwidth, Real afBandwidth, float fmDeviation, float toneFrequency, int volumeFactor, bool audioMute, bool playLoop) :
MsgConfigureNFMMod(Real rfBandwidth, Real afBandwidth, float fmDeviation, float toneFrequency, float volumeFactor, bool audioMute, bool playLoop) :
Message(),
m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth),
@ -251,7 +251,7 @@ private:
Real m_afBandwidth;
float m_fmDeviation;
float m_toneFrequency;
int m_volumeFactor;
float m_volumeFactor;
quint32 m_audioSampleRate;
bool m_audioMute;
bool m_playLoop;
@ -263,7 +263,7 @@ private:
m_afBandwidth(-1),
m_fmDeviation(5000.0f),
m_toneFrequency(1000.0f),
m_volumeFactor(20),
m_volumeFactor(1.0f),
m_audioSampleRate(0),
m_audioMute(false),
m_playLoop(false)

View File

@ -78,7 +78,7 @@ void NFMModGUI::resetToDefaults()
ui->afBW->setValue(3);
ui->fmDev->setValue(50);
ui->toneFrequency->setValue(100);
ui->micVolume->setValue(50);
ui->micVolume->setValue(10);
ui->deltaFrequency->setValue(0);
blockApplySettings(false);
@ -94,6 +94,7 @@ QByteArray NFMModGUI::serialize() const
s.writeS32(4, ui->fmDev->value());
s.writeU32(5, m_channelMarker.getColor().rgb());
s.writeS32(6, ui->toneFrequency->value());
s.writeS32(7, ui->micVolume->value());
return s.final();
}
@ -132,6 +133,8 @@ bool NFMModGUI::deserialize(const QByteArray& data)
d.readS32(6, &tmp, 100);
ui->toneFrequency->setValue(tmp);
d.readS32(7, &tmp, 10);
ui->micVolume->setValue(tmp);
blockApplySettings(false);
m_channelMarker.blockSignals(false);
@ -224,6 +227,12 @@ void NFMModGUI::on_fmDev_valueChanged(int value)
applySettings();
}
void NFMModGUI::on_micVolume_valueChanged(int value)
{
ui->micVolumeText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
applySettings();
}
void NFMModGUI::on_toneFrequency_valueChanged(int value)
{
ui->toneFrequencyText->setText(QString("%1k").arg(value / 100.0, 0, 'f', 2));
@ -413,7 +422,7 @@ void NFMModGUI::applySettings()
ui->afBW->value() * 1000.0,
ui->fmDev->value() * 100.0f, // value is in '100 Hz
ui->toneFrequency->value() * 10.0f,
ui->micVolume->value(),
ui->micVolume->value() / 10.0f,
ui->audioMute->isChecked(),
ui->playLoop->isChecked());
}

View File

@ -63,9 +63,9 @@ private slots:
void on_deltaMinus_toggled(bool minus);
void on_rfBW_currentIndexChanged(int index);
void on_afBW_valueChanged(int value);
void on_modPercent_valueChanged(int value);
void on_fmDev_valueChanged(int value);
void on_toneFrequency_valueChanged(int value);
void on_micVolume_valueChanged(int value);
void on_audioMute_toggled(bool checked);
void on_tone_toggled(bool checked);
void on_mic_toggled(bool checked);

View File

@ -50,7 +50,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -387,28 +396,6 @@
</property>
</widget>
</item>
<item>
<widget class="QDial" name="micVolume">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Audio input volume</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>50</number>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="mic">
<property name="toolTip">
@ -426,28 +413,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="micVolumeText">
<property name="minimumSize">
<size>
<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>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
@ -461,6 +426,64 @@
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="volLabel">
<property name="text">
<string>Vol</string>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="micVolume">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Audio input volume</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="micVolumeText">
<property name="minimumSize">
<size>
<width>25</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>1.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -669,6 +692,7 @@
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>