mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-18 07:35:47 -05:00
DC correction needs floating point.
This commit is contained in:
parent
e2b1a06772
commit
85b088cead
@ -91,8 +91,7 @@ private:
|
|||||||
|
|
||||||
bool m_dcOffsetCorrection;
|
bool m_dcOffsetCorrection;
|
||||||
bool m_iqImbalanceCorrection;
|
bool m_iqImbalanceCorrection;
|
||||||
qint32 m_iOffset;
|
double m_iOffset, m_qOffset;
|
||||||
qint32 m_qOffset;
|
|
||||||
qint32 m_iRange;
|
qint32 m_iRange;
|
||||||
qint32 m_qRange;
|
qint32 m_qRange;
|
||||||
qint32 m_imbalance;
|
qint32 m_imbalance;
|
||||||
|
@ -71,6 +71,8 @@ void DSPEngine::stopAcquistion()
|
|||||||
{
|
{
|
||||||
DSPAcquisitionStop cmd;
|
DSPAcquisitionStop cmd;
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_messageQueue);
|
||||||
|
if(m_dcOffsetCorrection)
|
||||||
|
qDebug("DC offset:%f,%f", m_iOffset, m_qOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::setSource(SampleSource* source)
|
void DSPEngine::setSource(SampleSource* source)
|
||||||
@ -135,24 +137,22 @@ void DSPEngine::run()
|
|||||||
|
|
||||||
void DSPEngine::dcOffset(SampleVector::iterator begin, SampleVector::iterator end)
|
void DSPEngine::dcOffset(SampleVector::iterator begin, SampleVector::iterator end)
|
||||||
{
|
{
|
||||||
int count = end - begin;
|
double count;
|
||||||
int io = 0;
|
int io = 0;
|
||||||
int qo = 0;
|
int qo = 0;
|
||||||
|
Sample corr((qint16)m_iOffset, (qint16)m_qOffset);
|
||||||
|
|
||||||
// sum all sample components
|
// sum and correct in one pass
|
||||||
for(SampleVector::iterator it = begin; it < end; it++) {
|
for(SampleVector::iterator it = begin; it < end; it++) {
|
||||||
io += it->real();
|
io += it->real();
|
||||||
qo += it->imag();
|
qo += it->imag();
|
||||||
|
*it -= corr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// build a sliding average (el cheapo style)
|
// moving average
|
||||||
m_iOffset = (m_iOffset * 3 + io / count) >> 2;
|
count = end - begin;
|
||||||
m_qOffset = (m_qOffset * 3 + qo / count) >> 2;
|
m_iOffset = (15.0 * m_iOffset + (double)io / count) / 16.0;
|
||||||
|
m_qOffset = (15.0 * m_qOffset + (double)qo / count) / 16.0;
|
||||||
// correct samples
|
|
||||||
Sample corr(m_iOffset, m_qOffset);
|
|
||||||
for(SampleVector::iterator it = begin; it < end; it++)
|
|
||||||
*it -= corr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::imbalance(SampleVector::iterator begin, SampleVector::iterator end)
|
void DSPEngine::imbalance(SampleVector::iterator begin, SampleVector::iterator end)
|
||||||
|
Loading…
Reference in New Issue
Block a user