mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-29 13:32:26 -04:00
Frequency Scanner: Fix rounding error that prevent some channels from being scanned, depending on sample rate.
This commit is contained in:
parent
2baea0364b
commit
fd1d411bf0
@ -198,7 +198,9 @@ void FreqScanner::stop()
|
|||||||
qDebug("FreqScanner::stop");
|
qDebug("FreqScanner::stop");
|
||||||
m_running = false;
|
m_running = false;
|
||||||
m_thread->exit();
|
m_thread->exit();
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
m_thread->wait();
|
m_thread->wait();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FreqScanner::handleMessage(const Message& cmd)
|
bool FreqScanner::handleMessage(const Message& cmd)
|
||||||
@ -343,9 +345,9 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList<
|
|||||||
int binsPerChannel;
|
int binsPerChannel;
|
||||||
calcScannerSampleRate(m_settings.m_channelBandwidth, m_basebandSampleRate, m_scannerSampleRate, fftSize, binsPerChannel);
|
calcScannerSampleRate(m_settings.m_channelBandwidth, m_basebandSampleRate, m_scannerSampleRate, fftSize, binsPerChannel);
|
||||||
|
|
||||||
// Align first frequency so we cover as many channels as possible, while channel guard band
|
// Align first frequency so we cover as many channels as possible, while skipping channel guard band (12.5% either end)
|
||||||
// Can we adjust this to avoid DC bin?
|
// Can we adjust this to avoid DC bin?
|
||||||
m_stepStartFrequency = frequencies.front() + m_scannerSampleRate / 2 - m_scannerSampleRate * 0.125f;
|
m_stepStartFrequency = frequencies.front() + m_scannerSampleRate / 2 - (m_scannerSampleRate / 8);
|
||||||
m_stepStopFrequency = frequencies.back();
|
m_stepStopFrequency = frequencies.back();
|
||||||
|
|
||||||
// If all frequencies fit within usable bandwidth, we can have the first frequency more central
|
// If all frequencies fit within usable bandwidth, we can have the first frequency more central
|
||||||
@ -374,7 +376,7 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList<
|
|||||||
bool complete = false; // Have all frequencies been scanned?
|
bool complete = false; // Have all frequencies been scanned?
|
||||||
bool freqInRange = false;
|
bool freqInRange = false;
|
||||||
qint64 nextCenterFrequency = m_centerFrequency;
|
qint64 nextCenterFrequency = m_centerFrequency;
|
||||||
float usableBW = m_scannerSampleRate * 0.75f;
|
int usableBW = (m_scannerSampleRate * 3 / 4) & ~1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (nextCenterFrequency + usableBW / 2 > m_stepStopFrequency)
|
if (nextCenterFrequency + usableBW / 2 > m_stepStopFrequency)
|
||||||
|
@ -117,8 +117,8 @@ void FreqScannerSink::processOneSample(Complex &ci)
|
|||||||
qint64 diff = frequency - startFrequency;
|
qint64 diff = frequency - startFrequency;
|
||||||
float binBW = m_scannerSampleRate / (float)m_fftSize;
|
float binBW = m_scannerSampleRate / (float)m_fftSize;
|
||||||
|
|
||||||
// Ignore results in uppper and lower 12.5%, as there may be aliasing here from half-band filters
|
// Ignore results in upper and lower 12.5%, as there may be aliasing here from half-band filters
|
||||||
if ((diff < m_scannerSampleRate * 0.875f) && (diff >= m_scannerSampleRate * 0.125f))
|
if ((diff >= m_scannerSampleRate / 8) && (diff < m_scannerSampleRate * 7 / 8))
|
||||||
{
|
{
|
||||||
int bin = std::round(diff / binBW);
|
int bin = std::round(diff / binBW);
|
||||||
int channelBins;
|
int channelBins;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user