Commits
Commits on
a3e9dc2d50d8a2595e06b8d5fbcde7eeb078b2bcFiltered to crates/engine/src/audio.rsClear filter2026-08-10
✨ feat(audio): AC3 tracks decode with a built-in stereo downmixAhmet Kaan Gümüş · 8c7bf80Browse files
✨ feat(audio): per-clip equalizer is live in playback and exportAhmet Kaan Gümüş · 4d92155
✨ feat(audio): per-clip equalizer is live in playback and export The model, the format and the filter have all existed with no callers. This wires them: `Project::audio_eqs_from` hands one curve per segment beside the play list `audio_segments_from` already builds, `open_mixed_streams_eq` gives each lane's worker those curves, and `emit` -- the one place both readers hand their samples over -- filters a segment after it is trimmed and before it is sent. Playback and an audio export therefore get the same filtered stream by construction rather than by two call sites agreeing. A parallel list, not a fourth element of the segment tuple: that tuple is what every opener, the packet-copy path and a dozen tests speak, and an effect is not part of which samples a segment names. A short list plays flat, so a mismatch can neither panic nor shift a curve onto the wrong clip. Live editing needs no channel into a running worker: `set_eq` is an edit and every edit reseeks, so the workers are rebuilt from the new curves where the playhead is standing. An mp4 export copies AAC packets and no filter can reach a copy, so an equalized clip is refused by name and by timecode rather than written flat. The card is the third of its kind (same scrim, width and rows as keys and export): a row per band, dragged from the middle out, with `q` to open it and 1-5 / up / down / r as its own keyboard, every one of them listed in the keys menu by the registry the guard test reads.
✨ feat(engine): N-lane compositing in playback and exportAhmet Kaan Gümüş · 08af6bc
✨ feat(engine): N-lane compositing in playback and export Video: the topmost video lane with a clip there wins, topmost being the last lane in display order (V2 over V1, the overlay convention). No blending, so exactly one lane is visible per frame and the composite is itself a span list -- Project::composite_span_at -- which one decoder plays. N video lanes never mean N decoders; a lane change costs the one decoder reopen a cut already costs. Audio: every audio lane that holds something gets a play list (Project::audio_segments_from) and AudioSession::open_mixed_streams sums them, clamped, each lane keeping its own gap rule so the master clock counts a sample per sample of timeline. One lane skips the mixer entirely and is the byte-for- byte path it always was. Export walks the same composite and mixes the same lanes for WAV/FLAC. The mp4 path copies AAC packets and cannot mix, so a timeline whose sound is spread over two lanes is refused there by name rather than silently exported without half of it.
✨ feat(engine): AV1 import via the VA-API pluginAhmet Kaan Gümüş · 6d3e3ba
✨ feat(engine): AV1 import via the VA-API plugin
AV1 arrives in Matroska, never in an mp4 -- `mp4 0.14` knows no `av01`
sample entry at all -- so the demuxer grows a second container:
`MkvDemuxer` walks the EBML itself, indexes every block of the AV1 track
in one header-only pass (payloads are seeked over) and hands each block
to the decoder as the temporal unit it is, with the `av1C` sequence
header re-injected ahead of every keyframe the way the H.264 parameter
sets are.
Matroska indexes neither the frame count nor the frame rate, which is why
that walk exists: the count is the blocks of the track and the rate is
`DefaultDuration` in nanoseconds (33333333 = 30 fps to seven digits,
where the millisecond block timestamps beside it would say 30.30).
Keyframe flags come out of the same pass, so a seek lands on a sync point
without a Cues element and without guessing at the bitstream.
Audio is picture-only for now: a Matroska file is a silent source and
says so by name ("A_AAC audio in a Matroska file is not wired to the
decoder yet") rather than failing in the mp4 reader's words. 10- and
12-bit AV1 are refused at open like HEVC Main 10, for the same 8-bit
read-back reason.
No new dependency: symphonia's mkv reader drops the keyframe flag and
`DefaultDuration` and offers no frame count, so it could not have done
the job. edith keeps its 7 DT_NEEDED entries.Merge S5a audio-file import into stream-picker mainAhmet Kaan Gümüş · 1bb8ee2
Merge S5a audio-file import into stream-picker main
Both sides taught `audio` a new axis and they meet on one type: S5a made
`Track` an enum over the mp4/AAC reader and symphonia's, main gave every
reader a `(path, stream)` address. The merged `Track::open(path, stream)`
keeps both -- the stream index lives inside `AacTrack::open`, and a
standalone audio file, which has exactly one track by construction, refuses
any stream above 0 rather than quietly serving the only one it has.
- `AudioProbe` is S5a's `{sample_rate, channels}`: equality is playability,
so an mp3 may share a timeline with mp4s. Copyability is a separate
refusal, at export, and stays AAC-only through `copy_track`.
- `probe_streams` reads a standalone file through symphonia instead of
walking it as an mp4 -- an ALAC .m4a parses as an mp4 whose only audio
track is not AAC, so the mp4 walk would call it undecodable where
symphonia decodes it.
- Which lane a source lands on is decided once, in `place_stream_at`: a
file with no picture is placed on the audio lane alone, everything else
is pasted as a grouped take. The front-end only owes the refusal notice.
- `unsupported()` and the NTSC/VP9 work are untouched; `is_audio` files
never reach the former, since a song cannot open a timeline at all.✨ feat(engine): common audio files import and playAhmet Kaan Gümüş · fe53979
✨ feat(engine): common audio files import and play mp3, wav, flac, ogg-vorbis, ALAC and ADTS join a timeline as sources with no picture: symphonia's own probe reads them, the audio lane holds them, and the video lane refuses them by name. The mp4/AAC path is untouched -- it is still the only one that yields packets an export can copy, so a timeline carrying anything else is refused at export with the file and its format named rather than exported silent. A source with no picture is as long as it plays, rounded up to whole frames; import, load and the library row all derive its length from that.
✨ feat(library): every audio stream is a row, and the picked one plays and exportsAhmet Kaan Gümüş · ecb5e06
✨ feat(library): every audio stream is a row, and the picked one plays and exports A file with one audio track per language is one row per track now, not one row per file. The engine carries the pick end to end: a source is a (file, audio stream) pair, .edith v3 writes the stream on the source line, playback opens it and — the trap this closes — the export copies *that* stream's packets rather than always stream 0. Streams that cannot go on the timeline are listed greyed with the reason instead of hidden: a codec we cannot read, or a rate/layout that cannot share one output device and one copied AAC track with the rest of the timeline (there is no resampler here and no AAC encoder to write a join with). place_stream_at is the one door a row goes through, and it refuses those in the engine's own words. - v2 and v1 files still load: no stream field means stream 0, which is all those dialects could play; saving either writes v3. - Waveform peaks are keyed by file *and* stream, so two tracks of one file cannot draw each other's envelope. - Library swatches and clip tints follow the *file*, so a file's streams share one colour in the panel and on the lanes. - assets/test_multilang.mp4: two AAC 44.1k stereo streams (und, fra), the shape real multi-language media has and the one where a second stream is placeable.
🐛 fix(engine): NTSC frame rates survive the sample tableAhmet Kaan Gümüş · 3f81ef8
🐛 fix(engine): NTSC frame rates survive the sample table `mp4 0.14`'s `Mp4Track::frame_rate` divides the sample count by whole milliseconds before the float cast, so 24000/1001 read back as a flat 23.0: the picture the audio-sample master clock asked for was 4 % out and the drift grew with the film — five minutes of it by the end of a two-hour one. The frame rate now comes off the stts totals in f64, which is exactly `timescale / delta` for a constant table and an average for a spread one. The same truncation lived at the writing end (a 90 kHz clock cannot count 23.976 fps in whole ticks), so the muxer picks a timescale that can: 90 kHz wherever it divides exactly — every integer rate, so those exports are byte for byte what they were — and `round(fps * 1001)` over 1001 ticks otherwise, which is exact for the whole NTSC family. The hardware encoder gets that same rational instead of a rounded `fps * 1000`. The video edit list is honoured now too, the way the audio one always was — but only what it really trims: a `media_time` equal to the first `ctts` offset is the B-frame composition delay, not a cut, and reading it as one throws two real frames away. A file whose audio we cannot decode at all (an AC-3 remux) played silent with the reason on stderr; the session carries it now and the window says NO AUDIO in its notice bar.
✨ feat(engine): every audio stream is listed, and any one of them opensAhmet Kaan Gümüş · dff7d84
✨ feat(engine): every audio stream is listed, and any one of them opens A remux carries one audio track per language; the engine took whichever AAC track a HashMap handed it first and there was no way to ask for another. - probe_streams() describes every audio track in file order, undecodable ones included (decodable: false) so a picker can grey them rather than hide them - open_multi_streams() takes (path, stream) per source; the old open_multi_segments is a wrapper pinning stream 0, so no caller moved - stream ids come from moov.traks, not the tracks HashMap: "stream 0" was a different track run to run on a multi-track file - a named stream that is missing or not AAC is an Err; stream 0 stays the silent source it always was, because a file we cannot decode the audio of still has a picture worth editing - assets/test_multiaudio.mp4: video + AAC stereo + AAC mono (fra) + AC-3, which covers the picking, the language and the greyed row
🐛 fix(engine): group ids only where the lanes agree, priming for a leading gapAhmet Kaan Gümüş · 07cd3d3
🐛 fix(engine): group ids only where the lanes agree, priming for a leading gap Two states the verifier panel reached that saved but would not load again. `split` and `regroup` handed one fresh id to whichever clip each lane had at that frame, but the lanes are edited apart: the clip being cut may start or end somewhere else in the other lane, and a group id whose two clips disagree about their span is not one take. Each side of the cut now asks the question separately, so the halves that do line up stay one take and the ones that do not get ids of their own. The exported audio of a timeline that opens on a hole played every sound after the hole 23 ms early: a reader drops the first packet of an AAC track as priming, and with no packet to spare that drop came out of the hole. The gap at the head now carries one extra silent packet, which owes the rounding debt nothing. Tests: both panel repros, a seeded random-op sweep that reloads the project after every edit, and the leading-gap onset measured off the exported file (44032 of an expected 44100; 43008 without the packet).
✨ feat(engine): real silent AAC for export gaps, link + overflow guardsAhmet Kaan Gümüş · 301e29b
✨ feat(engine): real silent AAC for export gaps, link + overflow guards Grafts the losing candidate's hand-written AAC-LC silence into the offset-placed lanes: a gap in the audio lane is copied as max_sfb=0 access units (4 bytes mono, 7 stereo, verified against our own decoder) instead of being spent as stts duration on the packet in front of it. That retires the 23 ms leading-gap misplacement, so every packet is one 1024-frame sample table entry again and the muxer takes no duration. from_parts becomes the release-active untrusted door it claims to be: per-cause errors, an end-overflow bound, and the grouping rules -- a link id names at most one clip per lane, and a pair covers one span. The parser bounds the same overflow by line number, `place` strips the incoming group id, and the two lane surgeries (`clear`, `open_room`) drop the id from what they cut, which is where duplicates came from.
✨ feat(engine): video+audio lanes with offset-placed clips, gaps, .edith v2Ahmet Kaan Gümüş · 59eb78e
✨ feat(engine): video+audio lanes with offset-placed clips, gaps, .edith v2 Project gains two lanes; a Clip now carries `start` (its timeline placement) and `link` (group id), so a gap is simply the absence of a placement rather than an object anyone has to keep in sync. Moves and trims become arithmetic on start/in_frame; the lane invariant (sorted, non-overlapping) is checked in from_parts, at the .edith parser, and asserted after every mutation. split cuts every lane and hands the two sides fresh group ids; regroup is its exact inverse. delete still ripples both lanes (the app keeps its behaviour), lift removes one placement and leaves a hole, place is the per-lane overwrite that can make one. A video gap plays as black frames from a worker that opens no file -- same channel, backpressure, cancel and retire path as a decoder -- and exports as encoded black. An audio gap is synthesised zero chunks, real ones, so the master clock keeps counting through it; on the export side it is spent as stts duration on the packet beside it, since there is no AAC encoder to make silence with. .edith v2 writes one line per placement per lane; v1 files still load, as fully-grouped gapless lanes, and save as v2.
2026-08-09
✨ feat(engine): multi-source model + segmented multi-file audioAhmet Kaan Gümüş · 5593a9f
✨ feat(engine): multi-source model + segmented multi-file audio Wave 1 of the import slice: the timeline model and the audio backend both learn about several source files. Nothing user-visible yet — every clip is still source 0 until playback/export traversal lands. S1 — project.rs model + mechanical call-site fixes: - Clip gains `source: usize` (Clip stays Copy, so clipboard/undo semantics are untouched); Project gains an append-only `sources: Vec<PathBuf>`. - Import splits in two: `import(path) -> usize` is dedup-only and pushes no history, `append_clip(source_idx, frame_count) -> bool` pushes the one snapshot — an import stays exactly one undo step, and append_clip refuses an unknown index. - Dedup key is fs::canonicalize with a raw-path fallback, so Project stays pure data and an unreadable path still gets an index. - cut/paste carry the source through `..self.clips[idx]` struct-update. - `segments_from` now yields (source, start, end) triples; playback.rs and export.rs strip the index and keep feeding the single-source audio fns. S2 — audio.rs Track/probe/bit-exact joins: - New private `Track` resolves one source once (reader, copied stts, own priming, params, sample_count). - `open_multi_segments` / `copy_multi_segments` take the source triples; `open_segments` / `copy_segments` are now one-source wrappers, so every existing call site compiles unchanged. - Each source contributes its own priming and length; the timeline sample counter and the bresenham rounding debt both run continuously across a source join, and the extra priming packet stays the first segment's alone. - `AudioSession::probe(path) -> Option<AudioProbe>` exposes the fields import validation needs. - Cross-source decode is bit-exact against single-file open_at on both sides of a join (max abs diff 0e0).
✨ feat(engine): export lane 1 — mux module, AAC packet copyAhmet Kaan Gümüş · 5ce68fe
✨ feat(engine): export lane 1 — mux module, AAC packet copy mux.rs is the write side of demux.rs: split_annex_b/nal_type feed a repack to 4-byte-length-prefixed samples (mp4 0.14 hardcodes length_size_minus_one=3), SPS/PPS/AUD/SEI stripped out of the sample bytes, is_sync taken from an actual NAL type 5 rather than GOP arithmetic. Mp4Muxer::create wants the parameter sets up front, so mux::parameter_sets pulls them out of a buffered first access unit before the muxer exists. Timescales are 90000 video / sample_rate audio / 1000 movie, per-frame duration (90000/fps).round(), and mp4 0.14 ignores Mp4Sample::start_time on write -- timing is duration accumulation only. An SPS shorter than 4 bytes panics inside the crate (avc1.rs indexes sps[1..3]), so create rejects that and the other degenerate shapes up front instead. Audio is copied, not re-encoded: there is no pure-Rust AAC encoder and mp4 0.14 has no PCM MediaConfig, so the only honest option is to hand the source packets back through verbatim. AudioSession::copy_segments does that -- stts walk to packet ids, no decode, bytes straight from read_sample. Cut points do not land on 1024-sample boundaries (23.2 ms packets vs 33.3 ms frames), so a bresenham accumulator picks the packet run per segment and keeps the cumulative A/V offset under 512 samples, proven by induction over the carry and measured over 200 random join lists. The first segment starts one packet early to feed the 1024-sample priming drop; interior segments do not, because an extra head packet there is 23 ms of pre-cut audio at every join and it would not fix the missing MDCT predecessor anyway. That artifact is documented at the seam.
✨ feat(engine): clips primitives — edit-list model, bounded decode, segmented audioAhmet Kaan Gümüş · e75a7ba
✨ feat(engine): clips primitives — edit-list model, bounded decode, segmented audio Lane 1 of the clips slice; PlaybackSession traversal comes next. - project.rs: Clip/Project — cut (metadata-only, refuses no-op splits), delete (closes gap, keeps ≥1 clip), undo snapshots, timeline↔source mapping with boundary sweep tests - decode: open_range(start, end) — both backends stop after end-1, empty/inverted ranges disconnect cleanly without spawning a worker - audio: open_segments — one worker walks the edit list; segments bit-exact vs equivalent seeks, joins gapless by contiguity assert, head+tail trim inside a single AAC packet handled
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_atAhmet Kaan Gümüş · 96ae365
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_at Lane 1 of the seek slice; PlaybackSession orchestration comes next. - demux/decode: stss sync lookup, DecodeSession::open_at decodes from the keyframe and discards to the target; Frame.index stays absolute. HW plugin ABI: vh_open renamed vh_open_at(path, target) — discards skip the vaGetImage readback; measured seek cost 65ms HW / 222ms SW - engine-audio: ao_flush drains the ring consumer-side in the RT callback (one-shot atomic), stale PCM unplayable even when paused; played-position atomics untouched so clock math survives - audio: open_at walks stts, 2-packet AAC pre-roll (MDCT overlap reconstructed exactly — verified 0-diff before the first PNS band), sample-exact trim; priming skip and seek discard unified. AAC seek is deliberately not bit-exact: symphonia's PNS noise LCG state depends on packet history; bounded <1e-3 by test instead
✨ feat(engine): audio decode, PipeWire output plugin, playback clockAhmet Kaan Gümüş · 229a569
✨ feat(engine): audio decode, PipeWire output plugin, playback clock Wave 1 of the audio slice — three independent modules, app wiring comes next: - audio.rs: AAC-LC via standalone symphonia AacDecoder over the existing mp4 demuxer; priming trim read from the container elst (verified against ffprobe); channel identity pinned by zero-crossing tests on the 440/880 Hz fixture - engine-audio: dlopen'd PipeWire cdylib (ao_* C ABI). App binary keeps zero libpipewire linkage; daemon absent fails open() in ~1ms. Fill capped at 1024 frames/callback: uncapped, PipeWire hands the sink-sized buffer and the position clock steps 256ms at a time. Stream time rate is 1/48000 regardless of stream rate — position is rescaled or the clock runs 8.8% fast on 44.1k content - clock.rs: PlaybackClock, audio-driven with wall fallback; audio positions relative to last re-anchor so restarted streams re-sync; paused == frozen exactly, all re-anchoring through one path