1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

GLSpectrum: separate waterfall and histogram resizing conditions. Fixes #1496

This commit is contained in:
f4exb 2022-11-04 19:11:25 +01:00
parent 4b665a188a
commit f5b91fff53

View File

@ -2239,7 +2239,6 @@ void GLSpectrumView::measureAdjacentChannelPower()
void GLSpectrumView::measureOccupiedBandwidth() void GLSpectrumView::measureOccupiedBandwidth()
{ {
float hzPerBin = m_sampleRate / (float) m_fftSize; float hzPerBin = m_sampleRate / (float) m_fftSize;
int bins = m_measurementBandwidth / hzPerBin;
int start = frequencyToBin(m_centerFrequency + m_measurementCenterFrequencyOffset); int start = frequencyToBin(m_centerFrequency + m_measurementCenterFrequencyOffset);
float totalPower, power = 0.0f; float totalPower, power = 0.0f;
int step = 0; int step = 0;
@ -3303,26 +3302,27 @@ void GLSpectrumView::applyChanges()
m_peakPowerMaxStr = m_linear ? "8.000e-10" : "-100.0"; m_peakPowerMaxStr = m_linear ? "8.000e-10" : "-100.0";
m_peakPowerUnits = m_linear ? "" : "dB"; m_peakPowerUnits = m_linear ? "" : "dB";
bool fftSizeChanged = true; bool waterfallFFTSizeChanged = true;
if (m_waterfallBuffer) { if (m_waterfallBuffer) {
fftSizeChanged = m_waterfallBuffer->width() != m_nbBins; waterfallFFTSizeChanged = m_waterfallBuffer->width() != m_nbBins;
} }
bool windowSizeChanged = m_waterfallTextureHeight != m_waterfallHeight; bool windowSizeChanged = m_waterfallTextureHeight != m_waterfallHeight;
if (fftSizeChanged || windowSizeChanged) if (waterfallFFTSizeChanged || windowSizeChanged)
{ {
if (m_waterfallBuffer) { if (m_waterfallBuffer) {
delete m_waterfallBuffer; delete m_waterfallBuffer;
} }
m_waterfallBuffer = new QImage(m_nbBins, m_waterfallHeight, QImage::Format_ARGB32); m_waterfallBuffer = new QImage(m_nbBins, m_waterfallHeight, QImage::Format_ARGB32);
m_waterfallBuffer->fill(qRgb(0x00, 0x00, 0x00)); m_waterfallBuffer->fill(qRgb(0x00, 0x00, 0x00));
if (m_waterfallHeight > 0) { if (m_waterfallHeight > 0) {
m_glShaderWaterfall.initTexture(*m_waterfallBuffer); m_glShaderWaterfall.initTexture(*m_waterfallBuffer);
} }
m_waterfallBufferPos = 0; m_waterfallBufferPos = 0;
if (m_3DSpectrogramBuffer) { if (m_3DSpectrogramBuffer) {
@ -3330,13 +3330,20 @@ void GLSpectrumView::applyChanges()
} }
m_3DSpectrogramBuffer = new QImage(m_nbBins, m_waterfallHeight, QImage::Format_Grayscale8); m_3DSpectrogramBuffer = new QImage(m_nbBins, m_waterfallHeight, QImage::Format_Grayscale8);
m_3DSpectrogramBuffer->fill(qRgb(0x00, 0x00, 0x00)); m_3DSpectrogramBuffer->fill(qRgb(0x00, 0x00, 0x00));
if (m_waterfallHeight > 0) { if (m_waterfallHeight > 0) {
m_glShaderSpectrogram.initTexture(*m_3DSpectrogramBuffer); m_glShaderSpectrogram.initTexture(*m_3DSpectrogramBuffer);
} }
m_3DSpectrogramBufferPos = 0; m_3DSpectrogramBufferPos = 0;
m_waterfallTextureHeight = m_waterfallHeight;
m_waterfallTexturePos = 0;
m_3DSpectrogramTextureHeight = m_waterfallHeight;
m_3DSpectrogramTexturePos = 0;
} }
m_glShaderSpectrogram.initColorMapTexture(m_colorMapName); m_glShaderSpectrogram.initColorMapTexture(m_colorMapName);
m_glShaderColorMap.initColorMapTexture(m_colorMapName); m_glShaderColorMap.initColorMapTexture(m_colorMapName);
m_colorMap = ColorMap::getColorMap(m_colorMapName); m_colorMap = ColorMap::getColorMap(m_colorMapName);
@ -3349,17 +3356,16 @@ void GLSpectrumView::applyChanges()
((quint8*)&m_waterfallPalette[i])[3] = 255; ((quint8*)&m_waterfallPalette[i])[3] = 255;
} }
if (fftSizeChanged) bool histogramFFTSizeChanged = true;
{
if (m_histogramBuffer) if (m_histogramBuffer) {
{ histogramFFTSizeChanged = m_histogramBuffer->width() != m_nbBins;
delete m_histogramBuffer;
m_histogramBuffer = nullptr;
} }
if (m_histogram) { if (histogramFFTSizeChanged)
delete[] m_histogram; {
m_histogram = nullptr; if (m_histogramBuffer) {
delete m_histogramBuffer;
} }
m_histogramBuffer = new QImage(m_nbBins, 100, QImage::Format_RGB32); m_histogramBuffer = new QImage(m_nbBins, 100, QImage::Format_RGB32);
@ -3367,6 +3373,10 @@ void GLSpectrumView::applyChanges()
m_histogramBuffer->fill(qRgb(0x00, 0x00, 0x00)); m_histogramBuffer->fill(qRgb(0x00, 0x00, 0x00));
m_glShaderHistogram.initTexture(*m_histogramBuffer, QOpenGLTexture::ClampToEdge); m_glShaderHistogram.initTexture(*m_histogramBuffer, QOpenGLTexture::ClampToEdge);
if (m_histogram) {
delete[] m_histogram;
}
m_histogram = new quint8[100 * m_nbBins]; m_histogram = new quint8[100 * m_nbBins];
memset(m_histogram, 0x00, 100 * m_nbBins); memset(m_histogram, 0x00, 100 * m_nbBins);
@ -3376,14 +3386,6 @@ void GLSpectrumView::applyChanges()
std::fill(m_q3ColorMap.m_array, m_q3ColorMap.m_array+4*(m_nbBins+1), 0.0f); std::fill(m_q3ColorMap.m_array, m_q3ColorMap.m_array+4*(m_nbBins+1), 0.0f);
} }
if (fftSizeChanged || windowSizeChanged)
{
m_waterfallTextureHeight = m_waterfallHeight;
m_waterfallTexturePos = 0;
m_3DSpectrogramTextureHeight = m_waterfallHeight;
m_3DSpectrogramTexturePos = 0;
}
m_q3TickTime.allocate(4*m_timeScale.getTickList().count()); m_q3TickTime.allocate(4*m_timeScale.getTickList().count());
m_q3TickFrequency.allocate(4*m_frequencyScale.getTickList().count()); m_q3TickFrequency.allocate(4*m_frequencyScale.getTickList().count());
m_q3TickPower.allocate(6*m_powerScale.getTickList().count()); // 6 as we need 3d points for 3D spectrogram m_q3TickPower.allocate(6*m_powerScale.getTickList().count()); // 6 as we need 3d points for 3D spectrogram