Soundboard 58: fluxer-audio sound outline, trim to WAV, stopping one clip #387

Closed
opened 2026-11-13 01:40:51 +00:00 by charles · 0 comments
Owner

Plan: docs/superpowers/plans/2026-11-12-textchat.md, section "Task 58" (Soundboard and entrance sounds, added 2026-11-12, high priority per Charles).

Task 58: fluxer-audio sound outline, trim to WAV, stopping one clip

Issue: (to be created)
Closes: none.

Files:

  • Create: crates/fluxer-audio/src/edit.rs
  • Modify: crates/fluxer-audio/src/{lib.rs,clip.rs,engine.rs,mixer.rs}, crates/fluxer-audio/README.md
  • Test: crates/fluxer-audio/src/edit.rs (unit), crates/fluxer-audio/tests/clips.rs

Interfaces:

  • Produces: edit::SoundOutline { duration: Duration, channels: u16, peaks: Vec<f32> /* 0..=1, one per bucket */ }; edit::outline(bytes: &[u8], content_type: Option<&str>, buckets: usize) -> Result<SoundOutline, ClipError>; edit::trim_to_wav(bytes: &[u8], content_type: Option<&str>, range: Range<Duration>, mono: bool) -> Result<Vec<u8>, ClipError> — RIFF/WAVE PCM 16-bit, 48 kHz, stereo or (with mono, the entrance trimmer's downmixToMono) the channel average, as encodeAudioBufferSliceToWav; the range is clamped to the sound, an empty range is ClipError::Empty. Both decode a source of up to MAX_CLIP_BYTES with no MAX_CLIP_DURATION cap (a long file is trimmed down, not refused): clip::decode gets a private variant with the cap as a parameter. No new dependency (the WAV header is written by hand). AudioEngine::stop_clip(&self, tag: u64) stops one clip started with play_clip and reports EngineEvent::ClipFinished for it; others and chimes play on.

  • Step 1: Write failing tests: 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 (5.2 s → < 1 048 576 bytes), outline_has_the_requested_buckets_and_duration, outline_of_garbage_is_an_error, trimmed_wav_decodes_back_to_the_range (round trip through clip::decode), stop_clip_stops_only_that_tag (tests/clips.rs, on NullHost).

  • Step 2–5: FAIL → implement → PASS → commit feat(audio): sound outline, trim to WAV and stopping one clip.

🤖 Generated with Claude Code

Plan: `docs/superpowers/plans/2026-11-12-textchat.md`, section "Task 58" (Soundboard and entrance sounds, added 2026-11-12, high priority per Charles). ### Task 58: `fluxer-audio` sound outline, trim to WAV, stopping one clip **Issue:** (to be created) **Closes:** none. **Files:** - Create: `crates/fluxer-audio/src/edit.rs` - Modify: `crates/fluxer-audio/src/{lib.rs,clip.rs,engine.rs,mixer.rs}`, `crates/fluxer-audio/README.md` - Test: `crates/fluxer-audio/src/edit.rs` (unit), `crates/fluxer-audio/tests/clips.rs` **Interfaces:** - Produces: `edit::SoundOutline { duration: Duration, channels: u16, peaks: Vec<f32> /* 0..=1, one per bucket */ }`; `edit::outline(bytes: &[u8], content_type: Option<&str>, buckets: usize) -> Result<SoundOutline, ClipError>`; `edit::trim_to_wav(bytes: &[u8], content_type: Option<&str>, range: Range<Duration>, mono: bool) -> Result<Vec<u8>, ClipError>` — RIFF/WAVE PCM 16-bit, 48 kHz, stereo or (with `mono`, the entrance trimmer's `downmixToMono`) the channel average, as `encodeAudioBufferSliceToWav`; the range is clamped to the sound, an empty range is `ClipError::Empty`. Both decode a source of up to `MAX_CLIP_BYTES` with no `MAX_CLIP_DURATION` cap (a long file is trimmed down, not refused): `clip::decode` gets a private variant with the cap as a parameter. No new dependency (the WAV header is written by hand). `AudioEngine::stop_clip(&self, tag: u64)` stops one clip started with `play_clip` and reports `EngineEvent::ClipFinished` for it; others and chimes play on. - [ ] **Step 1: Write failing tests**: `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` (5.2 s → < 1 048 576 bytes), `outline_has_the_requested_buckets_and_duration`, `outline_of_garbage_is_an_error`, `trimmed_wav_decodes_back_to_the_range` (round trip through `clip::decode`), `stop_clip_stops_only_that_tag` (`tests/clips.rs`, on `NullHost`). - [ ] **Step 2–5:** FAIL → implement → PASS → commit `feat(audio): sound outline, trim to WAV and stopping one clip`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
charles added this to the Text chat milestone 2026-11-13 01:40: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#387
No description provided.