From ab60cac3589e639a32c0220093e3a9a61409b7ff Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 1 Dec 2016 08:45:09 +0100 Subject: [PATCH] NFM Modulator: corrected volume setting --- plugins/channeltx/modnfm/nfmmod.cpp | 7 +- plugins/channeltx/modnfm/nfmmod.h | 12 +-- plugins/channeltx/modnfm/nfmmodgui.cpp | 13 ++- plugins/channeltx/modnfm/nfmmodgui.h | 2 +- plugins/channeltx/modnfm/nfmmodgui.ui | 114 +++++++++++++++---------- 5 files changed, 91 insertions(+), 57 deletions(-) diff --git a/plugins/channeltx/modnfm/nfmmod.cpp b/plugins/channeltx/modnfm/nfmmod.cpp index 41ddba3fc..c97f5f521 100644 --- a/plugins/channeltx/modnfm/nfmmod.cpp +++ b/plugins/channeltx/modnfm/nfmmod.cpp @@ -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(&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(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: diff --git a/plugins/channeltx/modnfm/nfmmod.h b/plugins/channeltx/modnfm/nfmmod.h index 5a5a92e03..3ff477d1e 100644 --- a/plugins/channeltx/modnfm/nfmmod.h +++ b/plugins/channeltx/modnfm/nfmmod.h @@ -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) diff --git a/plugins/channeltx/modnfm/nfmmodgui.cpp b/plugins/channeltx/modnfm/nfmmodgui.cpp index a8d58fd7a..7b2b5a2be 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.cpp +++ b/plugins/channeltx/modnfm/nfmmodgui.cpp @@ -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()); } diff --git a/plugins/channeltx/modnfm/nfmmodgui.h b/plugins/channeltx/modnfm/nfmmodgui.h index 0ea90e0f2..2c9bd7ac7 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.h +++ b/plugins/channeltx/modnfm/nfmmodgui.h @@ -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); diff --git a/plugins/channeltx/modnfm/nfmmodgui.ui b/plugins/channeltx/modnfm/nfmmodgui.ui index 2e3cfdbdc..44d237d04 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.ui +++ b/plugins/channeltx/modnfm/nfmmodgui.ui @@ -50,7 +50,16 @@ 3 - + + 2 + + + 2 + + + 2 + + 2 @@ -387,28 +396,6 @@ - - - - - 24 - 24 - - - - Audio input volume - - - 100 - - - 1 - - - 50 - - - @@ -426,28 +413,6 @@ - - - - - 20 - 0 - - - - Audio input volume level - - - - - - 50 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -461,6 +426,64 @@ + + + + Qt::Vertical + + + + + + + Vol + + + + + + + + 24 + 24 + + + + Audio input volume + + + 100 + + + 1 + + + 10 + + + + + + + + 25 + 0 + + + + Audio input volume level + + + + + + 1.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -669,6 +692,7 @@ +