fluxer-audio edit: decode cap for the trimmer, all-channel downmix, computePeaks bucketing #410

Open
opened 2026-11-13 02:56:51 +00:00 by charles · 0 comments
Owner

Follow-up from the review of #409 (Text chat 58, #387). Seen on commit 4d40f28.

  1. Decode length cap for the trimmer. edit::outline and edit::trim_to_wav call clip::decode_capped(.., None). As the plan specifies, this has no frame cap. A very low-bitrate file under 20 MiB can hold hours of audio and decode to gigabytes of 48 kHz stereo PCM. The file is the user's own pick, not server data, so no invariant is broken. A sanity cap (for example 10 minutes) would bound memory. Choosing the value needs a decision, because the original has no cap.
  2. More than 2 channels. The decoder keeps only the first two channels. So for a 5.1 source, the mono downmix in trim_to_wav and the peaks in outline average two channels, while the original (AudioWavEncode.ts downmixToMono, AudioWaveform.tsx computePeaks) averages all of them. This is cosmetic.
  3. Outline buckets. outline splits the frames into even buckets (index * buckets / len). computePeaks uses floor(len / bins) samples per bin, so its last frames can fall outside any bin. This is a cosmetic difference in the waveform.

Repro for 1: give edit::outline a 20 MiB, 8 kbps mono MP3 (about 5.8 hours) and watch memory grow by several GiB.

Follow-up from the review of #409 (Text chat 58, #387). Seen on commit 4d40f28. 1. **Decode length cap for the trimmer.** `edit::outline` and `edit::trim_to_wav` call `clip::decode_capped(.., None)`. As the plan specifies, this has no frame cap. A very low-bitrate file under 20 MiB can hold hours of audio and decode to gigabytes of 48 kHz stereo PCM. The file is the user's own pick, not server data, so no invariant is broken. A sanity cap (for example 10 minutes) would bound memory. Choosing the value needs a decision, because the original has no cap. 2. **More than 2 channels.** The decoder keeps only the first two channels. So for a 5.1 source, the mono downmix in `trim_to_wav` and the peaks in `outline` average two channels, while the original (`AudioWavEncode.ts` `downmixToMono`, `AudioWaveform.tsx` `computePeaks`) averages all of them. This is cosmetic. 3. **Outline buckets.** `outline` splits the frames into even buckets (`index * buckets / len`). `computePeaks` uses `floor(len / bins)` samples per bin, so its last frames can fall outside any bin. This is a cosmetic difference in the waveform. Repro for 1: give `edit::outline` a 20 MiB, 8 kbps mono MP3 (about 5.8 hours) and watch memory grow by several GiB.
charles added this to the Text chat milestone 2026-11-13 02:56:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#410
No description provided.