Commit Graph

41 Commits

Author SHA1 Message Date
tyler bc8bcf78b7 fix: web text corruption, blocking-load notice, no-cache dev server
**Most UI text drew with raylib's built-in font, not the loaded one.**
Thirteen call sites used DrawText/MeasureText directly instead of the
project's DrawTextScaled/MeasureTextScaled wrappers, so the cursor and
marker readouts, spectrum panel labels and export toast rendered from
raylib's default bitmap atlas. On desktop that merely looked slightly off;
on web it renders as garbage. The only raw calls left are the two
fallbacks inside the wrappers themselves.

**The rail tooltip held a dangling pointer.** RailButton stored a
TextFormat() result for the deferred draw pass, and raylib documents that
string as expiring once TextFormat has been called a few more times — which
it has by then. It copies into owned storage now.

**Loading a large file in the browser looked like a crash.** The web build
computes its whole STFT in one synchronous pass, with no frame presented in
between, so nothing drawn on the canvas during that window ever reaches the
screen. A notice now goes into the host DOM instead, which the browser
paints independently, and yields once so that paint actually happens before
the work starts. Because that yield unwinds the stack under ASYNCIFY, the
load block is guarded by stftBusy — without it the re-entered main loop
calls ComputeSTFTInit again and frees the STFT the suspended call is still
building.

**Removed EXPORTED_FUNCTIONS from the web link flags.** It replaces
emscripten's default export list rather than extending it, so everything
unnamed is dead-code-eliminated. The upload callback stays reachable via
the EMSCRIPTEN_KEEPALIVE already on its definition.

**Adds serve_web.py**, a dev server that sends no-store. Browsers cache
.wasm hard enough that a plain reload runs a stale module while the page
looks freshly loaded — which makes a rebuild appear to change nothing.
That cost most of a debugging session today: three separate fixes were
tested against a binary that never changed, each returning an identical
fault at an identical address. README now points at it and says why.

Documents the remaining web issue in known_bugs.md: large captures still
corrupt text after loading. Leading theory is ALLOW_MEMORY_GROWTH
reallocating the heap mid-load and invalidating pointers cached across
that moment, which fits the symptom being text specifically.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ZWfr5XZyyDttvkhJUgHN
2026-08-12 18:38:59 -07:00
tyler 40623feadc feat: web file upload, axis-locked grid, averaged cursor readout
**File loading on the web.** The browser build's filesystem is an in-memory
sandbox, so the file browser could only ever list what the page itself had
written — useless for opening a capture off the user's disk. Adds
Platform_NeedsFileUpload / RequestFileUpload / TakeUploadedFile: no-ops on
desktop, and on web they drive a real <input type="file">, copy the chosen
bytes into MEMFS, and hand the path back through a callback the main loop
polls. The ordinary load path takes it from there, so mLnL parsing and
collision detection work identically.

All three entry points (the O key, File -> Open, and the empty-state
button) route through the same place, so they can't disagree about what
"open" means. ccall/cwrap/FS and the callback symbol needed explicit
export — recent emscripten omits them by default and the failure is
silent until someone clicks the button.

The empty-state banner was centred with the old 320px sidebar's width
hardcoded and never measured its text, so it sat well off-centre once the
rail shrank to 46px. It now measures and centres against the area right of
the rail, and says something useful on web.

**Grid was not locked to the axes.** It drew a fixed 10x8 even divisions of
the viewport rectangle, with no idea what time or frequency those lines
fell on — so they marked arbitrary values and slid continuously while
panning, never coinciding with the labels. Both axes now draw at real
values from a 1-2-5 ladder, and the time labels moved onto that same
ladder (they were at 11 fixed fractions of the view, printing values like
"3.47s" that matched no gridline). Grid and labels share one set of
spacing helpers so they cannot drift apart again.

**Cursor dB readout was a single bin.** On an OFDM burst that swings ~30 dB
between adjacent subcarriers and symbols, so the number reported where the
cursor landed rather than the level of the signal under it. Now averaged
over +/-3 segments x +/-6 bins (~76 Hz x 300 ms at 12 kHz / 2048, under a
third of the narrowest mLink channel, so it stays inside one signal).
Simulated against Rayleigh-distributed subcarriers this cuts the standard
deviation from 5.6 dB to 0.44 dB.

The mean is taken over power and converted afterwards: averaging dB values
is a geometric mean of power and read ~2 dB low. The window is sized in
STFT cells rather than screen pixels, which would otherwise mean something
different at every zoom — one pixel spans hundreds of segments zoomed out
and a fraction of a bin zoomed in.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ZWfr5XZyyDttvkhJUgHN
2026-08-12 16:23:26 -07:00
tyler 56b1666850 fix: playhead drift, replay, and cursor flicker; add selection transport
**Playhead ran ahead of the audio.** It was dead-reckoned by summing
GetFrameTime() every frame, so every frame's *render* work counted as
playback time and the error compounded — by seconds over a long region,
and worst when zoomed out where each frame does the most work. That is why
it tracked fine zoomed in. It is now derived from a wall-clock instant
captured when the buffer is handed to the device, so it cannot drift from
the audio regardless of frame timing.

**Replay after a natural finish left the marker stuck at the end.** The
rail's play button never cleared playbackFinished, so the stale
playheadT > 1.0 persisted and DrawPlayhead early-returned while the audio
played from the top. The Space path already handled this; the button did
not.

**No way to replay a subrange.** The playhead is now drawn while stopped
(with a grab tab) and can be dragged to set where the next play starts
*within* the selection, leaving the region itself intact. Stopping parks
the marker where it stopped rather than snapping to the start.

playheadT is a fraction of the *played* span, which stops being the
selection once a scrub offset exists — so every conversion goes through
absolute file time, the only frame the two share. Getting this wrong made
stop-after-scrub jump backwards.

**Selection transport bar.** Rewind / play-pause / stop / loop, attached
above the selection box. Pause resumes where it left off; loop restarts
from the top of the region rather than repeating whatever tail the last
play started from.

**Cursor flicker.** Twelve unconditional SetMouseCursor calls ran per
frame and the last one won. Two blocks in particular both ran every frame:
one set a cursor regardless of mouse position, and a second overrode it
only when the mouse was inside the spectrogram — so when a capture guard
had parked mousePos off-screen, the first block's stale choice stuck. That
is the fight between finger/pointer, resize/pointer and crosshair/pointer.
Handlers now record a prioritised request (active drag > hover hint >
default) and it is applied once at the end of the frame. The divider hint
is RESIZE_NS rather than the 4-way arrow while here.

The rewind glyph drew its bar and triangle with a gap between them and read
as a lone vertical bar; verified the fix by rendering it offscreen and
dumping pixels rather than eyeballing the geometry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ZWfr5XZyyDttvkhJUgHN
2026-08-12 15:56:33 -07:00
tyler cce96659b1 feat: menubar + icon rail, minimap, Blender-style navigation
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
2026-08-12 15:28:44 -07:00
tyler 4c3c6a955a perf: unblock long-file loading; add collision detection and jump nav
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
2026-08-12 13:58:58 -07:00
tyler 5c3c88dc22 feat: scale time zoom by duration, decouple the two axes
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
2026-08-12 00:19:36 -07:00
tyler 398be34aaf build: document system deps, add check-deps, auto-glob web modules
- README: rewrite Build section for the hand-written Makefile (make /
  make DEBUG=1 / run / test / bench). Add a "System dependencies" table
  with the X11+GL dev packages per distro (apt/dnf/pacman/zypper/apk),
  since a clone won't build without them and the error is otherwise
  cryptic. Fix stale ./bin/Debug paths to ./bin/Release.
- Makefile: add `make check-deps` — probes for the required X11/GL dev
  headers and prints the install command for the detected distro on
  failure (via /etc/os-release).
- build_web.sh: auto-discover app modules from src/*.c (drop the
  hardcoded APP_MODULES list that had to be hand-synced), matching the
  desktop Makefile. Excludes the desktop platform backends. Remove the
  stale rspektrum.make reference.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 21:19:23 -07:00
tyler 3b2e5517bf Update README.md 2026-06-06 03:08:38 +00:00
tyler 7916e8a24e docs+chore: add screenshot to README; drop committed export PNGs and junk
- README: embed resources/Screenshot.png under the intro
- remove accidentally-committed app export outputs (spectrogram_full.png,
  spectrogram_export.png) and gitignore them so they don't return
- remove unused resources/wabbit_alpha.png and stray .qwen/settings.json.orig

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 15:51:12 -07:00
tyler 5c3c452133 docs: rewrite README as a fresh project overview + usage guide
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 15:40:44 -07:00
tyler fb7bc5486e feat: true no-X headless --render (CPU spectrogram bitmap + overlay)
Rewrite --render to compute the spectrogram and write a PNG entirely on the
CPU, with no window, no GL context, and no X server. Previously it opened a
hidden GL window and grabbed LoadImageFromScreen(), which still required an X
server (Xvfb); the output was a UI screenshot rather than the spectrogram data.

The new path (RunHeadlessRender) loads the WAV, computes the STFT, colorizes
the bitmap at native STFT resolution, bakes the mLnL annotation overlay onto
it, and exports — all CPU-only. render.c gains a GL-free colorize
(BuildSpectrogramImageCPU), a CPU font loader (LoadFontCPU), and a CPU overlay
drawer (DrawAnnotationsToImage).

Annotations draw outline + label only: mLnL captures contain many overlapping
full-band boxes whose translucent fills alpha-stack to opaque and bury the
signal. The outline marks each region while the spectrogram reads through; a
dark backing strip keeps labels legible. Note: MeasureTextEx/ImageText* bail
when font.texture.id == 0, so the CPU font sets a sentinel non-zero id (the
draw path reads glyph images, never the texture).

Render options: --annotation-opacity (overlay strength), --annotation-kinds
(comma-separated kind filter), --width (resize; default native). Removed the
obsolete --pane/--height window options and the screenshot workaround.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 22:37:38 -07:00
tyler 95be6f6c22 docs: rewrite README to characterize rspektrum accurately
Replaces the stale Unity-port README (wrong controls, premake build,
missing features). Documents the mLink/mLnL focus, real keybindings,
make-based build, headless --render mode, and the Xvfb GUI-driving
primer. Consolidates the old SPECTROGRAM_README.md into README.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 23:50:29 -07:00
Jeffery Myers 4cf96e771f add info about software render target 2026-01-13 11:47:28 -08:00
Jeffery Myers c8e40f3845 Revise license section in README.md
Updated license information to reflect CC0 1.0.
2026-01-06 16:34:47 -08:00
Peter0x44 8853ece16a Update README.md 2026-01-06 23:18:43 +00:00
Jeffery Myers 31630dded8 add more clear description on how to get the template 2025-12-09 11:36:37 -08:00
Peter0x44 e5415bcb6e Add rename folder step to all platform sections
Fixes #30
2025-12-03 05:31:26 +00:00
Jeffery Myers 1861d659a5 tweaks to lib info 2025-11-20 15:47:24 -08:00
Youness SBAI cf453b5601 Add clarification on external library dependencies in README 2025-11-20 19:36:37 +01:00
Jeffery Myers 55b448e122 Update README.md 2025-07-17 10:53:07 -07:00
Jeffery Myers 284a5f8b42 update to premake5 beta 7
replace gmake2 with gmake
2025-07-14 11:14:09 -07:00
Jeffery Myers d218555489 Update README.md 2025-02-02 11:59:51 -08:00
Jeffery Myers 2edcc85178 Update README.md 2025-01-29 12:40:10 -08:00
Jeffery Myers f498cccb69 Update README.md 2025-01-29 12:39:53 -08:00
Jeffery Myers 589d8c5f8b Update README.md 2025-01-29 12:39:17 -08:00
Jeffery Myers 48f409b15c Update README.md 2025-01-29 09:11:04 -08:00
Jeffery Myers 6fa6fab5e9 note the obvious that you need a compiler for vscode. 2025-01-15 19:13:31 -08:00
Nathan Iszlaub 312433ae8b use code formatting for commands, files, and paths 2024-11-24 00:33:27 +08:00
Nathan Iszlaub ec8968b0f3 fix minor typos and adjust casing+punctuation for consistency 2024-11-24 00:32:28 +08:00
Jeffery Myers 94a0a75d69 typo 2024-11-18 15:48:51 -08:00
Zelwaris eb20ab2d56 Update README.md 2024-09-30 20:57:20 +02:00
Jeffery Myers f8fb323310 update readme to say it uses git main 2024-09-27 07:41:45 -07:00
Jeff Myers 3f9ed218fb Make clean on MinGW-W64 batch.
Add notes to readme for how to swap to C++ or use your own code.
2024-09-20 15:56:00 -07:00
Jeffery Myers e5b0c478bb update OSX docs, they don't use the same bin as linux. 2024-08-23 07:09:36 -07:00
Jeffery Myers 9049a646a1 Updates 2024-08-17 08:53:09 -07:00
Jeffery Myers 0523db4ad6 Update README.md 2024-08-16 08:24:54 -07:00
Jeffery Myers 134bb017ee Update README.md 2024-08-14 19:36:33 -07:00
Jeffery Myers d79c7ae9af Update README.md 2024-08-14 19:35:12 -07:00
Jeffery Myers 1c30e84c38 linux info, ignores 2024-08-14 19:33:30 -07:00
Jeff Myers 3f023baa2f inital code drop. 2024-08-14 17:09:43 -07:00
Jeffery Myers fe934db383 Initial commit 2024-08-14 17:08:10 -07:00