A pass over the whole interface, driven by using it on a 5.7-hour capture.
**Layout.** The 320px sidebar of labelled widgets is now a 46px icon rail —
one column of square buttons, sized so it costs the spectrogram as little
width as possible — plus a menubar for one-shot actions. Menu items are
defined by naming a keymap entry, so an item reuses that binding's action,
gate and shortcut label and the two can't drift; items grey out under
exactly the conditions that make the shortcut a no-op. Settings that need
more than an on/off (FFT size, colours/levels, annotation kinds) open as
popouts beside the rail rather than widening it. Every toggle has exactly
one home: nothing is reachable from both the rail and a menu.
Icons are drawn from raylib primitives rather than an atlas or font
glyphs — the bundled font has no symbol coverage, and vector shapes stay
crisp at any UI scale with no assets to ship.
**Navigation.** Left-drag now pans and Ctrl+drag box-selects, with Tab
swapping which is bare (Ctrl always means "the other one", so either mode
does both). Previously a bare left-drag did three different things
depending on invisible state, with no cursor feedback; the cursor now
reports the active gesture. Wheeling a scrollbar pans that axis, or zooms
it with Shift.
**Minimap.** Whole-file thumbnail in the top-right with the current view
drawn on it; click or drag to scrub, corner handle switches between two
sizes. Rendered once per size into a cached texture and rebuilt only when
its content changes — panning and zooming just move the rectangle drawn on
top. The reduction is strided (each thumbnail cell samples at most 8x8),
because reducing every segment x bin meant ~1 G reads per rebuild and a
visible hitch on every overlay toggle.
**Fixes found along the way:**
- The timeline lane mapped events across the whole file while the
spectrogram above it showed a zoomed window, so the two only lined up at
full zoom-out and an event's tick sat nowhere near its burst. It is also
properly toggleable now: the old flag only grew an always-present lane.
- Clicks preferred the spectrogram over the minimap. Input handling runs
~900 lines before the draw pass that computed the minimap's rect, so a
press there started a pan AND a scrub — two handlers writing app.view in
one frame. Geometry queries that input depends on now live outside the
draw pass.
- Repainting during the background fill re-ran the full synchrosqueeze
every 0.5 s. Zoomed out that is ~0.5 G bin-visits with four trig calls
each, twice a second, for minutes — while showing almost nothing new,
since folded segments land in columns already drawn. The interval now
scales with how much work a repaint actually costs.
- IsUserInteracting() sweeps 512 key codes and was called three times a
frame; memoized per frame.
- Frequency labels were drawn at a fixed offset wider than their gutter and
overflowed into the rail. They are measured and right-aligned now, with
one format chosen per axis so the column doesn't mix "3k" with "2.3k".
- The horizontal scrollbar is pinned to the window bottom; it used to sit
mid-layout competing with the scope's divider, and the scope covered it
outright at larger window sizes.
- The scope starts hidden — the spectrogram is the primary view.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ZWfr5XZyyDttvkhJUgHN
Control events are zero-duration log markers about the run rather than
signals on the air. A busy capture carries thousands, and they clutter the
overlay without saying anything about what was transmitted, so the GUI now
starts with that kind hidden; the per-kind checkbox brings it back. The
headless --render path still enables every kind — an export should render
what was asked for, not a GUI preference.
The auto-crop notice was a full modal: it dimmed the window, took focus,
and demanded a click before the user could look at the file they had just
opened. Auto-crop is a helpful default, not a decision worth blocking on.
It is now a bottom-right toast offering Undo / Dismiss, with a progress
strip showing the remaining time so it doesn't just vanish mid-read, and
it is out of UiModalOpen() so it no longer swallows keys or blocks the
spectrogram underneath.
The countdown only advances while the window is focused, so a crop applied
during a background load is still readable when the user returns. The
per-frame step is clamped: auto-crop fires on the frame right after the
blocking STFT compute, and GetFrameTime() there reports the entire
compute, which drained the whole 5 s budget at once and made the toast
flash by in an instant.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ZWfr5XZyyDttvkhJUgHN
Three things, all surfaced while working a multi-node protocol issue on a
5.7-hour capture.
**Loading was frame-paced, not compute-bound.** The STFT overview advanced
a fixed 200 segments per frame, so the frame limiter — not the FFT — set
the pace: 478k segments at ACTIVE_FPS meant over a minute spent waiting
between frames rather than computing. The tell was absurd: backgrounding
the window, which skips presenting entirely, loaded the same file in
seconds. The progress bar was slower precisely because you were watching
it. The overview is now computed in one blocking call after presenting the
loading panel, so focused load matches the unfocused speed. The panel says
the window will stop responding and drops the percentage, which could not
animate and would have read as a hang. ACTIVE_FPS 30 -> 60 while here;
idle still parks at ~0% CPU through the event-wait path.
Background work also no longer stops when the window loses focus. Pending
work now counts as "active" regardless of focus, so the loop doesn't block
in PollInputEvents waiting for input that isn't coming, and an unfocused
frame with work outstanding skips the draw pass entirely rather than
throttling the high-res fill to the refresh rate.
**Collision detection.** Annotations that overlap in both time and
frequency are flagged, merged into contiguous regions, and drawn as red
bands confined to the band the overlap occupies (padded, so a narrow
overlap stays findable) rather than spanning the full axis and hiding the
signal being pointed at. N / Shift+N and sidebar buttons jump between
regions, centring each without disturbing the current zoom.
Point markers are excluded: control events and assertions have no band and
zero duration, and treating a missing band as "whole spectrum" — which is
how they are *drawn* — made every marker collide with whatever it sat
inside. That was 38% of the reported collisions on a real capture. Only
things that actually occupy the air can interfere. Counts verified against
an independent reference implementation on two captures.
**Scope waveform via min/max summary.** The envelope rescanned every
visible sample every frame — ~245M reads, near 1 GB of memory traffic, on
a multi-hour file, measured at ~60 ms/frame for a few hundred pixel
columns. It now draws from 1024-sample buckets built once at load (60 ms,
1.9 MB), measured at ~0.07 ms/frame. Keeping both extremes per bucket
means single-sample transients still show at full zoom-out, which plain
decimation would drop; verified that no column ever understates a true
peak. Zoomed in past a bucket it falls back to raw samples, which is cheap
there by definition.
Also fixes ComputeCollisions never running for files opened through the
file browser, and moves the collision panel above the annotations dropdown
where it isn't pushed off the bottom of the sidebar.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ZWfr5XZyyDttvkhJUgHN
The minimum visible time window was a flat 2% of the file, but view.start
and view.end are normalized to the whole signal — so the achievable time
resolution scaled with file length. A 30-minute recording could never show
less than a 36-second span, while a 30-second one reached 0.6 s. Long
captures were effectively unreadable at the sample level no matter how far
you scrolled.
Derive the floor from the STFT hop instead (MinTimeViewWidth): segments sit
fftSize/HOP_RATIO samples apart, so the real limit is the point where only
a handful of segments span the viewport and further zoom would interpolate
rather than reveal. The floor is now a constant ~43 ms at 48 kHz/1024
regardless of duration — an 844x improvement on a 30-minute file, and it
tightens further with a smaller FFT. Guards cover the unloaded (sampleRate
0) and shorter-than-the-floor cases.
Zooming is also no longer forced to move both axes together. The bare wheel
keeps the existing coupled behaviour; Shift+wheel is time-only and
Ctrl+wheel frequency-only, so a long capture can be stretched along time
without collapsing the frequency range to match.
Time-axis labels now pick their precision from the span between adjacent
ticks (1 to 4 decimals, and m:ss.sss past a minute). At the spans this
change makes reachable the old fixed "%.1fs" printed the same value in
every slot, which read as a frozen axis.
Adds a `wheel X Y N [mod]` action to shot_input.sh for exercising zoom
headlessly, and known_bugs.md for behaviour that is unspecified rather
than broken.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ZWfr5XZyyDttvkhJUgHN
The spectrogram image spans the full Nyquist axis, but sel.freq* are
fractions of the displayed axis (capped at EffectiveMaxFreqHz). ExportPNG
mapped the selection straight onto the full image height, so when the
display max frequency was below Nyquist the export grabbed a band higher
in frequency than the box-select. Scale by DisplayFreqFraction() to match
the on-screen texture sub-sampling.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The left-hand control panel is laid out top-to-bottom with a running y; with
annotations expanded or a short window, the bottom buttons (export, signal
info, about) ran off the bottom and were unreachable. Offset the content by a
sidebarScroll amount, measure the laid-out height, and let the wheel scroll it
(clamped) when the cursor is over the sidebar and no modal is open. No visible
scrollbar; the spectrogram's wheel-zoom already ignores the sidebar column so
the two never both fire.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Commit the accumulated working-tree changes as one snapshot.
- Headless render: `--render OUT.png INPUT.wav` draws the spectrogram
(full window, or `--pane` for the spectrogram pane only) to a PNG
with no visible window. Options: `--annotations`/`--no-annotations`,
`--annotation-opacity`, `--width`/`--height`.
- mLnL annotations: parse the optional `mLnL` RIFF chunk (schema v2)
and render tx_frame/assertion/control overlays, a timeline lane, and
a waveform-scope echo, with hover tooltips on the spectrogram,
timeline, and scope.
- sched_offset_ms: parse the per-frame intent->air latency and surface
it in the hover tooltips (boxes stay air-anchored upstream).
- Supporting: build wiring (rspektrum.make), shared types/headers,
web-build and capture-script tweaks, and removal of the old
synchrosqueezing LaTeX doc.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Make the Emscripten build behave like the desktop app for loading, window
scaling, and exporting. All changes are #ifdef __EMSCRIPTEN__-gated or no-op on
desktop, so native behavior is unchanged.
Scaling:
- Drop FLAG_WINDOW_HIGHDPI on web. The emscripten-GLFW shim forces a fixed
pixel canvas style (!important) when HiDPI-aware, overriding the shell's
100vw/100vh CSS so the canvas can't fill the page; raylib's own resize/window
callbacks also disagree about dividing by devicePixelRatio, desyncing the
framebuffer from the reported screen size.
- Sync raylib's window size to window.innerWidth/innerHeight each frame via
SetWindowSize (guarded against no-op churn). This keeps screen size, GL
viewport, and projection consistent, so the UI fills the viewport and reflows
on resize like the desktop window.
Loading:
- Compute the full-resolution STFT synchronously when a file loads instead of
the desktop overview-then-deferred-high-res path, which relied on many
main-loop iterations yielding to the browser and appeared to stall partway.
- Allow the wasm heap to grow (INITIAL_MEMORY + ALLOW_MEMORY_GROWTH) so longer
recordings fit now that everything is computed up front.
Exports:
- Add Platform_OfferFileToUser(): no-op on desktop (file is already on disk);
on web it reads the just-written file from MEMFS and triggers a browser
download, then unlinks the temp copy. Wired into PNG and WAV export, which
now show just the filename in the status message.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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>