Skip to content

Commit

Permalink
Merge pull request #1067 from gqrx-sdr/meter-siglevel-float
Browse files Browse the repository at this point in the history
Improve accuracy and precision of S-meter display
  • Loading branch information
argilo authored Jan 15, 2022
2 parents 8edce55 + 514cc4e commit ea97a7c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions resources/news.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
IMPROVED: FFT and S-meter performance.
IMPROVED: Reduced FFT memory usage.
IMPROVED: Increased S-meter resolution to 0.1 dB.
IMPROVED: Accuracy of S-meter display.


2.15.2: Released January 8, 2022
Expand Down
19 changes: 12 additions & 7 deletions src/qtgui/meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void CMeter::setLevel(float dbfs)
float level = m_dBFS;
float alpha = dbfs < level ? ALPHA_DECAY : ALPHA_RISE;
m_dBFS -= alpha * (level - dbfs);
m_Siglevel = (int)((level - MIN_DB) * m_pixperdb);
m_Siglevel = (level - MIN_DB) * m_pixperdb;

draw();
}
Expand Down Expand Up @@ -169,12 +169,17 @@ void CMeter::draw()
qreal ht = (qreal) h * CTRL_NEEDLE_TOP;
qreal x = marg + m_Siglevel;

painter.setBrush(QBrush(QColor(0, 190, 0, 255)));
painter.setOpacity(1.0);

// Qt 4.8+ has a 1-pixel error (or they fixed line drawing)
// see http://stackoverflow.com/questions/16990326
painter.drawRect(marg - 1, ht + 1, x - marg, 6);
if (m_Siglevel > 0.0f)
{
QColor color(0, 190, 0, 255);
QPen pen(color);
pen.setJoinStyle(Qt::MiterJoin);
painter.setPen(pen);
painter.setBrush(QBrush(color));
painter.setOpacity(1.0);

painter.drawRect(QRectF(marg, ht + 2, x - marg, 4));
}

if (m_SqlLevel > 0.0f)
{
Expand Down
2 changes: 1 addition & 1 deletion src/qtgui/meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public slots:
QSize m_Size;
QString m_Str;
qreal m_pixperdb; // pixels / dB
int m_Siglevel;
qreal m_Siglevel;
float m_dBFS;
qreal m_Sql;
qreal m_SqlLevel;
Expand Down

0 comments on commit ea97a7c

Please sign in to comment.