forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on cc667e6819d96fdfa32fc2debfcf76352e10da4cFiltered to crates/engine/src/audio.rsClear filter

2026-08-11

🩹 fix(audio): an mkv's stream 0 is the track it already played, not its firstAhmet Kaan Gümüş · a7dd4c5
🩹 fix(audio): an mkv's stream 0 is the track it already played, not its first

A remux flags the language it wants heard with FlagDefault on whichever
track it likes -- mkvmerge writes it on the second one all the time --
and every reader here picked with that flag. Numbering the streams by
file position outright made stream 0 a different track on those files,
so an .edith project saved before the listing existed would quietly
start playing the other language.

mkv_stream_order puts the track the file already plays first and the
rest behind it in file order, and it does not re-derive the old pick, it
runs it: the AC-3 arm asks MkvAc3Track the same question Track::open
asked it, everything else asks symphonia for its default track.
probe_streams, Track::open and therefore the library's rows all count in
that one order.

Tested on a byte-patched fixture -- ffmpeg writes FlagDefault only to
say 0, so the one byte behind the French track's language is flipped to
1 -- and it fails on file-order numbering: eng leads instead of fra.
✨ feat(audio): every audio track of an mkv is a row, and the second one playsAhmet Kaan Gümüş · 264c10c
✨ feat(audio): every audio track of an mkv is a row, and the second one plays

A Matroska file was worth exactly one audio stream here -- whichever
track the readers stumbled on first -- so the second language of a
dual-audio remux was invisible and unopenable, and no mkv ever showed
what language its sound was in.

The header walk now collects every audio TrackEntry in file order with
its number, codec id, TrackLanguage and TrackName
(demux::matroska_audio_tracks), and that list is what a stream index
counts in. The index picks an entry, the entry's *track number* is what
each reader is then pointed at -- MkvAudio::open_track for the AC-3
blocks, SymTrack::open_track for symphonia, whose mkv reader keeps the
same number as its track id -- so the two readers cannot disagree about
which track a stream meant. Stream 0 is still the file's first audio
track, sample for sample.

Rows name their codec from the container rather than from symphonia's
registry: the tracks that most need naming are exactly the ones it has
no decoder for, and "opus is not supported" beats "an unsupported
format".

Fixture: test_multiaudio.mkv, two AAC tracks, eng 440/880 Hz and fra
220/330 Hz -- different tones because a mapping that drifts plays the
other language.
✨ feat(export): OGG Vorbis is a row you can pick, not a note about missing encodersAhmet Kaan Gümüş · 17d7d99
✨ feat(export): OGG Vorbis is a row you can pick, not a note about missing encoders

The export card said "no pure-Rust Vorbis or Opus encoder" and that had stopped
being true. `rusty_vorbis` 0.1.1 (Apache-2.0, zero dependencies, same family as
the h264/aac/mp3 encoders already here) is the first permissively-licensed
pure-Rust Vorbis *encoder*; `oxideav-ogg` 0.1.8 pages it, and its only dependency
is the `oxideav-core` the AC-3 decoder already pulls in. No C, no FFI, no new
runtime system dependency -- `ldd` on the binary is unchanged, name for name.

The row is live, keyed `o`, and names its encoder like every other live row does.
VP9 stays refused with the reason it always had: AV1 replaces it.

What the bench found, and what the code does about it. Every number below was
measured by encoding this suite's own fixtures and decoding them back with
symphonia -- an independent decoder, and the one this engine reopens exports
with:

* The encoder numbers its granules a full block ahead of the samples it codes,
  so written straight through, every sample lands ~1024 early: a marker signal
  came back with its head at 36% amplitude and a full-scale burst 1500 samples
  before the real one, in silence. One hop of silent pre-roll puts it back --
  head 0.86 against an input peak of 0.80, the phantom burst down to 0.04.
* Its block grid overshoots the last sample, so the stream is padded and the
  last page's granule declares the timeline's own frame count. An `.ogg` is now
  exactly as long as the WAV of the same timeline, which is the promise every
  other audio row here keeps.
* Below quality 0.50 the encoder is *quiet*, not merely coarse (1-1.6 dB of
  level error, near-silence at 0.10), and the whole usable band tops out around
  200 kbps. So the file is written at one measured quality, 0.85, and the Sound
  row is refused by name rather than mapping 128/192/256/320 onto quality steps:
  the top two are rates this encoder cannot reach, and a card that printed them
  would be lying.
* The embedded setup header is a stereo profile -- a mono push is refused
  outright -- so a mono mix is written as dual mono, both channels bit-identical.

And one defect the round trip turned up on the way in: `SymTrack` subtracted
`Track::delay` on top of symphonia, which already drops those frames itself.
Every `.mp3` import was losing its first 1105 samples (25 ms) and reading 25 ms
short, every `.ogg` its first 128. Measured against `test_tone.flac` -- lossless,
and the only one of the three declaring no delay -- which the mp3 and the ogg of
the same tone now align with. WAV, FLAC and AAC-in-mp4 read hash-identical
across the change; only those two formats move, and both move to the length
their own container declares.
✨ feat(engine): an edit rebuilds what it dirtied, and nothing elseAhmet Kaan Gümüş · c2e62a3
✨ feat(engine): an edit rebuilds what it dirtied, and nothing else

Every param change went through one funnel -- edit() -> seek() -- which
flushed the audio ring, reopened every track, respawned the feeder and
rebuilt the video decoder. Dragging a colour slider therefore cut the
sound ~40 times across one gesture, and every restart re-anchored the
clock onto an empty ring, so the silence of the restart was counted as
timeline time: a permanent A/V offset, re-rolled by every edit made
while playing (the resolution-change desync).

Edits are classified by what they dirty now. A grade, a fit policy and
the project resolution rebuild the picture where it stands and never
touch a sample. An equalizer rebuilds the sound and never touches the
picture. A fader and the master ceiling rebuild nothing at all: they
live at the mix sum, so the running mixer picks them up between two
blocks (MixControls), and the limiter is retuned rather than restarted
so its delay line -- and the sample count the master clock is made of --
keeps running. Only a structural edit still reseeks both halves.

And a restart no longer costs an offset: the feeder stamps the device
position its first real sample was queued at, and the clock anchors
there instead of on the first poll after the seek, so the silence before
the content is never timeline time.

Also: a span whose source will not open no longer presents the old
channel's frames under the new mapping, and the feeder stops parking
10 ms on a ring that is merely waiting out a flush.
🐛 fix(audio): a broken Matroska track is an error, not silenceAhmet Kaan Gümüş · 941e882
🐛 fix(audio): a broken Matroska track is an error, not silence

Two verifier findings, both in the same class as A5's silent-take work:
a hole nobody asked for must not be indistinguishable from a hole the
timeline means.

Track::open's mkv arm turned every symphonia failure into Ok(None) --
silence -- with an eprintln as the only trace, so a file whose audio is
broken played and exported as a quiet stretch and said nothing. Now
SymTrack::open returns Ok(None) for the one honest case (the container
opened and holds no audio track) and Err for the rest; a codec nothing
here decodes is still silent, since that is what the decoder, not the
open, reports. probe_streams follows the same split, and a standalone
audio file keeps its old answer through open_required.

lanes.rs: three_lane_file() handed both of its tests one pid-keyed path,
so whichever finished first deleted the file the other was still using.
The name is the caller's now.
🔀 merge(A5): main (b10235a) into the import-policy branchAhmet Kaan Gümüş · 685d4e6
🔀 merge(A5): main (b10235a) into the import-policy branch

Clean: A1's Track::open rework routes codecs (MkvAc3Track before symphonia)
and A5 handles absent tracks -- the two compose, and git merged them
without touching either. C1's main.rs churn moved the refusal test's
neighbourhood, not the test.
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211cAhmet Kaan Gümüş · 0776b46
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211c

# Conflicts:
#	crates/engine/src/audio.rs
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211cAhmet Kaan Gümüş · 1e8c454
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211c

# Conflicts:
#	crates/engine/src/audio.rs
#	crates/engine/src/demux.rs
#	crates/engine/tests/audio_decode.rs
#	scripts/gen_fixtures.sh
🔀 merge(A5): main (dfd4ffe) into the import-policy branchAhmet Kaan Gümüş · cbb0f62
🔀 merge(A5): main (dfd4ffe) into the import-policy branch

No conflicts: A6's waveform/demux work and the subtitle lane do not touch
the import gate.
🔀 merge(A5): main (de15818) into the import-policy branchAhmet Kaan Gümüş · d17f345
🔀 merge(A5): main (de15818) into the import-policy branch

The rate gate main landed (`Rate`) and this branch's codec gate removal
are the same function: `matches_timeline` keeps main's `Rate` return and
loses the codec equality, with the decoder probe in its place. The
refusal tests that named a rate or a silence now name the one thing
left -- one output device, one rate and one layout.
✨ fix(waveform): a film in an mkv paints its wave, and a failure says soAhmet Kaan Gümüş · ffb3105
✨ fix(waveform): a film in an mkv paints its wave, and a failure says so

A 5.1 AAC track decodes through rusty_aac, whose IMDCT ran as an 8 MB
cosine matrix -- 88% of decode time and 2x realtime, so a two-hour film
needed an hour of background decode before its lane had anything to
draw. The same file has an N/4-point FFT already, for the encoder: the
IMDCT is a DCT-IV read at an offset, so both directions now share
dsp::dct4. 40x on the fixture, 141 s for the film.

And a decode that fails is no longer a silent file: peaks() errors reach
the lane as Wave::Failed with a band that says "audio unreadable", the
reason goes to the log, and the Matroska opener logs what it swallows.
✨ feat(audio): AC-3 and E-AC-3 sound out of a Matroska fileAhmet Kaan Gümüş · a71f015
✨ feat(audio): AC-3 and E-AC-3 sound out of a Matroska file

The "(AAC only)" refusal fired on every A_AC3/A_EAC3 track in an mkv
because a Matroska file's sound reached no reader at all. The blocks of
its first audio track are now indexed beside the picture's and handed to
the oxideav-ac3 decoder the mp4 path already uses, downmix and all.
✨ feat(import): mixed codecs and silent takes join the timelineAhmet Kaan Gümüş · 9bc3bd4
✨ feat(import): mixed codecs and silent takes join the timeline

The two refusals a user hits for no reason are gone: a file coded
differently opens its own decoder like every clip already does, and a
file with no audio track contributes silence over its span like a gap
already does.

What the codec gate was really protecting against stays, moved to the
one place that can answer it: import asks the file for a decoder, so a
machine without the VA-API plugin refuses an HEVC take by the decoder's
own name rather than playing black frames with the complaint on stderr.
Rate and layout stay refused -- there is no resampler.

Both audio paths now read a source with no track as the silence they
already synthesise for a hole: the worker plays it, the packet copy
writes it, so an mp4 export of a timeline with a silent take is as long
as the timeline and quiet where the take is.
✨ feat(mix): every track has its own volume and the mix has a ceilingAhmet Kaan Gümüş · dc7d07d
✨ feat(mix): every track has its own volume and the mix has a ceiling

A fader per audio track and one master limiter over the sum of them, both
applied where the lanes are added and nowhere else -- so what an export
writes is what the room heard, by construction rather than by two call
sites agreeing.

A track's fader moves everything on it, every frequency: it is not the
equalizer (one take, one band) and not the panel's volume (this machine's
monitoring, which no file carries). The limiter is lookahead, soft-knee
and per sample: the peak of an exported file is a measurement, not a hope,
and the hard clamp stays behind it as the backstop.

Flat settings are still the bit-exact passthrough: one lane at unity with
the limiter off never opens a mixer thread, and an mp4 of such a timeline
is still a packet copy. A mixed one re-encodes, and the card says so
before the export starts.

Both belong to the project, so `.edith` is v9: `fps`, `limiter` and `gain`
lines, every older dialect still loading flat. The rate line pays an old
debt with it -- a timeline of nothing but stills and songs now comes back
at the rate it was cut at instead of the one its scaffold implied.

UI: the mix card (f, or an audio track's own header), rows with steppers
and hold-to-run arrows, and the track's level on its header.
✨ feat(export): every video format carries sound, AV1 picks its box, MP3 is a rowAhmet Kaan Gümüş · 5ebd3ac
✨ feat(export): every video format carries sound, AV1 picks its box, MP3 is a row

Three asks, one seam — the export's audio path was a packet copy, and everything
it could not copy was a refusal.

- MkvMuxer gains an A_AAC track (CodecPrivate = AudioSpecificConfig, CodecDelay
  one packet) and interleaves it into the clusters: an AV1 export carries the
  timeline's sound instead of naming it as left out.
- Mp4Muxer::create_av1 writes AV1 into an mp4 — the `av01` + `av1C` sample entry
  `mp4 0.14` cannot spell is patched into the finished moov (layout cribbed from
  OxideAV's oxideav-mp4, MIT); Mp4Demuxer reads that entry back.
- Format::Mp3 through `rusty_mp3` at 256 kbps CBR, and Format::Av1Mp4 beside
  Format::Av1: the export card has a row and a key for each.
- copy_audio lifts every "cannot copy" refusal into a route to encode_audio —
  a second audio lane, a speeded clip, a Matroska source, an mp3 or a png
  timeline. A copy nothing forces stays a bit-exact copy.

Round trips per container, through this project's own readers: mkv + mp4 AV1
with a tone (mux unit tests), an AV1 export in either box (tests/av1.rs), a
still under a song as an mp4 with sound and an MP3 of the timeline
(tests/audio_export.rs), two lanes summed into an mp4 (tests/lanes.rs), a
speeded lane resampled into one (tests/speed.rs).

2026-08-10

🔀 merge(T1): mkv HEVC + 5.1 AAC import meets the EQ exportAhmet Kaan Gümüş · 1dc163e
🔀 merge(T1): mkv HEVC + 5.1 AAC import meets the EQ export

One rusty_aac, not two: the branch's vendored 0.5.0 (patched IMDCT) is what the
workspace patch table points every dependant at, so T5's encoder and this
branch's decoder are the same crate. The auto-merge had left two identical
`rusty_aac` keys in the engine manifest, which is a duplicate-key error -- one
entry now, its comment naming both halves.

The three prose conflicts were all one shape: this branch wrote 'no AAC encoder
is wired here' while T5 was busy wiring one. T5's wording wins in each. Where
main's Av1 doc said this engine's reader 'refuses Matroska audio' the claim is
now false the other way round, so that sentence keeps main's writer half and
takes this branch's reader half.
✨ feat(import): a Matroska film opens, its 10-bit picture and its 5.1 sound alikeAhmet Kaan Gümüş · b083a3b
✨ feat(import): a Matroska film opens, its 10-bit picture and its 5.1 sound alike

mkv HEVC demux (Main/Main10), a P010 pool in the hardware path read back to
I420, mkv audio through symphonia's Matroska reader with rusty_aac decoding
what symphonia's own AAC refuses (anything wider than stereo), and a BS.775
fold of 5.1 down to the stereo the output device takes.

vendor/rusty_aac is 0.5.0 with one local patch: its decoder's IMDCT caches the
cosine matrix instead of calling cos() per term, 11x faster and the difference
between playable and not.
🔀 merge(T6): the last media leaves, and nothing assumes source 0 stayedAhmet Kaan Gümüş · 7e4ead7
🔀 merge(T6): the last media leaves, and nothing assumes source 0 stayed

Both sides kept: the library-removal slice (a project may name no file, the
audio reference is never a still, the clipboard follows its file down the
list, a silence edit drops the selection) and main's EQ audio export, image
left-trim, track removal, volume slider, hold-repeat and EQ spectrum.

The one textual conflict was the test import list; close_session now also
drops the gestures and caches those slices added.
✨ feat(timeline): clips play at a speed of their ownAhmet Kaan Gümüş · f8effe8
✨ feat(timeline): clips play at a speed of their own

A clip gains a rate (`Speed`, thousandths of real time, 0.25x to 4x) and
every speed question is answered at the mapping seams that were already
there: `Clip::frames` is the source range divided by the rate, `end` is
built on it, and `map`/`span_at`/`composite_span_at` walk the offset
through `Speed::source_at`. `in_frame`/`out_frame` stay *source* frames,
so a trim and a split still address the file.

The picture needs no new decoder: the span says how many source frames it
reads, and `try_frame` brings the decoder's numbers back through the same
rate -- at 2x two decoded frames land on one timeline frame and the
display's drop-when-behind policy takes it from there. The sound is
resampled per segment inside the worker playback and the audio export
already share (linear interpolation, carried across packet seams), so the
pitch moves with the rate: tape, not pitch-preserve, and the card says so.
Each segment is told how much timeline it owes and pads or trims to it,
which is what keeps a run of speeded cuts from drifting.

Rounding is where a rate could break the lane, so it does not: `Speed::fit`
never hands a trim more source than its room holds, and `Speed::split_at`
refuses a cut a slow clip's rate cannot address rather than leaving two
halves that no longer add up. The fuzz sweeps set_speed in with the rest.

- card in the eq/colour pattern, on `j` and in the clip menu; a drag is one
  undo step for the whole linked group, 1.00x reachable by hand and by `r`
- clip boxes carry a "2.00x" mark, and their width, waveform and details
  row are the timeline length
- WAV/FLAC honour it; mp4 and AV1 *refuse* by name -- that path copies AAC
  packets and a resample is not a copy (ponytail names the upgrade path)
- .edith v8 carries the rate; v7 and older load at 1.00x
- `assets/test_speed_sync.mp4`: one flash, one beep, same instant. At 2x
  they still land together, to the frame.
✨ 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