Spectrum slice (S): floating panel plotting the time-averaged power
spectrum of the current selection (or the visible view when there's no
selection). Frequency on X over the region's band, auto-ranged dB on Y,
with a peak marker. Backed by ComputePowerSpectrum() in stft.c (mean
linear power per bin over the time span). The selection stat panel now
biases to the left when this panel is up so the two don't overlap.
Marker/ruler tool (M): press-drag-release drops point A and B; the
overlay shows crosshairs, a connecting line, and a readout of the
ham-useful deltas — Δt, Δf, tone spacing (1/Δt), and drift (Δf/Δt).
Marker mode swaps the LMB-drag gesture from box-select to marker drop
(Alt/middle still pan); RMB/Esc clear the measurement. Markers reset on
new-file load alongside the selection.
Both are gated toggles (off by default), wired into the keymap (so they
self-document in the About dialog) and the sidebar.
Verified headlessly: idle viewport pixel-identical to baseline (AE=0,
deterministic); both panels render correctly with sensible numbers.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
New "Export WAV (W)" button + W key saves the current selection as a mono
WAV — the same band-limited, time-cropped audio you'd hear on playback, so
"what you hear is what you save". Self-documenting filename encodes the
time span and frequency band (rspektrum_sel_<t0>-<t1>s_<f0>-<f1>Hz.wav).
Refactor the shared filtered-region builder out of PlaySelectedRegion
(which also fixes a leak: it never freed regionSamples after
LoadSoundFromWave copies it). Make the export confirmation message persist
~3s instead of flashing for a single frame (affected PNG export too).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The box-selection state was 11 fields spread across three comment blocks
(time sel, freq sel, drag state). Consolidate them into one Selection
sub-struct (app.sel.*) and extract the 4-line 'clear to full range' block —
duplicated in 5 places — into a ClearSelection() helper.
Pure mechanical rename (anchored to app./spa-> so the ScopeView fields of the
same name are untouched) + behavior-identical dedup. Fully-settled render
verified pixel-identical (AE=0).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reset Sel advertised an 'R' key that was never bound and only set the
selection to the current view, overlapping Clear/Esc. Removed it and made
Clear a single full-width button labelled to match the Esc shortcut.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the global key handling scattered through the main loop with a single
KEYMAP table (key, gate, action, help text) and a DispatchKeymap() pass. The
About/Help overlay now renders its key list straight from the table, so the
on-screen shortcuts can never drift from the actual bindings.
- Order-sensitive keys (Space, Esc) stay inline where their frame ordering
matters; they carry action==NULL and appear in the table for the help list.
- Adds the F11 fullscreen binding the sidebar button already advertised but
that was never actually wired up.
- Fix About title em-dash rendering as '?' (font is ASCII-only); use a hyphen.
Launch render verified pixel-identical (AE=0); keys verified via injected input.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collapse the repeated 'CheckCollisionPointRec + IsMouseButtonPressed' click
test and the 'DrawRectangleRec + DrawRectangleLinesEx' panel chrome into two
helpers used across the sidebar buttons. Pure readability; render output is
pixel-identical (verified AE=0 vs baseline).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two extensibility easy-wins, both behavior-preserving:
- UiModalOpen() centralizes the "an overlay owns input" check that was
copy-pasted as `!showFileBrowser && !showAbout` across 6 input gates.
New overlays now update one place.
- Colormaps become a COLORMAPS[] table (name + function) indexed by enum.
GetColormapColor and the sidebar both read it, so adding a colormap is
one enum value + one Cmap* fn + one row — and the sidebar name can no
longer drift from the enum (deleted the parallel colormapNames[] array).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
dB floor handling:
- Fix the white-out/inversion when the floor was cranked up: guard the
(ceiling - floor) range in ColorizeSpectrogram so floor >= ceiling
degrades to a hard threshold instead of dividing by ~0 (white) or a
negative (inverted colors).
- Add two amplitude scale modes, toggled in the sidebar:
* Relative: ceiling tracks the signal peak, floor sits N dB below it
(slider = dynamic range, 10..100 dB). Floor can't cross the ceiling.
* Absolute: fixed dBFS scale (0 dBFS = full scale), slider sets an
absolute floor in dBFS. Brightness reflects real level.
Mode + both slider values persist across loads. This replaces the
amplitudeUserSet flag — storing the intent (range / absolute floor)
preserves it across re-scales structurally.
About / Help dialog (no help menu existed):
- F1 or sidebar button; documents the scale modes and the caveats
(dBFS not dBm — a WAV has no power reference; ~6 dB Hann window
offset; pixels are reassigned energy, not raw bins) plus key list.
- Modal: underlying spectrogram input is gated while open; open/close
handled in the main loop so the opening click can't self-close it and
a dismissing click can't fall through into a selection.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Split GenerateSpectrogramTexture into ComputeSpectrogramReassignment
(the expensive synchrosqueezing, cached in app.reassignBuffer) and
ColorizeSpectrogram (cheap). dB-floor and colormap changes now only
re-colorize instead of recomputing the whole reassignment every frame —
the dB slider and colormap switching are smooth on large files.
- AutoScaleAmplitude no longer overwrites a dB floor the user set by hand
(amplitudeUserSet flag, reset per file load).
- Extract ResetForNewSignal() used by all three load paths; removes the
duplicated reset blocks and the double ComputeSTFTInit per load. Drag-drop
now resets the selection like the browser already did.
- Remove the dead lastInteractedFrame field.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
spectrogram.c was ~2950 lines holding everything. Break it into cohesive
translation units; spectrogram.c keeps only globals + the main frame loop.
New modules:
- spectrogram_types.h shared types, constants, extern globals, inline math
- fft.c/.h FFT, bit-reverse, twiddle (standalone, no app deps)
- stft.c/.h STFT compute, adaptive resolution, FFT-size LRU cache
- audio.c/.h WAV/ffmpeg load, FreeSignal, bandpass, playback
- render.c/.h UI scaling, colormaps, texture gen, on-screen drawing
- ui.c/.h file browser, sidebar, sliders, PNG export
Also:
- utils.c now includes utils.h instead of re-typedef'ing AudioSignal/
SignalStats (they had to be hand-synced before).
- Remove dead code: ApplyHannWindow and ComputeSTFTHighResRange were never
called (the live high-res path is ComputeNextHighResChunk).
- Delete the unused raylib-template main.c.
- rspektrum.make: build the new units. premake5.lua: glob src/**.c so a
future regen stays correct.
Pure code movement otherwise; no behavior change. Builds clean (-Wshadow).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>