Skip to content

Fix waterfall misalignment with spectrum display#2647

Merged
f4exb merged 2 commits intomasterfrom
copilot/fix-spectrum-waterfall-alignment
Feb 14, 2026
Merged

Fix waterfall misalignment with spectrum display#2647
f4exb merged 2 commits intomasterfrom
copilot/fix-spectrum-waterfall-alignment

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

PR #1464 corrected spectrum alignment by replicating the Nyquist sample and drawing m_nbBins+1 points instead of m_nbBins, but only applied this to the spectrum histogram. The waterfall and 3D spectrogram still used m_nbBins pixels, causing rightward shift visible at low FFT sizes.

Changes

  • Buffer allocation: Changed waterfall and 3D spectrogram buffer width from m_nbBins to m_nbBins+1
  • Data population: Replicate Nyquist sample (spectrum[0]) at end of waterfall and 3D spectrogram lines
  • Texture uploads: Updated all subTexture() calls to use m_nbBins+1 width parameter
// In updateWaterfall() and update3DSpectrogram()
for (int i = 0; i < m_nbBins; i++) {
    // ... write spectrum[i] ...
}
// Replicate Nyquist sample to end of positive side
*pix++ = /* spectrum[0] value */;

This brings waterfall rendering in line with the spectrum display, ensuring both use the same bin count and align with the frequency scale.

Original prompt

This section details on the original issue you should resolve

<issue_title>Spectrum and waterfall misalignment</issue_title>
<issue_description>Sdrangel for MacOS, 7.22.10, MacOS Tahoe 26.0.1, 4k display.

The peak of the spectrum does not align with the peak in the waterfall using the Broadcast FM demod. Sometimes it's slight, sometimes it's quite obvious. Here's a screen shot that shows the problem:

Spectrum/Waterfall Misalignment

The question that arises since they don't agree is: Which should we be using to tune? The spectrum, or the waterfall?

</issue_description>

Comments on the Issue (you are @copilot in this section)

@srcejon Can see it in this image where I've generated a tone at DC, with low FFT size. It's the waterfall that appears shifted to the right.

Image</comment_new>
<comment_new>@srcejon
Possibly related to this fix I did a while back: #1464 - I only changed the spectrum.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: f4exb <6192319+f4exb@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix spectrum and waterfall misalignment in Sdrangel Fix waterfall misalignment with spectrum display Feb 14, 2026
Copilot AI requested a review from f4exb February 14, 2026 12:30
@sonarqubecloud
Copy link

@f4exb f4exb marked this pull request as ready for review February 14, 2026 15:16
@f4exb f4exb merged commit 636249a into master Feb 14, 2026
5 of 6 checks passed
@f4exb f4exb deleted the copilot/fix-spectrum-waterfall-alignment branch February 14, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spectrum and waterfall misalignment

2 participants

Comments