docs(multitrack): mark Stages 1+2 done

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-14 00:05:32 -04:00
co-authored by Claude Opus 4.8
parent f6520b79f7
commit 729f5ed6a5
+4 -4
View File
@@ -1,6 +1,6 @@
# Multitrack (stem) recording — plan / scope contract # Multitrack (stem) recording — plan / scope contract
**Status:** Stage 1 in progress (2026-06-13). This doc is the scope contract; update it as stages land. **Status:** Stages 1 + 2 DONE (2026-06-13). Stage 3 (config UI) next, then Stage 4 (field-test). This doc is the scope contract; update it as stages land.
## Goal & differentiation ## Goal & differentiation
@@ -18,7 +18,7 @@ The mixer loop (`src/core/mod.rs` ~L761788) already pops a decoded `frame` pe
## Stages ## Stages
### Stage 1 — Pure `MultitrackRecorder` core (no wiring) — *in progress* ### Stage 1 — Pure `MultitrackRecorder` core (no wiring) — DONE (`fde6f8a`)
`src/audio/multitrack.rs`. Owns a per-peer `HashMap<EndpointId, Track>` + a mic track + an optional mix track (Both mode), each a reused `recorder::WavWriter`, plus a `cycles` counter (the master clock). API: `src/audio/multitrack.rs`. Owns a per-peer `HashMap<EndpointId, Track>` + a mic track + an optional mix track (Both mode), each a reused `recorder::WavWriter`, plus a `cycles` counter (the master clock). API:
- `add_peer(id, name)` — create the track, pre-pad with `cycles * FRAME_SAMPLES` silence (late-join alignment); idempotent. - `add_peer(id, name)` — create the track, pre-pad with `cycles * FRAME_SAMPLES` silence (late-join alignment); idempotent.
- `write_peer(id, &[i16])` / `write_mic(&[i16])` / `write_mix(&[i16])` — append one cycle's frame (fit to `FRAME_SAMPLES`: zero-pad if short), mark the track written-this-cycle. - `write_peer(id, &[i16])` / `write_mic(&[i16])` / `write_mix(&[i16])` — append one cycle's frame (fit to `FRAME_SAMPLES`: zero-pad if short), mark the track written-this-cycle.
@@ -26,8 +26,8 @@ The mixer loop (`src/core/mod.rs` ~L761788) already pops a decoded `frame` pe
- `finalize(self)` — finalize all writers. - `finalize(self)` — finalize all writers.
Pure/testable: tests assert "after N cycles every track is exactly N×FRAME_SAMPLES" and "a peer added at cycle k carries k×FRAME_SAMPLES leading silence." Plus a filesystem-safe track-naming helper (`me.wav`, `<slug>-<shortid>.wav`, `mix.wav`) reusing `sanitize::sanitize_name`. Pure/testable: tests assert "after N cycles every track is exactly N×FRAME_SAMPLES" and "a peer added at cycle k carries k×FRAME_SAMPLES leading silence." Plus a filesystem-safe track-naming helper (`me.wav`, `<slug>-<shortid>.wav`, `mix.wav`) reusing `sanitize::sanitize_name`.
### Stage 2 — Wire into the mixer + mic tasks ### Stage 2 — Wire into the mixer + mic tasks — DONE (`f6520b7`)
Retain `peer_id` alongside each decoded frame in the mixer; tap the raw frame for stems; per cycle call `write_peer` for present peers, `write_mix` with the finished mix, `write_mic` from the mic FIFO, then `end_cycle`. `add_peer` on join (`RoomEvent::PeerJoined`/`PeerUpdated` carries the name), keep the track on leave (it just goes silent). Keep the existing single-file mixed `Recorder` path for `Mixed` mode. Gate by `is_recording` like today. Done: mixer taps each peer's raw frame into `stems`, writes peer stems + mix (Both) + `end_cycle` per cycle; mic pushed to the recorder's FIFO from the capture thread; `add_peer` on `PeerJoined` (named) + for everyone present at recording start; `Mixed` mode keeps the single-file `Recorder`; `RecordingMode` config + `SetRecordingMode` command (sent at startup) select the path; `is_multitrack` is the fast-path gate; `stop_recording` finalizes both. Note: mic uses an internal FIFO drained per cycle (not a per-cycle `write_mic`), matching `recorder.rs`. No UI yet → defaults to `Mixed`; set `recording_mode` in config.json to exercise stems until Stage 3.
### Stage 3 — Config + UI ### Stage 3 — Config + UI
`AppConfig.recording_mode: Mixed | Multitrack | Both` (serde-default `Mixed`, back-compat). New **"Recording"** category in Settings (fits the category-header layout) with the mode picker + an output-dir note. Output to a per-session dir `~/peerspeak-recordings/<timestamp>/` (Multitrack/Both); `Mixed` keeps today's single-file behaviour. `AppConfig.recording_mode: Mixed | Multitrack | Both` (serde-default `Mixed`, back-compat). New **"Recording"** category in Settings (fits the category-header layout) with the mode picker + an output-dir note. Output to a per-session dir `~/peerspeak-recordings/<timestamp>/` (Multitrack/Both); `Mixed` keeps today's single-file behaviour.