Replace the fixed RMS threshold with prominence over a rolling noise
floor (20th percentile per 30s block, min-smoothed so events cannot
raise their own floor, clamped to -54 dBFS). Slow ambience changes such
as rain or daytime traffic hum move the floor instead of flagging
everything; sections now need `margin` dB (default 12) of prominence.
Each section carries a score (peak dB above floor); day-highlight chips
show the top 50 by score when there are too many to list, so the most
striking events are reviewed first.
--threshold is replaced by --margin; analysis caches are now keyed by
margin+min_gap, old threshold-keyed caches never match and are
overwritten on the next analyse. Detector covered by tests/test_web.py.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
FLAC duration cannot be derived from byte size (variable compression),
so unlike WAV the header cannot be patched from st_size alone. Instead,
every FLAC frame header carries its own frame/sample number: read the
last 64 KB of the growing file, scan backwards for a frame sync,
CRC-8-verify the header to reject false matches in compressed data,
and compute the exact samples recorded so far. STREAMINFO
total_samples (36 bits at a fixed offset) is rewritten in the served
bytes only - the on-disk file is never touched.
Overhead: one tail read per /stream request, active files only.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Server (web.py):
- /api/analyze no longer returns the full per-window RMS array (~45x
larger than the rms_display the UI actually renders); old caches are
stripped on read
- /api/files reads only the first 256 bytes of each analysis cache to
get threshold/min_gap instead of parsing the whole JSON
- durations cached by (mtime, size) instead of re-opening every audio
header per request; stat() race with deleted files guarded
- /api/storage no longer walks the recordings tree (used bytes now
computed client-side from the file list)
- HTTP/1.1 keep-alive enabled; short writes force-close the connection;
client-disconnect tracebacks from aborted seeks silenced
- all file copies bounded by the advertised Content-Length so files
growing during a response cannot desync the connection
Live recording playback:
- /stream/ patches in-progress WAV headers to the current file size so
browsers show real duration and can seek (on-disk header says 0
frames until the recorder closes the file)
- active files served with Cache-Control: no-store
- reopening the player for a recording file reloads the source to pick
up newly captured audio
UI loading:
- analyses lazy-load only for expanded day groups; collapsed days defer
fetching until opened, and auto-load only when cached parameters
match the current controls (no surprise mass recompute)
- client-side analysis cache shared by file rows and day highlights, so
re-renders and filters never refetch
- filename filter debounced (200 ms)
- file list auto-refreshes when the active recording set changes,
unless audio is playing
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
web.py was 1700 lines, more than half of it a single embedded HTML
string. The page now lives in webui.html (loaded once at startup),
so the frontend gets real syntax highlighting and web.py is pure
Python. Dockerfile copies the new file alongside web.py.
Also: ASCII startup banner (the arrow glyph crashed web.py on Windows
when stdout was redirected to a cp1252 file), and README fixes —
document the ALSA PCM-name device fallback and drop the monitor
device row, which the ALSA backend never supported.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- web.py: Python class bodies can't close over a name they also assign;
use a temporary alias _analyses_dir to break the self-reference
- docker-compose.yml: mount ./recordings/analyses:/recordings/analyses
instead of a separate ./analyses volume so cache lives inside recordings;
remove --analyses-dir flag (default now resolves correctly); remap
external port 8080→8050 for reverse proxy
- README.md / CLAUDE.md: update Docker port references to 8050
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Docker web container mounts ./recordings as :ro, causing every cache
write to fail silently (PermissionError swallowed by bare except).
Fix: add --analyses-dir flag (default: <recordings>/analyses for local runs).
docker-compose.yml adds ./analyses:/analyses (writable) and passes
--analyses-dir /analyses to web.py. Cache write failures now print a
warning instead of being swallowed silently.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Cache files now live in recordings/analyses/<filename>.analysis.json
(mirroring the relative path for files in subdirectories) rather than
alongside each audio file.
- _api_delete now removes the corresponding cache file after deleting audio.
- prune_orphan_analyses() runs at startup and removes any .analysis.json
whose audio file no longer exists (handles files deleted outside the UI).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
After the first analysis of a WAV/FLAC file, the result is written to
<filename>.analysis.json next to the audio. Subsequent requests with the
same threshold and min_gap parameters return the cached result immediately
without re-reading the audio data. The cache is invalidated automatically
if either parameter changes. Written via temp-then-replace for thread safety.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Recordings table now groups files by day with collapsible headings
showing file count, total duration, and size; most recent day expands
by default, older days start collapsed
- Day highlights button runs loudness analysis across all WAV/FLAC files
in a day and renders a combined SVG activity timeline (blue = file
extents, orange = loud sections) with time labels
- Grace period control (default 2 s, max 300 s) merges loud sections
separated by less than this gap; exposed in the controls bar, via
--min-gap CLI flag, and as a per-request min_gap param on /api/analyze
- Delete re-renders via applyFilters so day headings stay consistent
Adds a DELETE /api/files/<name> endpoint that refuses to remove files
currently being recorded (409). The UI shows a red '✕ Delete' button per
row (disabled while REC), confirms before proceeding, and removes both
the data row and the hidden player row from the DOM on success without
a full page reload. README updated accordingly.
hw:0,0 is an exclusive ALSA device — darkice holding it caused arecord
to fail silently (stderr was /dev/null), leaving all recordings at 0 bytes
with no errors in the log.
asound.conf: defines a dsnoop virtual device 'shared_mic' that opens
hw:0,0 once and lets multiple processes capture simultaneously.
docker-compose.yml: mount asound.conf into the container as
/etc/asound.conf; add ipc: host so the container shares the host IPC
namespace (dsnoop uses System V shared memory which does not cross the
container IPC boundary without this).
config.example.ini: document the dsnoop setup and shared-device pattern.
README, CLAUDE.md: document the full setup procedure.
- Remove stale instruction to set output_directory = /recordings in Docker
- Document that docker compose down + up --build is required when updating
- Fix output_directory and log_file table descriptions
- Expand Web UI section: inline playback, FLAC waveform, live REC badge, WCAG
- Fix Docker notes: log_file path and log_file in Docker guidance
- Add rule to CLAUDE.md: always update and commit README.md with code changes