Skip to content

fix(studio): re-analyse audio on every scenario load, and report failures - #181

Merged
LeadcodeDev merged 1 commit into
mainfrom
fix/studio-audio-analysis
Aug 12, 2026
Merged

fix(studio): re-analyse audio on every scenario load, and report failures#181
LeadcodeDev merged 1 commit into
mainfrom
fix/studio-audio-analysis

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

What

The studio analysed audio tracks exactly once, in run_preview_root. Every later load path — the file watcher, opening a scenario from the library, undo — replaced the model without touching the analysis.

So a scenario that gained a track, or whose track path was corrected, kept the previous (or no) analysis for the whole session. waveform and audio_spectrum then drew their flat fallback with nothing to explain it, because analyze_scenario_audio turned a failed decode into a bare continue.

Found while building a showcase scenario: the preview showed a flat line while the rendered mp4 showed the real envelope, and nothing in either output said why.

How

  • Move the call into StudioModel::new, the constructor every load path already funnels through.
  • analyze_scenario_audio returns the tracks it could not analyse instead of swallowing them. The encoders print a warning; the studio shows them in the topbar next to the write-error indicator.
  • The cache is keyed by path alone (the painters look tracks up that way), so record what each entry was computed from — file length, mtime, fps — and re-analyse when that changes. Re-exporting a mix under the same name while the studio was open used to keep serving the first envelope.

Tests

Two added in audio_tests:

  • an undecodable track is reported and leaves no cache entry
  • rewriting the same path re-analyses instead of serving the stale envelope

cargo test --workspace green, cargo fmt, cargo clippy --all-targets clean.

…ures

The studio analysed audio tracks exactly once, in run_preview_root. Every
later load path — the file watcher, opening a scenario from the library,
undo — replaced the model without touching the analysis, so a scenario that
gained a track, or whose track path was corrected, kept the previous (or no)
analysis for the whole session. waveform and audio_spectrum then drew their
flat fallback with nothing to explain it, because analyze_scenario_audio
turned a failed decode into a bare `continue`.

Move the call into StudioModel::new, the constructor every load path already
funnels through, and return the tracks that could not be analysed instead of
swallowing them. The encoders print them as a warning; the studio shows them
in the topbar next to the write-error indicator.

The cache is keyed by path alone (the painters look tracks up that way), so
also record what each entry was computed from — file length, mtime, fps — and
re-analyse when that changes. Re-exporting a mix under the same name while
the studio is open used to keep serving the first envelope.
@LeadcodeDev
LeadcodeDev merged commit da98916 into main Aug 12, 2026
3 checks passed
@LeadcodeDev
LeadcodeDev deleted the fix/studio-audio-analysis branch August 12, 2026 11:56
LeadcodeDev added a commit that referenced this pull request Aug 12, 2026
#195)

A gif component showed its first frame and then nothing — no error, no
warning, scenario valid, render successful.

Every frame after the first is usually a sub-rectangle holding only the pixels
that changed. The decoder stored frame.buffer alongside the *canvas*
dimensions, so the buffer was shorter than width * height * 4;
raster_from_data returned None and the `if let Some(img)` arm was skipped. The
first frame is full-canvas in most encoders, which is why it was the only one
that ever appeared.

Compose each frame onto a persistent canvas at (left, top), honouring alpha 0
as "leave what is underneath" and the disposal method (Background clears the
frame's rect, Previous restores the canvas, Keep/Any leave it). Even at the
right size, drawing an optimised frame alone would have shown a fragment on an
empty background.

The three silent exits now report once per source, the way #181 made the audio
analysis report. AlphaType is Unpremul: the decoder emits straight RGBA.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant