Text chat 58: fluxer-audio sound outline, trim to WAV, stopping one clip (#387) #409
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-58-audio-sound-edit"
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?
What this builds
fluxer-audio
edit.rs(new):SoundOutline { duration, channels, peaks }andedit::outline(bytes, content_type, buckets), where each bucket holds the loudest absolute sample of the channel average, from 0 to 1 (based onAudioWaveform.tsxcomputePeaks). Alsoedit::trim_to_wav(bytes, content_type, range, mono), which writes RIFF/WAVE PCM 16-bit at 48 kHz. The output is stereo, or one channel whenmonois set (the average, asdownmixToMono) or when the source is mono (asAudioWavEncode.ts). The range is clamped to the sound, and an empty range returnsClipError::Empty. The WAV header is written by hand, so there is no new dependency.clip.rs: a privatedecode_capped(bytes, content_type, Option<Duration>)that also returns the source channel count.decodecalls it with the 30 s cap.editcalls it with no cap, so a long file is trimmed down instead of refused. The 20 MiB input limit still applies.engine.rs:AudioEngine::stop_clip(tag)stops one clip and reportsEngineEvent::ClipFinishedfor it. Other clips and the chimes keep playing. A tag that is not playing is ignored.How it was tested
edit.rs):wav_header_is_pcm16_48k,trim_keeps_only_the_range,mono_downmix_averages_the_channels,stereo_is_kept_without_mono,range_is_clamped_to_the_sound,empty_range_is_an_error,long_source_is_trimmed_not_refused,entrance_length_mono_wav_fits_one_mib,outline_has_the_requested_buckets_and_duration,outline_of_garbage_is_an_error,trimmed_wav_decodes_back_to_the_range.tests/clips.rs:stop_clip_stops_only_that_tag(onNullHost).FLUXER_SCREENSHOT_TESTS=1 cargo xtask cipasses locally on Linux, at4d40f28.Deviations from the plan
None.
Closes #387
🤖 Generated with Claude Code
Review round 1. What changed for each finding:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cito completion on4d40f28and every step passed, includingpackage_produces_appimage_on_linux. Then I pushedtextchat-58-audio-sound-editand opened this PR. The code is unchanged.AudioWavEncode.ts(sourceChannels === 1), which the plan tells us to follow (encodeAudioBufferSliceToWav). The behaviour is documented in thetrim_to_wavdoc, the README and thestereo_is_kept_without_monotest. Tasks 59 and 60 only pass the bytes on.clip::decodekeeps a source's channels, which is more than a cheap fix.decode_capped(.., None). Deferred to follow-up #410. The plan specifies no cap, and the original has none, so choosing a sanity cap (such as 10 minutes) needs a decision.🤖 Generated with Claude Code
Independent review: Text chat 58 (
fluxer-audiosound outline, trim to WAV, stopping one clip)Reviewed cold:
git diff 6113a8e..origin/textchat-58-audio-sound-edit(commit4d40f28).(1) Tests. All 12 tests the plan names exist and pass.
entrance_length_mono_wav_fits_one_mibasserts 44 + 48 000 × 5.2 × 2 bytes, which is < 1 048 576.long_source_is_trimmed_not_refusedfirst shows thatclip::decodereturnsTooLong.trimmed_wav_decodes_back_to_the_rangemakes the round trip throughclip::decode.stop_clip_stops_only_that_tagruns onNullHostand checks that the other tag plays to its end.(2) Interfaces. These exist exactly as Task 59/61 consume them:
edit::SoundOutline { duration, channels, peaks }edit::outline(&[u8], Option<&str>, usize)edit::trim_to_wav(&[u8], Option<&str>, Range<Duration>, bool) -> Result<Vec<u8>, ClipError>ClipError::Emptyfor an empty or clamped-away rangeAudioEngine::stop_clip(&self, u64), which emitsClipFinishedclip::decode_cappedis a private (pub(crate)) variant with the cap as a parameter, anddecodekeeps the 30 s cap. The WAV header is written by hand and there is no new dependency.mixer.rsis listed in the plan but did not need a change.(3) Invariants. The diff only touches
fluxer-audio. Nothing is logged or written to disk, no paths, no secrets. Decoding stays insidecatch_unwind. No path throughframe_at,clampor the header arithmetic panics:startis at mostlen, and the sizes saturate.(4) Review Focus. No item belongs to this task.
(5) Local CI.
cargo xtask cipassed every step in the review worktree. The screenshot and livekit steps were skipped because their env vars were not set; this crate has no screenshots. The implementer reports a green run withFLUXER_SCREENSHOT_TESTS=1. I did not check remote CI.Findings
mono. This matchesAudioWavEncode.ts(sourceChannels === 1), so no change is needed.stop_clip_stops_only_that_tagstarts a chime but never checks that the chime keeps sounding afterstop_clip. The code is correct: the worker only matchesSourceId::Clip(tag).Verdict: approve. No blocking findings, and local CI is green.