mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05: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})
|
||||
#set( QT_DEFINITIONS "${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT" )
|
||||
set( QT_DEFINITIONS "${QT_DEFINITIONS}" )
|
||||
set( QT_DEFINITIONS "${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT" )
|
||||
#set( QT_DEFINITIONS "${QT_DEFINITIONS}" )
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
|
||||
if(MSVC)
|
||||
|
@ -38,6 +38,7 @@ ChannelAnalyzer::ChannelAnalyzer(SampleSink* sampleSink) :
|
||||
m_nco.setFreq(m_frequency, m_sampleRate);
|
||||
m_nco_test.setFreq(m_frequency, m_sampleRate);
|
||||
m_undersampleCount = 0;
|
||||
m_sum = 0;
|
||||
m_usb = true;
|
||||
m_ssb = true;
|
||||
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)
|
||||
{
|
||||
fftfilt::cmplx *sideband, sum;
|
||||
fftfilt::cmplx *sideband;
|
||||
int n_out;
|
||||
int decim = 1<<m_spanLog2;
|
||||
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
|
||||
// smart decimation with bit gain using float arithmetic (23 bits significand)
|
||||
|
||||
sum += sideband[i];
|
||||
m_sum += sideband[i];
|
||||
|
||||
if (!(m_undersampleCount++ & decim_mask))
|
||||
{
|
||||
sum /= decim;
|
||||
m_sum /= decim;
|
||||
|
||||
if (m_ssb & !m_usb)
|
||||
{ // 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
|
||||
{
|
||||
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;
|
||||
int m_spanLog2;
|
||||
int m_undersampleCount;
|
||||
fftfilt::cmplx m_sum;
|
||||
int m_sampleRate;
|
||||
int m_frequency;
|
||||
bool m_usb;
|
||||
|
@ -80,15 +80,24 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
|
||||
if (m_triggerChannel == TriggerFreeRun)
|
||||
{
|
||||
int count = end - begin;
|
||||
|
||||
if(count > (int)(m_trace.size() - m_fill))
|
||||
{
|
||||
count = m_trace.size() - 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);
|
||||
++begin;
|
||||
}
|
||||
|
||||
m_fill += count;
|
||||
if(m_fill >= m_trace.size()) {
|
||||
|
||||
if(m_fill >= m_trace.size())
|
||||
{
|
||||
m_glScope->newTrace(m_trace, m_sampleRate);
|
||||
m_fill = 0;
|
||||
}
|
||||
@ -123,6 +132,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(m_triggerState == Untriggered)
|
||||
{
|
||||
while(begin < end)
|
||||
@ -172,20 +182,31 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
|
||||
++begin;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_triggerState == Triggered)
|
||||
{
|
||||
int count = end - begin;
|
||||
|
||||
if(count > (int)(m_trace.size() - m_fill))
|
||||
{
|
||||
count = m_trace.size() - 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);
|
||||
++begin;
|
||||
}
|
||||
|
||||
m_fill += count;
|
||||
if(m_fill >= m_trace.size()) {
|
||||
|
||||
if(m_fill >= m_trace.size())
|
||||
{
|
||||
m_glScope->newTrace(m_trace, m_sampleRate);
|
||||
m_fill = 0;
|
||||
|
||||
if (m_triggerOneShot) {
|
||||
m_triggerState = WaitForReset;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user