mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-05 14:47:50 -04:00
Fixed glitches in channel analyzer decimation
This commit is contained in:
parent
aa66d26059
commit
1450289e0f
@ -33,8 +33,8 @@ ENDIF()
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
#include(${QT_USE_FILE})
|
#include(${QT_USE_FILE})
|
||||||
#set( QT_DEFINITIONS "${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT" )
|
set( QT_DEFINITIONS "${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT" )
|
||||||
set( QT_DEFINITIONS "${QT_DEFINITIONS}" )
|
#set( QT_DEFINITIONS "${QT_DEFINITIONS}" )
|
||||||
add_definitions(${QT_DEFINITIONS})
|
add_definitions(${QT_DEFINITIONS})
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -38,6 +38,7 @@ ChannelAnalyzer::ChannelAnalyzer(SampleSink* sampleSink) :
|
|||||||
m_nco.setFreq(m_frequency, m_sampleRate);
|
m_nco.setFreq(m_frequency, m_sampleRate);
|
||||||
m_nco_test.setFreq(m_frequency, m_sampleRate);
|
m_nco_test.setFreq(m_frequency, m_sampleRate);
|
||||||
m_undersampleCount = 0;
|
m_undersampleCount = 0;
|
||||||
|
m_sum = 0;
|
||||||
m_usb = true;
|
m_usb = true;
|
||||||
m_ssb = true;
|
m_ssb = true;
|
||||||
SSBFilter = new fftfilt(m_LowCutoff / m_sampleRate, m_Bandwidth / m_sampleRate, ssbFftLen);
|
SSBFilter = new fftfilt(m_LowCutoff / m_sampleRate, m_Bandwidth / m_sampleRate, ssbFftLen);
|
||||||
@ -62,7 +63,7 @@ void ChannelAnalyzer::configure(MessageQueue* messageQueue,
|
|||||||
|
|
||||||
void ChannelAnalyzer::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
|
void ChannelAnalyzer::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
fftfilt::cmplx *sideband, sum;
|
fftfilt::cmplx *sideband;
|
||||||
int n_out;
|
int n_out;
|
||||||
int decim = 1<<m_spanLog2;
|
int decim = 1<<m_spanLog2;
|
||||||
unsigned char decim_mask = decim - 1; // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
|
unsigned char decim_mask = decim - 1; // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
|
||||||
@ -88,22 +89,22 @@ void ChannelAnalyzer::feed(const SampleVector::const_iterator& begin, const Samp
|
|||||||
// Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
|
// Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
|
||||||
// smart decimation with bit gain using float arithmetic (23 bits significand)
|
// smart decimation with bit gain using float arithmetic (23 bits significand)
|
||||||
|
|
||||||
sum += sideband[i];
|
m_sum += sideband[i];
|
||||||
|
|
||||||
if (!(m_undersampleCount++ & decim_mask))
|
if (!(m_undersampleCount++ & decim_mask))
|
||||||
{
|
{
|
||||||
sum /= decim;
|
m_sum /= decim;
|
||||||
|
|
||||||
if (m_ssb & !m_usb)
|
if (m_ssb & !m_usb)
|
||||||
{ // invert spectrum for LSB
|
{ // invert spectrum for LSB
|
||||||
m_sampleBuffer.push_back(Sample(sum.imag() * 32768.0, sum.real() * 32768.0));
|
m_sampleBuffer.push_back(Sample(m_sum.imag() * 32768.0, m_sum.real() * 32768.0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sampleBuffer.push_back(Sample(sum.real() * 32768.0, sum.imag() * 32768.0));
|
m_sampleBuffer.push_back(Sample(m_sum.real() * 32768.0, m_sum.imag() * 32768.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
sum = 0;
|
m_sum = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,7 @@ private:
|
|||||||
Real m_LowCutoff;
|
Real m_LowCutoff;
|
||||||
int m_spanLog2;
|
int m_spanLog2;
|
||||||
int m_undersampleCount;
|
int m_undersampleCount;
|
||||||
|
fftfilt::cmplx m_sum;
|
||||||
int m_sampleRate;
|
int m_sampleRate;
|
||||||
int m_frequency;
|
int m_frequency;
|
||||||
bool m_usb;
|
bool m_usb;
|
||||||
|
@ -80,15 +80,24 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
|
|||||||
if (m_triggerChannel == TriggerFreeRun)
|
if (m_triggerChannel == TriggerFreeRun)
|
||||||
{
|
{
|
||||||
int count = end - begin;
|
int count = end - begin;
|
||||||
|
|
||||||
if(count > (int)(m_trace.size() - m_fill))
|
if(count > (int)(m_trace.size() - m_fill))
|
||||||
|
{
|
||||||
count = m_trace.size() - m_fill;
|
count = m_trace.size() - m_fill;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Complex>::iterator it = m_trace.begin() + m_fill;
|
std::vector<Complex>::iterator it = m_trace.begin() + m_fill;
|
||||||
for(int i = 0; i < count; ++i) {
|
|
||||||
|
for(int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0);
|
*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0);
|
||||||
++begin;
|
++begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fill += count;
|
m_fill += count;
|
||||||
if(m_fill >= m_trace.size()) {
|
|
||||||
|
if(m_fill >= m_trace.size())
|
||||||
|
{
|
||||||
m_glScope->newTrace(m_trace, m_sampleRate);
|
m_glScope->newTrace(m_trace, m_sampleRate);
|
||||||
m_fill = 0;
|
m_fill = 0;
|
||||||
}
|
}
|
||||||
@ -123,6 +132,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_triggerState == Untriggered)
|
if(m_triggerState == Untriggered)
|
||||||
{
|
{
|
||||||
while(begin < end)
|
while(begin < end)
|
||||||
@ -172,20 +182,31 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
|
|||||||
++begin;
|
++begin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_triggerState == Triggered)
|
if(m_triggerState == Triggered)
|
||||||
{
|
{
|
||||||
int count = end - begin;
|
int count = end - begin;
|
||||||
|
|
||||||
if(count > (int)(m_trace.size() - m_fill))
|
if(count > (int)(m_trace.size() - m_fill))
|
||||||
|
{
|
||||||
count = m_trace.size() - m_fill;
|
count = m_trace.size() - m_fill;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Complex>::iterator it = m_trace.begin() + m_fill;
|
std::vector<Complex>::iterator it = m_trace.begin() + m_fill;
|
||||||
for(int i = 0; i < count; ++i) {
|
|
||||||
|
for(int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0);
|
*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0);
|
||||||
++begin;
|
++begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fill += count;
|
m_fill += count;
|
||||||
if(m_fill >= m_trace.size()) {
|
|
||||||
|
if(m_fill >= m_trace.size())
|
||||||
|
{
|
||||||
m_glScope->newTrace(m_trace, m_sampleRate);
|
m_glScope->newTrace(m_trace, m_sampleRate);
|
||||||
m_fill = 0;
|
m_fill = 0;
|
||||||
|
|
||||||
if (m_triggerOneShot) {
|
if (m_triggerOneShot) {
|
||||||
m_triggerState = WaitForReset;
|
m_triggerState = WaitForReset;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user