1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-04-10 00:59:46 -04:00

Fix warnings

This commit is contained in:
Jon Beniston 2026-03-25 18:58:43 +00:00
parent a85903a12f
commit 6e21e689e9
10 changed files with 145 additions and 53 deletions

View File

@ -20,6 +20,7 @@
using namespace qtwebapp;
BufferLogger::BufferLogger(int maxSize, QObject *parent) :
Logger(parent),
m_maxSize(maxSize)
{
}
@ -41,7 +42,7 @@ QString BufferLogger::getLog() const
{
QString log;
for (const auto s : m_messages) {
for (const auto& s : m_messages) {
log.append(s);
}

View File

@ -2167,6 +2167,8 @@ void DeviceOpener::deviceSetAdded(int index, DeviceAPI *device)
void DeviceOpener::deviceChanged(int index)
{
(int) index;
// Apply device settings
QString errorMessage;
if (200 != m_device->getSampleSource()->webapiSettingsPutPatch(false, m_settingsKeys, *m_response, errorMessage)) {

View File

@ -105,6 +105,21 @@ void SpectrumVis::feedTriggered(const SampleVector::const_iterator& triggerPoint
}*/
}
void SpectrumVis::feed(const Complex *begin, unsigned int length)
{
if (!m_glSpectrum && !m_wsSpectrum.socketOpened()) {
return;
}
if (!m_mutex.tryLock(0)) { // prevent conflicts with configuration process
return;
}
processFFT(begin, false, false, length);
m_mutex.unlock();
}
void SpectrumVis::feed(const ComplexVector::const_iterator& cbegin, const ComplexVector::const_iterator& end, bool positiveOnly)
{
if (!m_running) {
@ -133,7 +148,7 @@ void SpectrumVis::feed(const ComplexVector::const_iterator& cbegin, const Comple
std::copy(begin, begin + samplesNeeded, m_fftBuffer.begin() + m_fftBufferFill);
begin += samplesNeeded;
processFFT(positiveOnly);
performFFT(positiveOnly);
// advance buffer respecting the fft overlap factor
// undefined behavior if the memory regions overlap, valid code for 50% overlap
@ -187,7 +202,7 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
*it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef);
}
processFFT(positiveOnly);
performFFT(positiveOnly);
// advance buffer respecting the fft overlap factor
// undefined behavior if the memory regions overlap, valid code for 50% overlap
@ -265,10 +280,8 @@ void SpectrumVis::mathDB(std::vector<Real> &spectrum)
}
}
void SpectrumVis::processFFT(bool positiveOnly)
void SpectrumVis::performFFT(bool positiveOnly)
{
PROFILER_START();
// apply fft window (and copy from m_fftBuffer to m_fftIn)
m_window.apply(&m_fftBuffer[0], m_fft->in());
@ -276,17 +289,23 @@ void SpectrumVis::processFFT(bool positiveOnly)
m_fft->transform();
// extract power spectrum and reorder buckets
const Complex* fftOut = m_fft->out();
processFFT(m_fft->out(), true, positiveOnly, m_settings.m_fftSize);
}
void SpectrumVis::processFFT(const Complex* fftOut, bool reorder, bool positiveOnly, int fftSize)
{
PROFILER_START();
Complex c;
Real v;
std::size_t halfSize = m_settings.m_fftSize / 2;
int halfSize = fftSize / 2;
bool ready = false;
if (m_settings.m_averagingMode == SpectrumSettings::AvgModeNone)
{
if (positiveOnly)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
@ -295,9 +314,9 @@ void SpectrumVis::processFFT(bool positiveOnly)
m_powerSpectrum[i * 2 + 1] = v;
}
}
else
else if (reorder)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i + halfSize];
v = c.real() * c.real() + c.imag() * c.imag();
@ -310,6 +329,16 @@ void SpectrumVis::processFFT(bool positiveOnly)
m_powerSpectrum[i + halfSize] = v;
}
}
else
{
for (int i = 0; i < fftSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
v *= m_powFFTMul;
m_powerSpectrum[i] = v;
}
}
ready = true;
}
@ -319,7 +348,7 @@ void SpectrumVis::processFFT(bool positiveOnly)
if (positiveOnly)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
@ -329,9 +358,9 @@ void SpectrumVis::processFFT(bool positiveOnly)
m_powerSpectrum[i * 2 + 1] = (Real) avg;
}
}
else
else if (reorder)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i + halfSize];
v = c.real() * c.real() + c.imag() * c.imag();
@ -346,6 +375,17 @@ void SpectrumVis::processFFT(bool positiveOnly)
m_powerSpectrum[i + halfSize] = (Real) avg;
}
}
else
{
for (int i = 0; i < fftSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
v *= m_powFFTMul;
avg = m_movingAverage.storeAndGetAvg(v, i);
m_powerSpectrum[i] = (Real) avg;
}
}
m_movingAverage.nextAverage();
ready = true;
@ -356,7 +396,7 @@ void SpectrumVis::processFFT(bool positiveOnly)
if (positiveOnly)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
@ -370,9 +410,9 @@ void SpectrumVis::processFFT(bool positiveOnly)
}
}
}
else
else if (reorder)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i + halfSize];
v = c.real() * c.real() + c.imag() * c.imag();
@ -393,6 +433,20 @@ void SpectrumVis::processFFT(bool positiveOnly)
}
}
}
else
{
for (int i = 0; i < fftSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
v *= m_powFFTMul;
// result available
if (m_fixedAverage.storeAndGetAvg(avg, v, i)) {
m_powerSpectrum[i] = avg;
}
}
}
// result available
if (m_fixedAverage.nextAverage()) {
@ -405,7 +459,7 @@ void SpectrumVis::processFFT(bool positiveOnly)
if (positiveOnly)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
@ -419,9 +473,9 @@ void SpectrumVis::processFFT(bool positiveOnly)
}
}
}
else
else if (reorder)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i + halfSize];
v = c.real() * c.real() + c.imag() * c.imag();
@ -442,6 +496,20 @@ void SpectrumVis::processFFT(bool positiveOnly)
}
}
}
else
{
for (int i = 0; i < fftSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
v *= m_powFFTMul;
// result available
if (m_max.storeAndGetMax(max, v, i)) {
m_powerSpectrum[i] = max;
}
}
}
// result available
if (m_max.nextMax()) {
@ -454,7 +522,7 @@ void SpectrumVis::processFFT(bool positiveOnly)
if (positiveOnly)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
@ -467,9 +535,9 @@ void SpectrumVis::processFFT(bool positiveOnly)
}
}
}
else
else if (reorder)
{
for (std::size_t i = 0; i < halfSize; i++)
for (int i = 0; i < halfSize; i++)
{
c = fftOut[i + halfSize];
v = c.real() * c.real() + c.imag() * c.imag();
@ -490,6 +558,19 @@ void SpectrumVis::processFFT(bool positiveOnly)
}
}
}
else
{
for (int i = 0; i < fftSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
v *= m_powFFTMul;
if (m_min.storeAndGetMin(min, v, i)) {
m_powerSpectrum[i] = min;
}
}
}
// result available
if (m_min.nextMin()) {
@ -499,6 +580,10 @@ void SpectrumVis::processFFT(bool positiveOnly)
if (ready)
{
for (int i = fftSize; i < m_settings.m_fftSize; i++) {
m_powerSpectrum[i] = 0.0f;
}
// Calculate maximum value in spectrum
m_specMax = *std::max_element(&m_powerSpectrum[0], &m_powerSpectrum[m_settings.m_fftSize]);

View File

@ -126,13 +126,14 @@ public:
void setMathMemory(const QList<Real> &values);
void getMathMovingAverageCopy(QList<Real>& copy);
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) override;
void feed(const ComplexVector::const_iterator& begin, const ComplexVector::const_iterator& end, bool positiveOnly);
void feed(const Complex *begin, unsigned int length) override; //!< feed output of FFT
void feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
virtual void stop();
virtual void pushMessage(Message *msg);
virtual QString getSinkName();
void start() override;
void stop() override;
void pushMessage(Message *msg) override;
QString getSinkName() override;
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
@ -221,7 +222,8 @@ private:
QRecursiveMutex m_mutex;
void processFFT(bool positiveOnly);
void performFFT(bool positiveOnly);
void processFFT(const Complex* fftOut, bool reorder, bool positiveOnly, int fftSize);
void setRunning(bool running) { m_running = running; }
void applySettings(const SpectrumSettings& settings, bool force = false);
bool handleMessage(const Message& message);

View File

@ -120,7 +120,7 @@ public:
void getAverages(std::vector<R> &values) const
{
values.resize(m_width);
for (int index = 0; index < m_width; index++) {
for (unsigned int index = 0; index < m_width; index++) {
values[index] = (R) (m_sum[index] / m_count);
}
}

View File

@ -1610,7 +1610,7 @@ void GLSpectrumGUI::smoothMem(int memoryIdx)
std::copy(m_settings.m_spectrumMemory[memoryIdx].m_spectrum.begin(), m_settings.m_spectrumMemory[memoryIdx].m_spectrum.end(), &temp[l]);
// Average n consequtive samples
for (int i = 0; i < size1; i++)
for (std::size_t i = 0; i < size1; i++)
{
Real sum = 0.0;
for (int j = 0; j < n; j++) {
@ -1629,7 +1629,7 @@ void GLSpectrumGUI::addMem(int memoryIdx)
{
std::size_t s = std::min(m_settings.m_spectrumMemory[0].m_spectrum.size(), m_settings.m_spectrumMemory[1].m_spectrum.size());
for (int i = 0; i < s; i++)
for (std::size_t i = 0; i < s; i++)
{
m_settings.m_spectrumMemory[memoryIdx].m_spectrum[i] =
m_settings.m_spectrumMemory[0].m_spectrum[i]
@ -1643,7 +1643,7 @@ void GLSpectrumGUI::diffMem(int memoryIdx)
{
std::size_t s = std::min(m_settings.m_spectrumMemory[0].m_spectrum.size(), m_settings.m_spectrumMemory[1].m_spectrum.size());
for (int i = 0; i < s; i++)
for (std::size_t i = 0; i < s; i++)
{
m_settings.m_spectrumMemory[memoryIdx].m_spectrum[i] =
m_settings.m_spectrumMemory[0].m_spectrum[i]

View File

@ -646,7 +646,7 @@ void GLSpectrumView::setMeasurementParams(
void GLSpectrumView::resetMeasurements()
{
m_mutex.lock();
for (int i = 0; i < m_maskFails.size(); ++i)
for (std::size_t i = 0; i < m_maskFails.size(); ++i)
{
m_maskTestCount[i] = 0;
m_maskFailCount[i] = 0;
@ -797,7 +797,7 @@ void GLSpectrumView::setScrolling(bool enabled, int length)
}
else
{
while (m_spectrumBuffer.size() > length)
while (m_spectrumBuffer.size() > (std::size_t) length)
{
if (m_currentSpectrum == m_spectrumBuffer.takeFirst().m_spectrum) {
m_currentSpectrum = nullptr;
@ -948,7 +948,7 @@ void GLSpectrumView::writeCSV(QTextStream &out)
else
{
out << "\"Date and Time\",\"Center Frequency (Hz)\",\"Sample Rate (Hz)\",\"Power\"\n";
for (int j = 0; j < m_spectrumBuffer.size(); j++)
for (std::size_t j = 0; j < m_spectrumBuffer.size(); j++)
{
out << m_spectrumBuffer[j].m_dateTime.toString(Qt::ISODateWithMs) << "," << m_spectrumBuffer[j].m_centerFrequency << "," << m_spectrumBuffer[j].m_sampleRate << ",";
for (int i = 0; i < m_spectrumBufferFFTSize; i++) {
@ -970,7 +970,7 @@ bool GLSpectrumView::writeImage(const QString& filename)
// Get center frequency for currently displayed spectrum (which is selected via the scroll bar)
qint64 GLSpectrumView::getDisplayedCenterFrequency() const
{
int idx = m_spectrumBuffer.size() - 1 - scrollBarValue();
std::size_t idx = m_spectrumBuffer.size() - 1 - scrollBarValue();
if ((idx >= 0) && (idx < m_spectrumBuffer.size())) {
return m_spectrumBuffer[idx].m_centerFrequency;
@ -982,7 +982,7 @@ qint64 GLSpectrumView::getDisplayedCenterFrequency() const
// Get sample rate for currently displayed spectrum (which is selected via the scroll bar)
quint32 GLSpectrumView::getDisplayedSampleRate() const
{
int idx = m_spectrumBuffer.size() - 1 - scrollBarValue();
std::size_t idx = m_spectrumBuffer.size() - 1 - scrollBarValue();
if ((idx >= 0) && (idx < m_spectrumBuffer.size())) {
return m_spectrumBuffer[idx].m_sampleRate;
@ -995,7 +995,8 @@ void GLSpectrumView::redrawSpectrum()
{
if (m_spectrumBuffer.size() > 0)
{
int idx = m_spectrumBuffer.size() - 1 - scrollBarValue();
std::size_t idx = m_spectrumBuffer.size() - 1 - scrollBarValue();
if (idx >= 0 && idx < m_spectrumBuffer.size())
{
updateHistogram(m_spectrumBuffer[idx].m_spectrum, m_fftSize, m_fftMin, m_nbBins);
@ -1008,7 +1009,7 @@ void GLSpectrumView::redrawWaterfallAnd3DSpectrogram()
{
if (m_waterfallBuffer && m_spectrumBuffer.size() > 0)
{
int idx = m_spectrumBuffer.size() - 1 - m_waterfallBuffer->height() - scrollBarValue();
std::size_t idx = m_spectrumBuffer.size() - 1 - m_waterfallBuffer->height() - scrollBarValue();
m_waterfallBufferPos = 0;
m_waterfallTexturePos = 0;
@ -1127,7 +1128,7 @@ void GLSpectrumView::newSpectrum(const Real *spectrum, int fftSize, quint32 samp
void GLSpectrumView::updateSpectrumNoBuffer(const Real *spectrum, int fftSize)
{
if (m_spectrumNoBuffer.size() != fftSize) {
if (m_spectrumNoBuffer.size() != (std::size_t) fftSize) {
m_spectrumNoBuffer.resize(fftSize);
}
@ -1154,7 +1155,7 @@ void GLSpectrumView::updateSpectrumBuffer(const Real *spectrum, int fftSize, qui
// Reuse old buffer if possible, otherwise allocate new buffer
Real *buffer = nullptr;
if (m_spectrumBuffer.size() >= m_spectrumBufferMaxSize) {
if (m_spectrumBuffer.size() >= (std::size_t) m_spectrumBufferMaxSize) {
buffer = m_spectrumBuffer.takeFirst().m_spectrum;
}
if (!buffer) {
@ -1894,7 +1895,7 @@ void GLSpectrumView::paintGL()
for (int m = 0; m < m_spectrumMemory.size(); m++)
{
if ( (m_spectrumMemory[m].m_spectrum.size() == m_fftSize)
&& (m_maskFails[m].size() == m_fftSize)
&& (m_maskFails[m].size() == (std::size_t) m_fftSize)
&& ((m_measurementMemMasks & (1 << m)) != 0)
)
{
@ -2011,9 +2012,6 @@ void GLSpectrumView::paintGL()
q3 = m_q3FFT.m_array;
for (int i = 0; i < m_nbBins; i++)
{
Real q1 = m_currentSpectrum[0];
Real q2 = m_currentSpectrum[m_fftMin + i];
Real q = m_currentSpectrum[m_fftMin + i] - m_referenceLevel;
Real v = clampPower(m_currentSpectrum[m_fftMin + i] - m_referenceLevel);
q3[2*i] = (Real) i;
@ -3195,7 +3193,7 @@ void GLSpectrumView::measureMask(const Real *spectrum, int fftSize, bool updateG
{
if ((m_measurementMemMasks & (1 << m)) != 0)
{
if (m_maskFails[m].size() < fftSize) {
if (m_maskFails[m].size() < (std::size_t) fftSize) {
m_maskFails[m].resize(fftSize);
}
@ -3250,9 +3248,9 @@ void GLSpectrumView::stopDrag()
// value is [0,m_waterfallHeight], as set in setTimeScaleRange()
QString GLSpectrumView::formatTick(double value) const
{
int idx = value - scrollBarValue() + m_spectrumBuffer.size() - 1 - m_waterfallHeight;
std::size_t idx = value - scrollBarValue() + m_spectrumBuffer.size() - 1 - m_waterfallHeight;
if (idx >= 0 && idx < m_spectrumBuffer.size())
if ((idx >= 0) && (idx < m_spectrumBuffer.size()))
{
QDateTime dt = m_spectrumBuffer[idx].m_dateTime;

View File

@ -164,6 +164,8 @@ void SpectrumDisplaySettingsDialog::on_scrollLength_valueChanged(int value)
void SpectrumDisplaySettingsDialog::on_spectrumColor_clicked(bool checked)
{
(void) checked;
QColorDialog dialog(QColor::fromRgba(m_spectrumColor), ui->spectrumColor);
if (dialog.exec() == QDialog::Accepted)
{
@ -182,6 +184,8 @@ void SpectrumDisplaySettingsDialog::on_memIdx_currentIndexChanged(int index)
void SpectrumDisplaySettingsDialog::on_memColor_clicked(bool checked)
{
(void) checked;
QColorDialog dialog(QColor::fromRgba(m_memorySettings[ui->memIdx->currentIndex()].m_color), ui->memColor);
if (dialog.exec() == QDialog::Accepted)
{

View File

@ -725,9 +725,9 @@ void SpectrumMeasurements::updateMeasurement(int row, float value, bool updateGU
QString spec = m_table->item(row, COL_SPEC)->text();
bool valueOK = checkSpec(spec, value);
bool meanOK = checkSpec(spec, mean);
bool minOK = checkSpec(spec, m_measurements[row].m_min);
bool mmaxOK = checkSpec(spec, m_measurements[row].m_max);
checkSpec(spec, mean);
checkSpec(spec, m_measurements[row].m_min);
checkSpec(spec, m_measurements[row].m_max);
if (!valueOK) {
m_measurements[row].m_fails++;

View File

@ -3423,7 +3423,7 @@ void MainWindow::startAll()
startAllDevices(workspace);
}
// Start all features
for (int featureSetIndex = 0; featureSetIndex < m_featureUIs.size(); featureSetIndex++)
for (std::size_t featureSetIndex = 0; featureSetIndex < m_featureUIs.size(); featureSetIndex++)
{
for (int featureIndex = 0; featureIndex < m_featureUIs[featureSetIndex]->getNumberOfFeatures(); featureIndex++) {
FeatureWebAPIUtils::run(featureSetIndex, featureIndex);