1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-02-03 09:44:01 -05:00

NFM Modulator: use CW smoother

This commit is contained in:
f4exb 2016-12-14 23:59:25 +01:00
parent 1186e80663
commit 380eceaae5
2 changed files with 16 additions and 3 deletions

View File

@ -73,6 +73,7 @@ NFMMod::NFMMod() :
m_cwKeyer.setSampleRate(m_config.m_audioSampleRate); m_cwKeyer.setSampleRate(m_config.m_audioSampleRate);
m_cwKeyer.setWPM(13); m_cwKeyer.setWPM(13);
m_cwKeyer.setMode(CWKeyer::CWNone); m_cwKeyer.setMode(CWKeyer::CWNone);
m_cwSmoother.setNbFadeSamples(96); // 2 ms @ 48 kHz
} }
NFMMod::~NFMMod() NFMMod::~NFMMod()
@ -188,15 +189,25 @@ void NFMMod::pullAF(Real& sample)
sample = ((audioSample[0] + audioSample[1]) / 65536.0f) * m_running.m_volumeFactor; sample = ((audioSample[0] + audioSample[1]) / 65536.0f) * m_running.m_volumeFactor;
break; break;
case NFMModInputCWTone: case NFMModInputCWTone:
Real fadeFactor;
if (m_cwKeyer.getSample()) if (m_cwKeyer.getSample())
{ {
sample = m_toneNco.next(); m_cwSmoother.getFadeSample(true, fadeFactor);
sample = m_toneNco.next() * fadeFactor;
}
else
{
if (m_cwSmoother.getFadeSample(false, fadeFactor))
{
sample = m_toneNco.next() * fadeFactor;
} }
else else
{ {
sample = 0.0f; sample = 0.0f;
m_toneNco.setPhase(0); m_toneNco.setPhase(0);
} }
}
break; break;
case NFMModInputNone: case NFMModInputNone:
default: default:
@ -366,6 +377,7 @@ void NFMMod::apply()
if (m_config.m_audioSampleRate != m_running.m_audioSampleRate) if (m_config.m_audioSampleRate != m_running.m_audioSampleRate)
{ {
m_cwKeyer.setSampleRate(m_config.m_audioSampleRate); m_cwKeyer.setSampleRate(m_config.m_audioSampleRate);
m_cwSmoother.setNbFadeSamples(m_config.m_audioSampleRate / 500); // 2 ms
} }
m_running.m_outputSampleRate = m_config.m_outputSampleRate; m_running.m_outputSampleRate = m_config.m_outputSampleRate;

View File

@ -322,6 +322,7 @@ private:
Real m_peakLevel; Real m_peakLevel;
Real m_levelSum; Real m_levelSum;
CWKeyer m_cwKeyer; CWKeyer m_cwKeyer;
CWSmoother m_cwSmoother;
static const int m_levelNbSamples; static const int m_levelNbSamples;
void apply(); void apply();