mirror of
https://github.com/gqrx-sdr/gqrx.git
synced 2024-09-21 10:47:10 +00:00
plotter: raise rate limit, use different criteria for histogram calc
Signed-off-by: Jeff Long <willcode4@gmail.com>
This commit is contained in:
parent
5e6855fc56
commit
32172d3ca5
@ -155,7 +155,7 @@
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Amount of smoothing for plot
|
||||
(histogram is not affected)</string>
|
||||
(persistence for histogram)</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
|
@ -1246,12 +1246,15 @@ void CPlotter::draw(bool newData)
|
||||
|
||||
const double frameTime = 1.0 / (double)fft_rate;
|
||||
|
||||
// Redraw the plot if it is visible.
|
||||
const bool doPlotter = (!m_2DPixmap.isNull()
|
||||
// Do plotter work only if visible.
|
||||
const bool plotterVisible = (!m_2DPixmap.isNull());
|
||||
|
||||
// Limit plotter drawing rate.
|
||||
const bool drawPlotter = (plotterVisible
|
||||
&& tnow_ms >= tlast_plot_drawn_ms + PLOTTER_UPDATE_LIMIT_MS);
|
||||
|
||||
// Do not waste time with histogram calculations unless in this mode.
|
||||
const bool doHistogram = m_PlotMode == PLOT_MODE_HISTOGRAM;
|
||||
const bool doHistogram = (plotterVisible && m_PlotMode == PLOT_MODE_HISTOGRAM);
|
||||
|
||||
// Use fewer histogram bins when statistics are sparse
|
||||
const int histBinsDisplayed = std::min(
|
||||
@ -1522,47 +1525,47 @@ void CPlotter::draw(bool newData)
|
||||
}
|
||||
}
|
||||
|
||||
// Update histogram IIR if it will be used.
|
||||
if (doHistogram)
|
||||
{
|
||||
const double gamma = 1.0;
|
||||
const double a = powf(1.0 - m_alpha, gamma);
|
||||
// fast attack ... leaving alternative here in case it's useful
|
||||
const double aAttack = 1.0;
|
||||
// const double aAttack = 1.0 - a * frameTime;
|
||||
const double aDecay = 1.0 - pow(a, 4.0 * frameTime);
|
||||
|
||||
histMax = 0.0;
|
||||
for (i = xmin; i < xmax; ++i) {
|
||||
for (j = 0; j < histBinsDisplayed; ++j)
|
||||
{
|
||||
double histV;
|
||||
const double histPrev = m_histIIR[i][j];
|
||||
const double histNew = m_histogram[i][j];
|
||||
// Fast response when invalid
|
||||
if (!m_histIIRValid)
|
||||
histV = histNew;
|
||||
else
|
||||
histV = histPrev + aAttack * histNew - aDecay * histPrev;
|
||||
m_histIIR[i][j] = std::max(histV, 0.0);
|
||||
histMax = std::max(histMax, histV);
|
||||
}
|
||||
}
|
||||
m_histIIRValid = true;
|
||||
|
||||
// 5 Hz time constant for colormap adjustment
|
||||
const double histMaxAlpha = std::min(5.0 * frameTime, 1.0);
|
||||
m_histMaxIIR = m_histMaxIIR * (1.0 - histMaxAlpha) + histMax * histMaxAlpha;
|
||||
}
|
||||
|
||||
// get/draw the 2D spectrum
|
||||
if (doPlotter)
|
||||
if (drawPlotter)
|
||||
{
|
||||
tlast_plot_drawn_ms = tnow_ms;
|
||||
|
||||
m_2DPixmap.fill(PLOTTER_BGD_COLOR);
|
||||
QPainter painter2(&m_2DPixmap);
|
||||
|
||||
// Update histogram IIR
|
||||
const double frameTime = 1.0 / (double)fft_rate;
|
||||
if (m_PlotMode == PLOT_MODE_HISTOGRAM)
|
||||
{
|
||||
const double gamma = 1.0;
|
||||
const double a = powf(1.0 - m_alpha, gamma);
|
||||
// fast attack ... leaving alternative here in case it's useful
|
||||
const double aAttack = 1.0;
|
||||
// const double aAttack = 1.0 - a * frameTime;
|
||||
const double aDecay = 1.0 - pow(a, 4.0 * frameTime);
|
||||
|
||||
histMax = 0.0;
|
||||
for (i = xmin; i < xmax; ++i) {
|
||||
for (j = 0; j < histBinsDisplayed; ++j)
|
||||
{
|
||||
double histV;
|
||||
const double histPrev = m_histIIR[i][j];
|
||||
const double histNew = m_histogram[i][j];
|
||||
// Fast response when invalid
|
||||
if (!m_histIIRValid)
|
||||
histV = histNew;
|
||||
else
|
||||
histV = histPrev + aAttack * histNew - aDecay * histPrev;
|
||||
m_histIIR[i][j] = std::max(histV, 0.0);
|
||||
histMax = std::max(histMax, histV);
|
||||
}
|
||||
}
|
||||
m_histIIRValid = true;
|
||||
|
||||
// 5 Hz time constant for colormap adjustment
|
||||
const double histMaxAlpha = std::min(5.0 * frameTime, 1.0);
|
||||
m_histMaxIIR = m_histMaxIIR * (1.0 - histMaxAlpha) + histMax * histMaxAlpha;
|
||||
}
|
||||
|
||||
// draw the pandapter
|
||||
QBrush fillBrush = QBrush(m_FftFillCol);
|
||||
|
@ -18,7 +18,7 @@
|
||||
#define PEAK_CLICK_MAX_V_DISTANCE 20 //Maximum vertical distance of clicked point from peak
|
||||
#define PEAK_WINDOW_HALF_WIDTH 10
|
||||
#define PEAK_UPDATE_PERIOD 100 // msec
|
||||
#define PLOTTER_UPDATE_LIMIT_MS 32 // 32ms = 31.25 Hz
|
||||
#define PLOTTER_UPDATE_LIMIT_MS 16 // 16ms = 62.5 Hz
|
||||
|
||||
#define MARKER_OFF std::numeric_limits<qint64>::min()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user