mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-21 23:55:13 -05:00
NFM modulator: try to improve audio input
This commit is contained in:
parent
d699271fcd
commit
532e794fca
Binary file not shown.
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 48 KiB |
Binary file not shown.
BIN
doc/img/NFMMod_plugin_input.png
Normal file
BIN
doc/img/NFMMod_plugin_input.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
BIN
doc/img/NFMMod_plugin_input.xcf
Normal file
BIN
doc/img/NFMMod_plugin_input.xcf
Normal file
Binary file not shown.
@ -279,6 +279,12 @@ void NFMModGUI::on_mic_toggled(bool checked)
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void NFMModGUI::on_compressor_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_compressorEnable = checked;
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void NFMModGUI::on_feedbackEnable_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_feedbackAudioEnable = checked;
|
||||
@ -581,6 +587,7 @@ void NFMModGUI::displaySettings()
|
||||
ui->dcsCode->setText(tr("%1").arg(m_settings.m_dcsCode, 3, 8, QLatin1Char('0')));
|
||||
ui->dcsPositive->setChecked(m_settings.m_dcsPositive);
|
||||
ui->bpf->setChecked(m_settings.m_bpfOn);
|
||||
ui->compressor->setChecked(m_settings.m_compressorEnable);
|
||||
|
||||
ui->channelMute->setChecked(m_settings.m_channelMute);
|
||||
ui->playLoop->setChecked(m_settings.m_playLoop);
|
||||
@ -729,6 +736,7 @@ void NFMModGUI::makeUIConnections()
|
||||
QObject::connect(ui->tone, &ButtonSwitch::toggled, this, &NFMModGUI::on_tone_toggled);
|
||||
QObject::connect(ui->morseKeyer, &ButtonSwitch::toggled, this, &NFMModGUI::on_morseKeyer_toggled);
|
||||
QObject::connect(ui->mic, &ButtonSwitch::toggled, this, &NFMModGUI::on_mic_toggled);
|
||||
QObject::connect(ui->compressor, &ButtonSwitch::toggled, this, &NFMModGUI::on_compressor_toggled);
|
||||
QObject::connect(ui->play, &ButtonSwitch::toggled, this, &NFMModGUI::on_play_toggled);
|
||||
QObject::connect(ui->playLoop, &ButtonSwitch::toggled, this, &NFMModGUI::on_playLoop_toggled);
|
||||
QObject::connect(ui->navTimeSlider, &QSlider::valueChanged, this, &NFMModGUI::on_navTimeSlider_valueChanged);
|
||||
|
@ -122,6 +122,7 @@ private slots:
|
||||
void on_tone_toggled(bool checked);
|
||||
void on_morseKeyer_toggled(bool checked);
|
||||
void on_mic_toggled(bool checked);
|
||||
void on_compressor_toggled(bool checked);
|
||||
void on_play_toggled(bool checked);
|
||||
|
||||
void on_playLoop_toggled(bool checked);
|
||||
|
@ -589,6 +589,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="compressor">
|
||||
<property name="toolTip">
|
||||
<string>Audio input compressor on/off</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CMP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
|
@ -75,6 +75,7 @@ void NFMModSettings::resetToDefaults()
|
||||
m_feedbackAudioDeviceName = AudioDeviceManager::m_defaultDeviceName;
|
||||
m_feedbackVolumeFactor = 0.5f;
|
||||
m_feedbackAudioEnable = false;
|
||||
m_compressorEnable = false;
|
||||
m_streamIndex = 0;
|
||||
m_useReverseAPI = false;
|
||||
m_reverseAPIAddress = "127.0.0.1";
|
||||
@ -135,6 +136,7 @@ QByteArray NFMModSettings::serialize() const
|
||||
s.writeBool(30, m_hidden);
|
||||
s.writeBool(31, m_preEmphasisOn);
|
||||
s.writeBool(32, m_bpfOn);
|
||||
s.writeBool(33, m_compressorEnable);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@ -224,6 +226,7 @@ bool NFMModSettings::deserialize(const QByteArray& data)
|
||||
d.readBool(30, &m_hidden, false);
|
||||
d.readBool(31, &m_preEmphasisOn, true);
|
||||
d.readBool(32, &m_bpfOn, true);
|
||||
d.readBool(33, &m_compressorEnable, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ struct NFMModSettings
|
||||
QString m_feedbackAudioDeviceName; //!< This is the audio device you send the audio samples to for audio feedback
|
||||
float m_feedbackVolumeFactor;
|
||||
bool m_feedbackAudioEnable;
|
||||
bool m_compressorEnable;
|
||||
int m_streamIndex;
|
||||
bool m_useReverseAPI;
|
||||
QString m_reverseAPIAddress;
|
||||
|
@ -55,6 +55,16 @@ NFMModSource::NFMModSource() :
|
||||
|
||||
m_magsq = 0.0;
|
||||
|
||||
m_audioCompressor.initSimple(
|
||||
m_audioSampleRate,
|
||||
-8, // pregain (dB)
|
||||
-20, // threshold (dB)
|
||||
20, // knee (dB)
|
||||
15, // ratio (dB)
|
||||
0.003, // attack (s)
|
||||
0.25 // release (s)
|
||||
);
|
||||
|
||||
applySettings(m_settings, true);
|
||||
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
|
||||
}
|
||||
@ -242,7 +252,16 @@ void NFMModSource::pullAF(Real& sample)
|
||||
case NFMModSettings::NFMModInputAudio:
|
||||
if (m_audioBufferFill < m_audioBuffer.size())
|
||||
{
|
||||
sample = ((m_audioBuffer[m_audioBufferFill].l + m_audioBuffer[m_audioBufferFill].r) / 65536.0f) * m_settings.m_volumeFactor;
|
||||
if (m_settings.m_compressorEnable)
|
||||
{
|
||||
sample = ((m_audioBuffer[m_audioBufferFill].l + m_audioBuffer[m_audioBufferFill].r) / 3276.8f);
|
||||
sample = clamp<float>(m_audioCompressor.compress(sample), -1.0f, 1.0f) * m_settings.m_volumeFactor * 3.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample = ((m_audioBuffer[m_audioBufferFill].l + m_audioBuffer[m_audioBufferFill].r) / 3276.8f) * m_settings.m_volumeFactor;
|
||||
}
|
||||
|
||||
m_audioBufferFill++;
|
||||
}
|
||||
else
|
||||
@ -365,6 +384,8 @@ void NFMModSource::applyAudioSampleRate(int sampleRate)
|
||||
m_cwKeyer.setSampleRate(sampleRate);
|
||||
m_cwKeyer.reset();
|
||||
m_preemphasisFilter.configure(m_preemphasis*sampleRate);
|
||||
m_audioCompressor.m_rate = sampleRate;
|
||||
m_audioCompressor.initState();
|
||||
m_audioSampleRate = sampleRate;
|
||||
applyFeedbackAudioSampleRate(m_feedbackAudioSampleRate);
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "util/movingaverage.h"
|
||||
#include "dsp/cwkeyer.h"
|
||||
#include "audio/audiofifo.h"
|
||||
#include "audio/audiocompressorsnd.h"
|
||||
|
||||
#include "nfmmodsettings.h"
|
||||
#include "nfmmoddcs.h"
|
||||
@ -124,6 +125,8 @@ private:
|
||||
std::ifstream *m_ifstream;
|
||||
CWKeyer m_cwKeyer;
|
||||
|
||||
AudioCompressorSnd m_audioCompressor;
|
||||
|
||||
QMutex m_mutex;
|
||||
|
||||
static const int m_levelNbSamples;
|
||||
|
@ -122,7 +122,7 @@ You should aim at keeping the peak value below 100% using the volume control
|
||||
|
||||
<h3>10: Input source control</h3>
|
||||
|
||||
![Modulator input source control GUI](../../../doc/img/ModControls.png)
|
||||
![Modulator input source control GUI](../../../doc/img/NFMMod_plugin_input.png)
|
||||
|
||||
<h4>10.1: Tone input select</h4>
|
||||
|
||||
@ -142,6 +142,10 @@ Left click to switch to the audio input. You must switch it off to make other in
|
||||
|
||||
Right click to select audio input device. See [audio management documentation](../../../sdrgui/audio.md) for details.
|
||||
|
||||
<h4>10.5: Audio input compression</h4>
|
||||
|
||||
Toggles the compressor for the audio input.
|
||||
|
||||
<h3>11: Audio feedback</h3>
|
||||
|
||||
Activate or de-activate the input source audio feedback
|
||||
|
Loading…
Reference in New Issue
Block a user