[minor] Add SpectrumAnalyzer widget - #516
Merged
Merged
Conversation
Log-frequency bars or a line over caller-supplied FFT magnitudes, with peak hold, in DbMeter's zone colours and Scope's frame layout. Band folding, bar ballistics and peak hold live in SpectrumAnalyzerState, tested without an ImGui context. Adds an isolation UI suite, a demo section and README/CLAUDE.md entries. Closes #501 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KwPRukimexyvu84zFn7oEP
Replaces the negated comparisons code quality flagged with direct ones, naming NaN and infinity explicitly so the guards reject the same inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KwPRukimexyvu84zFn7oEP
This was referenced Sep 29, 2026
Keeps both Waveform and SpectrumAnalyzer in the docs, demo and demo suite. The two signal demo sections go through a small SignalDemos class, because referencing both from ImGuiWidgetsDemo pushed it over the CA1506 class-coupling limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KwPRukimexyvu84zFn7oEP
7 tasks
|
This was referenced Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Requested by Matt · project thread
Before:
ktsu.ImGui.Widgetscould show an audio level (DbMeter) and a waveform (Scope), but not a spectrum. A host with FFT output had to draw one itself.After:
ImGuiWidgets.SpectrumAnalyzerdraws caller-supplied FFT magnitudes as log-frequency bars, or as a line, with a peak-hold marker per band. It usesDbMeter's zone colours andScope's frame layout, with gridlines at each frequency decade and every 12 dB. It marks itself withImGuiProbes.MarkItem.The FFT stays with the host. The widget takes the
N/2+1bin magnitudes of a real FFT in dB.How:
SpectrumAnalyzerStateis a public, caller-owned class with no ImGui dependency. It groups the bins into log-spaced bands, and each band shows its loudest bin, so a pure tone reads at its true level. Bands too narrow to hold a bin are interpolated at their centre rather than shown as silent, and bands above Nyquist read silence. Bars rise at once and fall atBarFallRate. Peaks hold forPeakHoldSeconds, then fall atPeakFallRate, never below their bar, and the fall is the same however the frame time is sliced. One overload updates and draws usingio.DeltaTime; the other only draws, so one state can be shown twice without advancing twice.The state is owned by the caller, like
ImageCanvasState, rather than kept under the widget's ImGui id as #501 suggested. That way nothing accumulates inside the library.Also includes:
tests/ImGui.Widgets.UITests/.Tested locally in Release. The widget unit tests (344), the widget UI suite (388) and the widgets demo suite (30) all pass. The demo suite ran against a stand-in
ktsu.pngin the build output, because this checkout has the LFS pointer instead of the image.Closes #501
🤖 Generated with Claude Code
https://claude.ai/code/session_01KwPRukimexyvu84zFn7oEP
Generated by Claude Code