1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-22 01:20:56 -05:00

WideFM gain.

This commit is contained in:
John Greb 2014-12-22 19:33:50 +00:00
parent 6de854e8d6
commit 1752be6262
2 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////
// (c) 2014 John Greb //
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
@ -36,6 +37,8 @@ WFMDemod::WFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
m_audioBuffer.resize(256);
m_audioBufferFill = 0;
m_scale = 0;
}
WFMDemod::~WFMDemod()
@ -48,17 +51,22 @@ void WFMDemod::configure(MessageQueue* messageQueue, Real afBandwidth, Real volu
cmd->submit(messageQueue, this);
}
/*
* Experimental. Code taken from RTL_FM does not work as well here as it does there.
*/
void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
{
qint16 sample;
double meansqr = 1.0;
for(SampleVector::const_iterator it = begin; it < end; ++it) {
Real a = (0.005) * m_this.real() * (m_last.imag() - it->imag());
Real b = (0.005) * m_this.imag() * (m_last.real() - it->real());
Real a = m_scale * m_this.real() * (m_last.imag() - it->imag());
Real b = m_scale * m_this.imag() * (m_last.real() - it->real());
m_last = m_this;
m_this = Complex(it->real(), it->imag());
Complex e(b - a, 0);
Complex c;
meansqr += it->real() * it->real() + it->imag() * it->imag();
if(m_interpolator.interpolate(&m_sampleDistanceRemain, e, &c)) {
// TODO: Volume is a function of bandwidth
@ -83,6 +91,9 @@ void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
if(m_sampleSink != NULL)
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
m_sampleBuffer.clear();
// moving average auto-gain
m_scale = 0.8 * m_scale + 0.2 * ( end - begin) * 20.0 / meansqr;
}
void WFMDemod::start() {}

View File

@ -73,6 +73,8 @@ private:
int m_sampleRate;
int m_frequency;
double m_scale;
Interpolator m_interpolator;
Real m_sampleDistanceRemain;
Complex m_last, m_this;