1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-22 17:45:48 -05:00

Spectrum averaging: display averaging time in tooltip. Bumped version to 4.0.2

This commit is contained in:
f4exb 2018-07-01 20:48:30 +02:00
parent a2674fa9de
commit e88a0d6b57
8 changed files with 122 additions and 13 deletions

View File

@ -35,7 +35,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
*/
QCoreApplication::setOrganizationName("f4exb");
QCoreApplication::setApplicationName("SDRangel");
QCoreApplication::setApplicationVersion("4.0.1");
QCoreApplication::setApplicationVersion("4.0.2");
#if 1
qApp->setStyle(QStyleFactory::create("fusion"));

View File

@ -57,7 +57,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
QCoreApplication::setOrganizationName("f4exb");
QCoreApplication::setApplicationName("SDRangelBench");
QCoreApplication::setApplicationVersion("4.0.1");
QCoreApplication::setApplicationVersion("4.0.2");
int catchSignals[] = {SIGQUIT, SIGINT, SIGTERM, SIGHUP};
std::vector<int> vsig(catchSignals, catchSignals + sizeof(catchSignals) / sizeof(int));

View File

@ -56,7 +56,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
QCoreApplication::setOrganizationName("f4exb");
QCoreApplication::setApplicationName("SDRangelSrv");
QCoreApplication::setApplicationVersion("4.0.1");
QCoreApplication::setApplicationVersion("4.0.2");
int catchSignals[] = {SIGQUIT, SIGINT, SIGTERM, SIGHUP};
std::vector<int> vsig(catchSignals, catchSignals + sizeof(catchSignals) / sizeof(int));

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
sdrangel (4.0.2-1) unstable; urgency=medium
* Spectrum: added averaging
-- Edouard Griffiths, F4EXB <f4exb06@gmail.com> Sun, 01 Jul 2018 21:14:18 +0200
sdrangel (4.0.1-1) unstable; urgency=medium
* DSD demod: added NXDN support

View File

@ -24,9 +24,12 @@
#include <QOpenGLFunctions>
#include <QPainter>
#include "gui/glspectrum.h"
#include "util/messagequeue.h"
#include <QDebug>
MESSAGE_CLASS_DEFINITION(GLSpectrum::MsgReportSampleRate, Message)
GLSpectrum::GLSpectrum(QWidget* parent) :
QGLWidget(parent),
m_cursorState(CSNormal),
@ -60,7 +63,8 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_displayHistogram(true),
m_displayChanged(false),
m_matrixLoc(0),
m_colorLoc(0)
m_colorLoc(0),
m_messageQueueToGUI(0)
{
setAutoFillBackground(false);
setAttribute(Qt::WA_OpaquePaintEvent, true);
@ -193,6 +197,9 @@ void GLSpectrum::setHistoStroke(int stroke)
void GLSpectrum::setSampleRate(qint32 sampleRate)
{
m_sampleRate = sampleRate;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportSampleRate(m_sampleRate));
}
m_changesPending = true;
update();
}

View File

@ -34,13 +34,32 @@
#include "dsp/channelmarker.h"
#include "export.h"
#include "util/incrementalarray.h"
#include "util/message.h"
class QOpenGLShaderProgram;
class MessageQueue;
class SDRGUI_API GLSpectrum : public QGLWidget {
Q_OBJECT
public:
class MsgReportSampleRate : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportSampleRate(quint32 sampleRate) :
Message(),
m_sampleRate(sampleRate)
{
m_sampleRate = sampleRate;
}
quint32 getSampleRate() const { return m_sampleRate; }
private:
quint32 m_sampleRate;
};
GLSpectrum(QWidget* parent = NULL);
~GLSpectrum();
@ -62,9 +81,11 @@ public:
void setDisplayGrid(bool display);
void setDisplayGridIntensity(int intensity);
void setDisplayTraceIntensity(int intensity);
qint32 getSampleRate() const { return m_sampleRate; }
void addChannelMarker(ChannelMarker* channelMarker);
void removeChannelMarker(ChannelMarker* channelMarker);
void setMessageQueueToGUI(MessageQueue* messageQueue) { m_messageQueueToGUI = messageQueue; }
void newSpectrum(const std::vector<Real>& spectrum, int fftSize);
void clearSpectrumHistogram();
@ -172,6 +193,8 @@ private:
IncrementalArray<GLfloat> m_q3TickPower;
IncrementalArray<GLfloat> m_q3FFT;
MessageQueue *m_messageQueueToGUI;
static const int m_waterfallBufferHeight = 256;
void updateWaterfall(const std::vector<Real>& spectrum);

View File

@ -8,7 +8,7 @@
GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
QWidget(parent),
ui(new Ui::GLSpectrumGUI),
m_messageQueue(0),
m_messageQueueToVis(0),
m_spectrumVis(0),
m_glSpectrum(0),
m_fftSize(1024),
@ -41,6 +41,7 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
for(int range = 100; range >= 5; range -= 5)
ui->levelRange->addItem(QString("%1").arg(range));
setAveragingCombo();
connect(&m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
GLSpectrumGUI::~GLSpectrumGUI()
@ -50,9 +51,10 @@ GLSpectrumGUI::~GLSpectrumGUI()
void GLSpectrumGUI::setBuddies(MessageQueue* messageQueue, SpectrumVis* spectrumVis, GLSpectrum* glSpectrum)
{
m_messageQueue = messageQueue;
m_messageQueueToVis = messageQueue;
m_spectrumVis = spectrumVis;
m_glSpectrum = glSpectrum;
m_glSpectrum->setMessageQueueToGUI(&m_messageQueue);
applySettings();
}
@ -193,20 +195,22 @@ void GLSpectrumGUI::applySettings()
m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity);
if (m_spectrumVis) {
m_spectrumVis->configure(m_messageQueue,
m_spectrumVis->configure(m_messageQueueToVis,
m_fftSize,
m_fftOverlap,
m_averagingNb,
m_averagingMode,
(FFTWindow::Function)m_fftWindow);
}
setAveragingToolitp();
}
void GLSpectrumGUI::on_fftWindow_currentIndexChanged(int index)
{
m_fftWindow = index;
if(m_spectrumVis != 0) {
m_spectrumVis->configure(m_messageQueue,
m_spectrumVis->configure(m_messageQueueToVis,
m_fftSize,
m_fftOverlap,
m_averagingNb,
@ -219,13 +223,14 @@ void GLSpectrumGUI::on_fftSize_currentIndexChanged(int index)
{
m_fftSize = 1 << (7 + index);
if(m_spectrumVis != 0) {
m_spectrumVis->configure(m_messageQueue,
m_spectrumVis->configure(m_messageQueueToVis,
m_fftSize,
m_fftOverlap,
m_averagingNb,
m_averagingMode,
(FFTWindow::Function)m_fftWindow);
}
setAveragingToolitp();
}
void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index)
@ -233,7 +238,7 @@ void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index)
m_averagingMode = index < 0 ? AvgModeMoving : index > 1 ? AvgModeFixed : (AveragingMode) index;
if(m_spectrumVis != 0) {
m_spectrumVis->configure(m_messageQueue,
m_spectrumVis->configure(m_messageQueueToVis,
m_fftSize,
m_fftOverlap,
m_averagingNb,
@ -257,7 +262,7 @@ void GLSpectrumGUI::on_averaging_currentIndexChanged(int index)
m_averagingNb = getAveragingValue(index);
if(m_spectrumVis != 0) {
m_spectrumVis->configure(m_messageQueue,
m_spectrumVis->configure(m_messageQueueToVis,
m_fftSize,
m_fftOverlap,
m_averagingNb,
@ -271,6 +276,8 @@ void GLSpectrumGUI::on_averaging_currentIndexChanged(int index)
m_glSpectrum->setTimingRate(m_averagingNb == 0 ? 1 : m_averagingNb);
}
}
setAveragingToolitp();
}
void GLSpectrumGUI::on_refLevel_currentIndexChanged(int index)
@ -481,3 +488,63 @@ void GLSpectrumGUI::setNumberStr(int n, QString& s)
s = tr("%1G").arg(n/1000000000);
}
}
void GLSpectrumGUI::setNumberStr(float v, int decimalPlaces, QString& s)
{
if (v < 1e-6) {
s = tr("%1n").arg(v*1e9, 0, 'f', decimalPlaces);
} else if (v < 1e-3) {
s = tr("%1µ").arg(v*1e6, 0, 'f', decimalPlaces);
} else if (v < 1.0) {
s = tr("%1m").arg(v*1e3, 0, 'f', decimalPlaces);
} else if (v < 1e3) {
s = tr("%1").arg(v, 0, 'f', decimalPlaces);
} else if (v < 1e6) {
s = tr("%1k").arg(v*1e-3, 0, 'f', decimalPlaces);
} else if (v < 1e9) {
s = tr("%1M").arg(v*1e-6, 0, 'f', decimalPlaces);
} else {
s = tr("%1G").arg(v*1e-9, 0, 'f', decimalPlaces);
}
}
void GLSpectrumGUI::setAveragingToolitp()
{
if (m_glSpectrum)
{
QString s;
float averagingTime = (m_fftSize * m_averagingNb) / (float) m_glSpectrum->getSampleRate();
setNumberStr(averagingTime, 2, s);
ui->averaging->setToolTip(QString("Number of averaging samples (avg time: %1s)").arg(s));
}
else
{
ui->averaging->setToolTip(QString("Number of averaging samples"));
}
}
bool GLSpectrumGUI::handleMessage(const Message& message)
{
if (GLSpectrum::MsgReportSampleRate::match(message))
{
setAveragingToolitp();
return true;
}
return false;
}
void GLSpectrumGUI::handleInputMessages()
{
Message* message;
while ((message = m_messageQueue.pop()) != 0)
{
qDebug("GLSpectrumGUI::handleInputMessages: message: %s", message->getIdentifier());
if (handleMessage(*message))
{
delete message;
}
}
}

View File

@ -5,12 +5,12 @@
#include "dsp/dsptypes.h"
#include "export.h"
#include "settings/serializable.h"
#include "util/messagequeue.h"
namespace Ui {
class GLSpectrumGUI;
}
class MessageQueue;
class SpectrumVis;
class GLSpectrum;
@ -36,9 +36,10 @@ public:
private:
Ui::GLSpectrumGUI* ui;
MessageQueue* m_messageQueue;
MessageQueue* m_messageQueueToVis;
SpectrumVis* m_spectrumVis;
GLSpectrum* m_glSpectrum;
MessageQueue m_messageQueue;
qint32 m_fftSize;
qint32 m_fftOverlap;
@ -67,6 +68,9 @@ private:
int getAveragingValue(int averagingIndex) const;
void setAveragingCombo();
void setNumberStr(int n, QString& s);
void setNumberStr(float v, int decimalPlaces, QString& s);
void setAveragingToolitp();
bool handleMessage(const Message& message);
private slots:
void on_fftWindow_currentIndexChanged(int index);
@ -88,6 +92,8 @@ private slots:
void on_invert_toggled(bool checked);
void on_grid_toggled(bool checked);
void on_clearSpectrum_clicked(bool checked);
void handleInputMessages();
};
#endif // INCLUDE_GLSPECTRUMGUI_H