Skip to content

Fix spectrum dBm range echo smoothing#2793

Merged
ten9876 merged 1 commit into
aethersdr:mainfrom
rfoust:codex/fix-spectrum-line-release-jump
May 17, 2026
Merged

Fix spectrum dBm range echo smoothing#2793
ten9876 merged 1 commit into
aethersdr:mainfrom
rfoust:codex/fix-spectrum-line-release-jump

Conversation

@rfoust

@rfoust rfoust commented May 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix spectrum display jumps around dBm range changes.

  • Rebase a few incoming FFT frames after dBm scale release so stale radio-encoded frames do not briefly snap the trace back to the old display location.
  • Apply the same protection to vertical span / scale adjustments, not just moving the top dBm reference.
  • Split manual dBm-range echo handling from auto FFT floor echo handling so auto-floor can keep its local smooth animation running while waiting for the radio echo.
  • Avoid applying an older auto-floor echo if the local animation has already moved past it; reissue the current local range instead.

Cause

The likely regression came from the later dBm stabilization work in PR #2786 / #2780. That path made the stream decoder switch to the requested dBm range immediately while the radio could still send several FFT frames encoded against the old range. It also caused auto-floor movement to pause behind the pending echo guard, which made the smooth motion appear as steps.

Test Plan

  • git diff --check
  • cmake --build build --parallel 8
  • Manual: drag dBm reference line and release; confirm no snap-back
  • Manual: Ctrl-drag vertical dBm span/scale and release; confirm no snap-back
  • Manual: enable/open panadapter with auto FFT floor adjustment; confirm movement is smooth instead of stepping

Build passes. Existing warnings remain unrelated.

Copilot AI review requested due to automatic review settings May 17, 2026 05:50
@rfoust rfoust requested review from jensenpat and ten9876 as code owners May 17, 2026 05:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves panadapter spectrum Y-scale stability when the dBm range changes by preventing brief “snap-back” artifacts from stale FFT frames and by allowing auto-floor animation to continue smoothly while waiting for radio echo/handshake confirmation.

Changes:

  • Split pending dBm-range echo state between manual interactions vs. auto-noise-floor adjustments.
  • Continue local auto-floor ref-level animation even while waiting for radio echo, and ignore/reissue stale auto-floor echoes when local state has moved on.
  • Add a short post-release FFT “rebase” window that detects stale-range-encoded frames and remaps them to the pre-release range to avoid visible jumps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/gui/SpectrumWidget.h Adds new state flags/counters to track echo source and post-release FFT rebasing parameters.
src/gui/SpectrumWidget.cpp Implements auto-floor echo handling split + post-release stale FFT rebasing logic in updateSpectrum() and dBm drag release behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/gui/SpectrumWidget.cpp Outdated
Comment on lines +2309 to +2315
--m_holdFftUpdatesAfterDbmRelease;
const float oldRange =
m_dbmReleasePreviewOldMaxDbm - m_dbmReleasePreviewOldMinDbm;
const float newRange =
m_dbmReleasePreviewNewMaxDbm - m_dbmReleasePreviewNewMinDbm;
if (!m_bins.isEmpty() && m_bins.size() == binsDbm.size()
&& oldRange > 0.0f && newRange > 0.0f) {
Comment thread src/gui/SpectrumWidget.cpp Outdated
Comment on lines +3688 to +3690
m_holdFftUpdatesAfterDbmRelease =
(std::abs(oldMinDbm - m_pendingMinDbm) > 0.05f
|| std::abs(oldMaxDbm - m_pendingMaxDbm) > 0.05f) ? 10 : 0;
Comment thread src/gui/SpectrumWidget.cpp Outdated
Comment on lines +2316 to +2331
QVector<float> directErrors;
QVector<float> rebasedErrors;
const int step = qMax(1, binsDbm.size() / 256);
directErrors.reserve((binsDbm.size() + step - 1) / step);
rebasedErrors.reserve(directErrors.capacity());
for (int i = 0; i < binsDbm.size(); i += step) {
const float directDbm = binsDbm[i];
const float frac = (m_dbmReleasePreviewNewMaxDbm - directDbm) / newRange;
const float rebasedDbm = m_dbmReleasePreviewOldMaxDbm - frac * oldRange;
directErrors.append(std::abs(directDbm - m_bins[i]));
rebasedErrors.append(std::abs(rebasedDbm - m_bins[i]));
}
std::sort(directErrors.begin(), directErrors.end());
std::sort(rebasedErrors.begin(), rebasedErrors.end());
const float directMedian = directErrors[directErrors.size() / 2];
const float rebasedMedian = rebasedErrors[rebasedErrors.size() / 2];
Comment thread src/gui/SpectrumWidget.cpp Outdated
Comment on lines +949 to +953
m_holdFftUpdatesAfterDbmRelease = 0;
m_dbmReleasePreviewOldMinDbm = 0.0f;
m_dbmReleasePreviewOldMaxDbm = 0.0f;
m_dbmReleasePreviewNewMinDbm = 0.0f;
m_dbmReleasePreviewNewMaxDbm = 0.0f;
@rfoust rfoust force-pushed the codex/fix-spectrum-line-release-jump branch from 9bc0806 to 4ea52c5 Compare May 17, 2026 06:03
@rfoust

rfoust commented May 17, 2026

Copy link
Copy Markdown
Collaborator Author

Updated the branch with a single amended commit that addresses the actionable Copilot review notes:

  • The post-release hold counter now only decrements after a compatible FFT frame is available, so the full hold window is preserved.
  • Median checks now use stack-backed sample buffers plus std::nth_element instead of sorting both vectors in the update path.
  • The release-hold frame count, sample count, dB threshold, and rebase improvement threshold are named constants.
  • dBm release rebase state now has a dedicated clear helper instead of being reset as part of the noise-floor baseline reset.

I kept the behavior time/frame-count based as originally implemented for this narrow fix; converting it to pan-FPS-based timing would be a larger tuning change.

@ten9876 ten9876 merged commit 92d51e2 into aethersdr:main May 17, 2026
5 checks passed
@ten9876

ten9876 commented May 17, 2026

Copy link
Copy Markdown
Collaborator

Claude here — merged. Thanks Robbie! Owning the regression from your own #2786/#2780 stabilization work and coming back the same day with a fix this carefully layered is exactly the kind of follow-up that matters. The median-improvement guard on the rebase is the standout — a less careful fix would have just rebased unconditionally for N frames and introduced a different snap. Five contributions today (#2780#2786, #2783, #2789, #2792, #2793).

73, Jeremy KK7GWY & Claude (AI dev partner)

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.

3 participants