1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 09:18:54 -05:00

GLSpectrum: calculate marker FFT marker frequency bin

This commit is contained in:
f4exb 2021-07-08 22:02:41 +02:00
parent bc3ac3731f
commit 9f8ce82287
2 changed files with 9 additions and 0 deletions

View File

@ -1964,6 +1964,8 @@ void GLSpectrum::applyChanges()
(m_histogramMarkers[i].m_frequency - m_frequencyScale.getRangeMin()) / m_frequencyScale.getRange();
m_histogramMarkers[i].m_point.ry() =
(m_powerScale.getRangeMax() - m_histogramMarkers[i].m_power) / m_powerScale.getRange();
m_histogramMarkers[i].m_fftBin =
(((m_histogramMarkers[i].m_frequency - m_centerFrequency) / (float) m_sampleRate) * m_fftSize) + (m_fftSize / 2);
}
// Waterfall markers
@ -2147,6 +2149,7 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
pHis.ry() = (ep.y()/height() - m_histogramRect.top()) / m_histogramRect.height();
float frequency = m_frequencyScale.getRangeMin() + pHis.x()*m_frequencyScale.getRange();
float power = m_powerScale.getRangeMax() - pHis.y()*m_powerScale.getRange();
int fftBin = (((frequency - m_centerFrequency) / (float) m_sampleRate) * m_fftSize) + (m_fftSize / 2);
if ((pHis.x() >= 0) && (pHis.x() <= 1) && (pHis.y() >= 0) && (pHis.y() <= 1))
{
@ -2155,6 +2158,7 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
m_histogramMarkers.push_back(HistogramMarker());
m_histogramMarkers.back().m_point = pHis;
m_histogramMarkers.back().m_frequency = frequency;
m_histogramMarkers.back().m_fftBin = fftBin;
m_histogramMarkers.back().m_frequencyStr = displayScaled(
frequency,
'f',

View File

@ -178,6 +178,7 @@ private:
struct HistogramMarker {
QPointF m_point;
float m_frequency;
int m_fftBin;
float m_power;
QString m_frequencyStr;
QString m_powerStr;
@ -186,6 +187,7 @@ private:
HistogramMarker() :
m_point(0, 0),
m_frequency(0),
m_fftBin(0),
m_power(0),
m_frequencyStr(),
m_powerStr(),
@ -195,6 +197,7 @@ private:
HistogramMarker(
const QPointF& point,
float frequency,
int fftBin,
float power,
const QString& frequencyStr,
const QString& powerStr,
@ -203,6 +206,7 @@ private:
) :
m_point(point),
m_frequency(frequency),
m_fftBin(fftBin),
m_power(power),
m_frequencyStr(frequencyStr),
m_powerStr(powerStr),
@ -212,6 +216,7 @@ private:
HistogramMarker(const HistogramMarker& other) :
m_point(other.m_point),
m_frequency(other.m_frequency),
m_fftBin(other.m_fftBin),
m_power(other.m_power),
m_frequencyStr(other.m_frequencyStr),
m_powerStr(other.m_powerStr),