FreeDV demod: stats in the GUI (2)

pull/304/head
f4exb 2019-02-27 18:37:07 +01:00
rodzic 2c76698857
commit ac5b6c184a
4 zmienionych plików z 41 dodań i 12 usunięć

Wyświetl plik

@ -299,7 +299,9 @@ FreeDVDemodGUI::FreeDVDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
ui->snrMeter->setColorTheme(LevelMeterSignalDB::ColorCyanAndBlue);
ui->snrMeter->setRange(-20, 30);
ui->snrMeter->setAverageSmoothing(2);
m_channelMarker.setVisible(true); // activate signal on the last setting only
@ -474,6 +476,16 @@ void FreeDVDemodGUI::tick()
ui->channelPower->setText(tr("%1 dB").arg(powDbAvg, 0, 'f', 1));
}
double snrAvg, snrPeak;
int nbSNRSamples;
m_freeDVDemod->getSNRLevels(snrAvg, snrPeak, nbSNRSamples);
ui->snrMeter->levelChanged(
(20.0f + snrAvg) / 50.0f,
(20.0f + snrPeak) / 50.0f,
nbSNRSamples
);
bool squelchOpen = m_freeDVDemod->getAudioActive();
if (squelchOpen != m_squelchOpen)

Wyświetl plik

@ -523,7 +523,7 @@
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
<height>24</height>
</size>
</property>
<property name="font">

Wyświetl plik

@ -64,6 +64,7 @@ LevelMeter::LevelMeter(QWidget *parent)
, m_decayedPeakLevel(0.0)
, m_peakDecayRate(PeakDecayRate)
, m_peakHoldLevel(0.0)
, m_avgSmoothing(256)
, m_redrawTimer(new QTimer(this))
, m_avgColor(0xff, 0x8b, 0x00, 128) // color mapper foreground
, m_peakColor(Qt::red) // just red 100% opaque
@ -94,7 +95,7 @@ void LevelMeter::reset()
void LevelMeter::levelChanged(qreal avgLevel, qreal peakLevel, int numSamples)
{
// Smooth the RMS signal
const qreal smooth = pow(qreal(0.9), static_cast<qreal>(numSamples) / 256); // TODO: remove this magic number
const qreal smooth = pow(qreal(0.9), static_cast<qreal>(numSamples) / m_avgSmoothing);
m_avgLevel = (m_avgLevel * smooth) + (avgLevel * (1.0 - smooth));
if (peakLevel > m_decayedPeakLevel) {
@ -143,6 +144,11 @@ void LevelMeter::resizeEvent(QResizeEvent * event)
resized();
}
void LevelMeter::setAverageSmoothing(uint32_t smoothingFactor)
{
m_avgSmoothing = smoothingFactor < 1 ? 1 : smoothingFactor > 256 ? 256 : smoothingFactor;
}
// ====================================================================
LevelMeterVU::LevelMeterVU(QWidget *parent) :
@ -251,22 +257,25 @@ void LevelMeterVU::render(QPainter *painter)
// ====================================================================
const QColor LevelMeterSignalDB::m_avgColor[3] = {
const QColor LevelMeterSignalDB::m_avgColor[4] = {
QColor(0xff, 0x8b, 0x00, 128),
QColor(0x8c, 0xff, 0x00, 128),
QColor(0x8c, 0xff, 0x00, 128)
QColor(0x8c, 0xff, 0x00, 128),
QColor(0x8c, 0xbf, 0xff, 128),
};
const QColor LevelMeterSignalDB::m_decayedPeakColor[3] = {
const QColor LevelMeterSignalDB::m_decayedPeakColor[4] = {
QColor(0x97, 0x54, 0x00, 128),
QColor(0x53, 0x96, 0x00, 128),
QColor(0x00, 0x96, 0x53, 128)
QColor(0x00, 0x96, 0x53, 128),
QColor(0x00, 0x94, 0x94, 128),
};
const QColor LevelMeterSignalDB::m_peakColor[3] = {
const QColor LevelMeterSignalDB::m_peakColor[4] = {
Qt::red,
Qt::green,
Qt::green
Qt::green,
Qt::cyan
};
LevelMeterSignalDB::LevelMeterSignalDB(QWidget *parent) :

Wyświetl plik

@ -70,6 +70,8 @@ public:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent * event);
void setAverageSmoothing(uint32_t smoothingFactor);
public slots:
void reset();
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
@ -119,6 +121,11 @@ protected:
*/
QTime m_peakHoldLevelChanged;
/**
* Average smoothing factor (between 1: fast and 256: slow)
*/
uint32_t m_avgSmoothing;
QTimer *m_redrawTimer;
QColor m_avgColor;
@ -155,7 +162,8 @@ public:
{
ColorGold,
ColorGreenYellow,
ColorGreenAndBlue
ColorGreenAndBlue,
ColorCyanAndBlue
} ColorTheme;
LevelMeterSignalDB(QWidget *parent = 0);
@ -164,9 +172,9 @@ public:
void setColorTheme(ColorTheme colorTheme) { m_colorTheme = colorTheme; }
void setRange(int min, int max);
static const QColor m_avgColor[3];
static const QColor m_decayedPeakColor[3];
static const QColor m_peakColor[3];
static const QColor m_avgColor[4];
static const QColor m_decayedPeakColor[4];
static const QColor m_peakColor[4];
protected:
virtual void render(QPainter *painter);