Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

docs: audio mixer (architecture §5.1, control protocol ids, mixer tests); ROADMAP: M7 mixing

Brandon Thomase7bb3c431c91
diff --git a/ROADMAP.md b/ROADMAP.md
index f86088ad3..0c7cf68c9 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -2,7 +2,7 @@
Progress toward feature parity with Adobe Premiere Pro, with estimates. Updated as milestones land.
-**Last updated:** 2026-09-30 (midday) · **Overall parity:** ~32% · **Code:** ~71k lines of Rust, 400+ tests
+**Last updated:** 2026-10-01 · **Overall parity:** ~33% · **Code:** ~71k lines of Rust, 400+ tests
## Estimate to parity
@@ -35,7 +35,7 @@ Status: ✅ done · 🟡 in progress · ⬜ not started. Estimates are remaining
| M4 | Playback | 🟡 | Audio-clock master, prefetch, J/K/L, dropped-frame stats, playback resolution | Render previews, render bar, 4K/8K tuning | 8–12 |
| M5 | Effects, keyframes, GPU | 🟡 | ~60 CPU effects, 30 transitions, keyframes + value/velocity graphs, wgpu compositor | Full ~150-effect catalogue, WGSL parity for all, masks + tracking, adjustment layers, presets, Warp Stabilizer, Morph Cut | 30–45 |
| M6 | Export | ✅ | Own H.264 encoder (High/Main/Baseline, B-frames, VBR/CBR/2-pass) → MP4 + own AAC; ProRes, MJPEG, PNG, GIF, WAV; background jobs | Preset library, queue UI, smart render | 6–8 |
-| M7 | Audio | 🟡 | Mixer basics, peak meters, BS.1770 loudness meters (M/S/I LUFS, true peak; matches ffmpeg), DSP crate, 12 clip audio effects running on it (EQ, filters, dynamics, limiter, delay, reverb, DeNoise, DeHum, pitch) with keyframes | Effects UI polish (EQ curve), remaining effects (multiband, convolution reverb), track effects/mixers with automation, Essential Sound, audio transitions, 5.1 | 6–10 |
+| M7 | Audio | 🟡 | Mixer graph (tracks → submixes → Mix, pre/post-fader inserts and sends, latency-compensated, sample-accurate, ~6× realtime for 24 tracks × 3 effects on one core), Audio Track Mixer + Audio Clip Mixer panels, track automation (Off/Read/Latch/Touch/Write, recorded live while playing, thinned to keyframes, timeline lanes with pen editing), solo/solo-safe, channel mapping basics, peak + BS.1770 loudness meters (match ffmpeg), DSP crate with 12 clip/track effects, Audio Gain (set/adjust/normalize), Constant Power / Constant Gain / Exponential Fade | Essential Sound, 5.1 panner and multichannel buses, voice-over record, effect editor windows (EQ curve), remaining effects (multiband, convolution reverb), clip-mixer automation recording | 6–9 |
| M8 | Colour | 🟡 | Lumetri: basic, creative + looks, RGB & hue curves, wheels, HSL secondary, vignette; basic scopes | LUT import UI, colour match, colour management + HDR (PQ/HLG, log, tone mapping) | 8–12 |
| M9 | More codecs | 🟡 | ProRes decode+encode, AAC decode+encode, HEVC Main/Main 10 decoder (bit-exact on 41 fixtures, ~225 fps 1080p), Matroska/WebM import (H.264/HEVC/ProRes/MJPEG + AAC/Opus/FLAC/MP3/Vorbis/PCM), Opus decoder (SILK/CELT/hybrid, 5.1/7.1 multistream; all RFC 8251 vectors range-exact; WebM/MKV/MP4) | VP9 (in progress), Ogg Opus files, AV1 (rav1d), DNxHR, MXF, hardware decode | 12–20 |
| M10 | Graphics & captions | 🟡 | Caption tracks (Subtitle/CEA-608/708/Teletext formats, track style), SRT/WebVTT/SCC import+export (frame-exact, property-tested), caption editing (add/split/merge/trim/move, sync-locked insert/extract), Text panel Captions tab, burn-in in Program monitor and export | Text engine with shaping, Type tool, Essential Graphics, rolls/crawls, MCC/STL/TTML, 608/708 embedding, speech-to-text | 18–27 |
@@ -49,6 +49,7 @@ Status: ✅ done · 🟡 in progress · ⬜ not started. Estimates are remaining
## Log
+- **2026-10-01:** Audio mixing (M7.2/M7.5/M7.6 basics): mixer graph with submixes, sends, inserts and latency compensation; Audio Track / Clip Mixer panels; Latch/Touch/Write automation recorded live; timeline track keyframes; Audio Gain dialog.
- **2026-09-30 (evening):** Opus decoder (RFC 6716/8251, range-exact on every conformance vector, ~80–110× realtime 48 kHz stereo) wired into WebM/MKV and MP4 import.
- **2026-09-30 (afternoon):** Matroska/WebM import; LUFS meters; clip audio effects on the DSP crate.
- **2026-09-30 (midday):** HEVC decoder, Matroska/WebM demuxer and audio DSP merged; HEVC import wired; asset rules (AGENTS.md, ATTRIBUTION.md, `cargo xtask assets`); README with hero screenshot and the Craft family.
diff --git a/docs/architecture.md b/docs/architecture.md
index c225ff120..8163747bc 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -115,7 +115,10 @@ Sequence
Track
├─ locked, sync lock, targeting, mute/solo/visibility
├─ items: Vec<TrackItem> sorted, never overlapping
-└─ transitions: Vec<Transition>
+├─ transitions: Vec<Transition>
+└─ audio: volume_db, pan, effects (mixer inserts), mixer: MixerStrip
+ (automation mode + lanes, sends, output, record arm, solo safe, input map)
+Sequence (audio) ─ submix_tracks: Vec<Track>, master_volume_db / master_effects / master_mixer
TrackItem (a clip instance)
├─ item: ItemId, start (timeline ticks), source_in (media ticks), duration, speed
├─ link group, label, enabled
@@ -208,8 +211,50 @@ file ──► codecs (MP4/MOV, MKV, audio) demux + decode, GOP-aware see
- **Audio clock.** The desktop app passes a cpal output (`apps/filmcraft/src/audio.rs`) to the UI as
`AudioOut`. While playing, the samples played by the sound card drive the playhead and video follows.
Without an audio device, playback falls back to the wall clock. Dropped frames are counted.
- Sequence audio is mixed in `render::audio`, and clip audio effects run on `audio-dsp` via
- `render::audio_fx`.
+ Sequence audio goes through the mixer graph (`render::mixer`, §5.1); clip audio effects run on
+ `audio-dsp` via `render::audio_fx`.
+
+### 5.1 Audio mixer
+
+```text
+clip: gain → clip effects → Volume / Channel Volume / Panner (clip keyframes, media time)
+ → audio transitions → summed per track render::audio::track_input
+track / submix strip: input map, mono fold → pre-fader inserts → pre-fader sends → mute
+ → fader (volume) → meter → post-fader inserts → post-fader sends → pan / balance → output
+Mix: bus sum → pre-fader inserts → fader → meter → post-fader inserts → out render::mixer
+```
+
+- **Model** (`project::mixer`). Every audio track, submix and the Mix has a `MixerStrip`. Static
+ values stay in `Track::volume_db`, `pan`, `muted` and the send/effect parameters; automation is
+ keyframes in sequence ticks: lanes `volume`, `pan`, `mute` (hold), `send.<i>.level` in
+ `MixerStrip::lanes`, and insert parameters (`fx.<slot>.<param>`) in the effect's own keyframes.
+ Up to 5 inserts (`EffectInstance::post_fader` picks the side) and 5 sends per strip. Submixes feed
+ the Mix or a submix after them (no feedback). All fields have serde defaults, so older projects
+ load unchanged.
+- **Graph** (`render::mixer::mix_graph`). Lanes are evaluated per sample; effect parameters update
+ on an absolute 64-sample grid, so the output does not depend on how callers cut the timeline into
+ requests (export batches and device callbacks give identical samples). Inserts that report
+ latency delay their strip; each route into a bus gets a compensation delay and the graph is read
+ ahead by its total latency. Graph state (DSP, delay lines) is cached per structure and continued by
+ sequential readers; other requests start fresh with a pre-roll (effect tails, ≤ 3 s). Tracks run
+ in parallel (rayon), buses in order. Mono tracks pan with the −3 dB constant-power law; stereo
+ tracks and sends use balance. Solo keeps soloed and solo-safe strips plus everything feeding them
+ or fed by them. 24 tracks × (EQ + Dynamics + Studio Reverb) + a compressed submix renders at
+ ~6× realtime on one core (release).
+- **Automation modes** (Premiere semantics). Off ignores lanes; Read plays them; Latch records from
+ the first touch and holds the last value until playback stops; Touch records while held and ramps
+ back to the existing automation over the **automatch time** (Preferences ▸ Audio, 1 s); Write
+ records every control from playback start (then switches to Touch unless "Switch to Touch after
+ Write" is off).
+- **Recording** (`engine::mixer`). Playback start runs `mixer.recordStart`, stop runs
+ `mixer.recordStop`. Fader and knob drags send `mixer.touch` (value, playhead) while held and
+ `mixer.release` when let go. Held values go to `render::mixer::LiveMix`, which the playing mix
+ reads, so moves are heard at once. At stop each gesture stream is thinned (linear keyframe
+ thinning, optional minimum time interval) and written over its time range as one undo step,
+ with boundary keyframes that keep the automation outside the range unchanged.
+- **Live state.** `PreviewStore::live` (`LiveMix`) also carries per-strip meter peaks posted by the
+ mix (Track Mixer and Audio Meters read them) and the newest project snapshot, which the audio
+ callback uses, so edits made during playback are heard.
## 6. Export jobs (`filmcraft-export`)
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index ecf201357..e759f7c85 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -31,6 +31,20 @@ Methods (handlers in `crates/ui-egui/src/control.rs`):
Element ids are stable, e.g. `timeline.clip.<id>`, `timeline.track.V1.lock`, `tools.Razor`,
`project.item.<id>`, `effects.item.gaussian_blur`, `panel.tab.Timeline`, `program.transport.playback.toggle`.
+Audio mixing: `mixer.*` commands (strips `"A1"`, `"S1"`, `"Mix"` or ids; lanes `volume`, `pan`,
+`mute`, `send.<i>.level`, `fx.<slot>.<param>`): `mixer.inspect`, `mixer.setStrip` (volume, pan, mute,
+solo, record arm, solo safe, mode Off/Read/Latch/Touch/Write, output, input map, channels),
+`mixer.setValue`, `mixer.touch` / `mixer.release` (a fader gesture; recorded during an automation pass),
+`mixer.recordStart` / `mixer.recordStop` (playback runs them), `mixer.addSubmix`, `mixer.deleteSubmix`,
+`mixer.addInsert` / `removeInsert` / `setInsert`, `mixer.addSend` / `setSend` / `removeSend`,
+`mixer.setKeyframe` / `deleteKeyframe` / `moveKeyframe` / `clearLane`, `mixer.writeAutomation`;
+`clipMixer.set`; `clip.audioGain {mode: set|adjust|normalizeMax|normalizeAll, db}`, `clip.audioPeak`;
+`effects.setDefaultTransition`. UI ids: `mixer.<A1|S1|Mix>.<fader|value|pan|panValue|mode|mute|solo|
+record|soloSafe|output|input|fx.<n>|send.<n>|meter|name>` (popup entries below them, e.g.
+`mixer.A1.mode.Touch`, `mixer.A1.fx.0.studio_reverb`), `mixer.showEffects`, `mixer.transport.<cmd>`,
+`clipMixer.A1.<fader|pan|mute|solo|keyframe|value>`, `timeline.track.A1.keyframes[.<lane>|.clip]`,
+`timeline.track.A1.lane[.kf.<n>]`, `audioGain.<set|adjust|normalizeMax|normalizeAll|ok|cancel|peak>`.
+
Project files, auto-save, crash recovery and preferences commands (`file.recover`, `prefs.set`, …) and their
automation ids are listed in [project-files.md](project-files.md).
diff --git a/docs/testing.md b/docs/testing.md
index 8d4304535..a9fdb4546 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -20,6 +20,7 @@ FILMCRAFT_REQUIRE_ORACLES=1 cargo test --workspace # CI: missing ffmpeg fails
| Golden images | `crates/golden/tests/golden.rs` | CPU renders vs committed PNGs; GPU vs CPU on the same scenes (§3) |
| Engine / command | `crates/engine/src/tests.rs` | run commands on the demo project, assert the sequence, undo/redo, disabled cases |
| Render | `crates/render/src/tests.rs` | compositing, opacity, Motion, cross dissolve midpoint, ½-res vs full, GPU plan vs reference, audio mix, audio-effect continuity |
+| Mixer | `crates/render/src/mixer_tests.rs`, `crates/engine/src/mixer_tests.rs` | sample-exact fader gain and pan laws, automation at block boundaries (bit-identical however requests are cut), solo/mute/solo-safe, sends and submix routing, latency-compensation alignment, render-vs-playback identity, Touch ramp-back, recorder modes (Latch/Touch/Write), thinning, Audio Gain, transition curves; `perf_24_tracks_3_effects_realtime_factor` prints the realtime factor |
| Oracle | `crates/*/tests/*oracle*.rs`, `conformance.rs` | compare with ffmpeg/ffprobe (§2) |
| Robustness / fuzz | `*/tests/robustness.rs`, `*/tests/fuzz.rs` | seeded mutation and truncation of real and synthetic files; nothing may panic |
| Performance | `*/tests/perf.rs` (`#[ignore]`) | §5 |
@@ -127,6 +128,12 @@ next frame by the app's own `raw_input_hook`, so clicks by automation id work he
| `clicking_a_tool_button_by_automation_id` | `ui.click {id: "tools.Razor"}` changes the tool (real egui input path) |
| `unknown_methods_and_commands_fail_cleanly` | errors come back as `{"ok": false}` |
+`crates/ui-egui/tests/mixer_ui.rs` drives the Audio Track Mixer, Audio Clip Mixer, timeline track
+keyframes and the Audio Gain dialog by automation id and with multi-frame pointer drags (press, move
+over several frames, release). With `FILMCRAFT_UI_SNAPSHOT_DIR=<dir>` it also renders the window
+offscreen through wgpu (`Harness::render`) and writes `mixer-*.png`; this works without a visible
+window (for example on a locked screen, where `ui.screenshot` cannot capture).
+
Not covered headless: `ui.screenshot` (needs a real viewport), the wgpu monitor path (the harness
runs the CPU texture path), audio output, and wall-clock playback advance (kittest frames do not
advance real time). Use `Driver` for new UI regressions: `d.exec(command, params)`,