Listening (v0.4.0): the audio engine #4
Reference in New Issue
Block a user
Delete Branch "feature/listening"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Day 4 core (v0.4.0): the audio engine. Day page
docs/04_listening.mdin the app repo.New crate
liber-audio(reusable, no Liber types; pure, in the purity scan):stretch: WSOLA, 40 ms Hann frames, 50% overlap, ±12 ms search on the mono mix applied to every channel; streaming, speed 0.5–3× changeable between blocks.silence: pauses ≥ 300 ms shortened to 150 ms, streaming (the first 150 ms goes out, the rest is held until the pause proves long); a frame above −45 dBFS is never dropped; a map from output time back to the book's time.boost: 80 Hz high-pass, +5 dB bell at 2.5 kHz, compressor (−24 dB, 3:1), soft limiter that never passes ±1.player: chapters (tidy: sorted, bounded, ≤ 10,000), skips, previous/next chapter, sleep timer (minutes or end of chapter),Saver(every 900 ms with blocks ≤ 100 ms), a genericQueue.container: sniffing by content; MP4 box walk (duration, Nerochpl, title; DRM:aax/aaxcbrands,adrm,aabd,aavd,drms,drmi,enca), ID3v2CHAP/TIT2, WAV duration,.cue; caps on boxes, depth, tag size, frames, chapters; nothing allocated from a claimed size.decode: symphonia 0.5 (MPL-2.0; mp3, aac, isomp4, wav, pcm) behind caps (channels, rate, hours, consecutive errors);Read + Seeksources only.speech: the read-aloud cache key (voice, voice file hash, speed, language, text, length-prefixed) and the timeline (sentence / paragraph / title pauses) for the highlight.Mandatory tests (written with the code, all generated fixtures):
tests/engine.rs(7): pitch 180.0 Hz → 180.1 Hz at 0.5×, 1.5×, 3×, duration within 3% (measured 1.2%, 2.0% off); stereo keeps its phase; trimming keeps every loud speech sample and shortens only long pauses (±40 ms); the trimmed→book time map; 2,000 random kills never more than 1 s behind; boost never clips and lifts presence; chapters, skips, sleep.tests/hostile.rs(7): lying chapter counts, a terabyte box, a box smaller than its header, 40-deep nesting, 250,000 boxes, a 200 MB ID3 claim, 30,000 CHAP frames, a frame larger than its tag, truncated WAV, junk under any name, an MP4 without audio — each refused or ended cleanly in under 2 s.adrm,aabd,enca→ "This audiobook is DRM-protected, so Liber cannot play it."; a scan finds no decrypt path or crypto crate.tests/speech.rs(3): the highlight timeline across pauses; stretched audio stays within a frame; the cache key changes with voice, voice file or speed and nothing else.Workspace: 108 tests green; clippy 0;
scripts/deps.mjs --check115 crates, 0 not allowed.Self-review
chplparser; the QuickTime chapter track is not read yet (Nerochplis what most M4B tools write) — a gap noted in the day page. HE-AAC is not decoded by symphonia (no permissive decoder).