mirror of
https://github.com/storytold/soundcraft.git
synced 2026-11-21 20:39:52 +00:00
Import external-WAV AAF as editable session data (pure Rust) (#799)
* Import external-WAV AAF as editable session data File > Import > Session Data analyzes an AAF and imports the selected audio tracks as new tracks, one clip per edit. Clips keep their offset into the complete source, so handles stay available; the import is one undo step and Save collects the full sources. crates/interchange (layer 3, no filesystem/process/UI access): - build_session(Plan): versioned rational-time plan -> Session. Endpoints are rounded to samples independently, so adjacent edits never drift. - aaf::read_aaf: reads the AAF object model from structured storage with the cfb crate (MIT): properties streams, strong reference vectors/sets and dictionary weak references. Media goes through a MediaResolver trait. crates/engine: file.preview_aaf (read-only) and file.import_aaf (undoable). The resolver opens only files named in the chosen media folder, checks file_access and reads WAV headers without loading samples; import re-probes and decodes before touching the session. crates/ui-egui: Session Data window with track selection, media folder, absolute/relative mapping, sample offset and report. Supported: SourceClip/Filler sequences resolved through MasterMobs to WAVEDescriptor SourceMobs with one external locator; mono/stereo PCM WAV; composition timecode including 24000/1001 and drop-frame. Gain, fades, transitions, selectors, nested sequences, embedded essence, split channels, mixed sample rates and non-local locators fail explicitly. Addresses #40. * AAF import: resolve each source once, offer composition choice, start folder picker - file_source returns early for a known source, so each WAV is probed and each relink is reported once however many edits use it. The per-slot PhysicalTrackNumber check still runs first. - When an AAF holds several compositions, the Session Data window lists them and passes the chosen MobID to file.preview_aaf. - "Choose media folder..." opens at the current media folder instead of receiving a label as its start path. * AAF import: lock the composition selector while analysis runs A selection change during analysis could leave a plan for the previous composition in the window and enable Import with it. * AAF import: drop a running analysis when the file or media folder changes window.import_aaf (and opening an .aaf) can set a new path while the previous file is still being analyzed; its late plan could then be shown and imported for the new path. * AAF import: forget the chosen composition when the path is edited * AAF import: keep the media folder with a typed AAF path A typed path now moves a media folder that was derived from the previous AAF, so same-named WAVs are not taken from the old folder. A folder the user chose elsewhere is kept. * AAF import: bound hostile input, confine locators, report missing media Review follow-up for the AAF reader (untrusted input): - Cap the structured-storage directory at MAX_DIRECTORY_ENTRIES on open; document every bound (sector chains via cfb, 32 MiB streams, MAX_ITEMS collections, 32-link source chains with cycle detection). - Locators are data: refuse `..` anywhere (also percent-encoded and inside absolute paths), NUL bytes, paths that name no file, and relative locators with a root or drive prefix; relative ones stay under the AAF's folder. - A missing media file no longer aborts the import: it is reported with the number of edits skipped, the other edits keep their positions, and the import fails only when no referenced file exists. - Tests: looped directory, mini-FAT and mini-stream chains terminate with an error; locators patched into the fixture cannot leave the AAF folder; an absolute locator is only looked up in the chosen media folder; missing media is reported per file. - Provenance statement in the module docs and README. * AAF import: confine the plan's media to the media folder at import too file.import_aaf takes the plan from its caller (UI, MCP, automation), so the media-folder rule applied while analysing is checked again before any source is read: the import requires `media_dir`, and every source must be a file directly inside it once both paths are canonical (symlinks resolved). The UI passes the folder it analysed with. Test: a plan edited to point outside the folder (absolute path, `..` traversal, symlink) or without `media_dir` is refused without an edit. * AAF reader: decode UTF-16 with as_chunks for clippy 1.99 clippy::chunks_exact_to_as_chunks (Rust 1.99, used by the gate) rejects chunks_exact(2) with a constant size. as_chunks is stable since 1.88, below the workspace minimum. * AAF reader: state its provenance accurately The storage layout, class and property identifiers and MobID text form were learned by reading pyaaf2 (MIT), not from the published AAF specifications. No pyaaf2, AAF SDK or copyleft code was copied. * aaf: bound property expansion Cache parsed objects and share property payloads. Enforce a 128 MiB aggregate property budget and reject duplicate local references before expansion, with a compact AAF regression. Migrate AAF media handling to craft-audio after integrating current main. * docs: record strict AAF import support
This commit is contained in:
Generated
+25
@@ -850,6 +850,17 @@ dependencies = [
|
||||
"nom 7.1.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfb"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f13298d9178622b7916ec5d01d470425c04273c8ed07e87b1c38b34c4f4612b"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"uuid",
|
||||
"web-time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.5"
|
||||
@@ -4994,6 +5005,7 @@ dependencies = [
|
||||
name = "soundcraft-engine"
|
||||
version = "0.20.1"
|
||||
dependencies = [
|
||||
"cfb",
|
||||
"craft-audio",
|
||||
"craft-docpath",
|
||||
"craft-score",
|
||||
@@ -5006,6 +5018,7 @@ dependencies = [
|
||||
"soundcraft-au-host",
|
||||
"soundcraft-clap-host",
|
||||
"soundcraft-dsp",
|
||||
"soundcraft-interchange",
|
||||
"soundcraft-midi",
|
||||
"soundcraft-mix",
|
||||
"soundcraft-model",
|
||||
@@ -5017,6 +5030,18 @@ dependencies = [
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "soundcraft-interchange"
|
||||
version = "0.20.1"
|
||||
dependencies = [
|
||||
"cfb",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"soundcraft-model",
|
||||
"soundcraft-time",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "soundcraft-midi"
|
||||
version = "0.20.1"
|
||||
|
||||
@@ -15,6 +15,7 @@ craft-score = { git = "https://github.com/storytold/craft-libs", rev = "3a1a627d
|
||||
craft-xml = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "ea24422ae9859dc5da398d0462bc87f8e02e0d10" }
|
||||
craft-mime = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "ea24422ae9859dc5da398d0462bc87f8e02e0d10" }
|
||||
# internal
|
||||
soundcraft-interchange = { path = "crates/interchange" }
|
||||
soundcraft-time = { path = "crates/time" }
|
||||
soundcraft-midi = { path = "crates/midi" }
|
||||
soundcraft-video = { path = "crates/video" }
|
||||
@@ -46,6 +47,8 @@ proptest = "1"
|
||||
|
||||
# audio
|
||||
rustfft = "6"
|
||||
# AAF interchange: Compound File Binary (structured storage) container reader.
|
||||
cfb = "0.15"
|
||||
# Session bundles (one file holding a session and its audio, for the browser): stored entries only.
|
||||
zip = { version = "9", default-features = false }
|
||||
cpal = "0.18"
|
||||
|
||||
+6
-4
@@ -2,7 +2,7 @@
|
||||
|
||||
**Stage: pre-alpha** · next: alpha, ~5% and ~110–180 h away (the alpha gate's three failing workflows)
|
||||
|
||||
> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-18 · **Change:** minor (MIDI input in the progress log; previously trivial: Frequency Shifter plugin, Command-click target priority and cursor, Command-click automation points, plugin editors on Linux/X11, Cancel Zoom Toggle, side panels in dock columns, Auto Pan stereo balance, Alt-click returns a plugin parameter to its default, Clip List Auto Rename, Strip Silence rectangles, Strip Silence Rename, Strip Silence Extract and Separate, Clip Looping dialog, AudioSuite Vari-Fi speed ramps, Auto Pan plugin, Subharmonic plugin, Ring Modulator plugin, Float32 file headroom) · **Target:** Avid Pro Tools Ultimate 2026.4.1
|
||||
> **Last reviewed:** 2026-11-14 · **Last updated:** 2026-11-18 · **Change:** minor (strict external-WAV AAF import and MIDI input in the progress log; previously trivial: Frequency Shifter plugin, Command-click target priority and cursor, Command-click automation points, plugin editors on Linux/X11, Cancel Zoom Toggle, side panels in dock columns, Auto Pan stereo balance, Alt-click returns a plugin parameter to its default, Clip List Auto Rename, Strip Silence rectangles, Strip Silence Rename, Strip Silence Extract and Separate, Clip Looping dialog, AudioSuite Vari-Fi speed ramps, Auto Pan plugin, Subharmonic plugin, Ring Modulator plugin, Float32 file headroom) · **Target:** Avid Pro Tools Ultimate 2026.4.1
|
||||
|
||||
SoundCraft is a clean-room, pure-Rust digital audio workstation that aims at full parity with
|
||||
Avid Pro Tools, and then beyond it: faster, open, scriptable and agent-controllable. This page is
|
||||
@@ -38,8 +38,8 @@ Editing, mixing, bouncing, and saving and reopening work end to end. But a Pro T
|
||||
record from a chosen audio interface at a chosen buffer size (only the default devices, a fixed
|
||||
512-sample block, and takes held in RAM). Recording MIDI from a keyboard is built but checked on
|
||||
Linux only: macOS and Windows are type-checked and have not been tried with a device, and there
|
||||
is no MIDI input on FreeBSD or the web. And they can't bring a session in or hand one back (no
|
||||
AAF/OMF/`.ptx`).
|
||||
is no MIDI input on FreeBSD or the web. Session interchange is still incomplete: a strict
|
||||
external-WAV AAF import subset works, but AAF export, OMF and `.ptx` do not.
|
||||
Readiness (~40 %) sits right at the alpha bar, but a gate failure keeps the app pre-alpha. The
|
||||
2026-10-07 estimate ("~65 % overall, 110–150 h to 100 %") counted feature presence. This one
|
||||
measures readiness and adds hardware, localization and field bug reports.
|
||||
@@ -106,7 +106,7 @@ Ranked; the alpha gate, the alpha checklist and the beta plan are in [docs/roadm
|
||||
|
||||
1. **Alpha blocker:** audio interfaces: device and buffer-size choice, duplex stream, ASIO; record to disk (G-01, G-06). 35–55 h.
|
||||
2. **Alpha blocker:** MIDI devices: keyboard input, live play and recording are in (checked on Linux only; macOS and Windows type-checked, none on FreeBSD or the web); output, clock and loop/merge recording remain (G-02). 12–22 h.
|
||||
3. **Alpha blocker:** AAF/OMF import and export (G-03). 50–90 h.
|
||||
3. **Alpha blocker:** complete AAF/OMF interchange (G-03): strict external-WAV AAF import works; AAF export and OMF import/export remain. 50–90 h.
|
||||
4. macOS plugin entitlement (#153), then AU editors and embedded CLAP editors on macOS (G-05). 1 h for the entitlement (needed for the mix row), then 10–15 h.
|
||||
5. Land the open bug-fix PRs and clear the correctness backlog (G-04). 15–25 h.
|
||||
6. PR CI running `cargo xtask ci` on three OSes (G-14). 5–10 h.
|
||||
@@ -125,6 +125,7 @@ mutated and truncated movies. Field reports from the first public week are track
|
||||
## Progress log
|
||||
|
||||
- **2026-11-18 (MIDI input):** MIDI input devices: keyboards play record-enabled and input-monitored MIDI and instrument tracks live and are recorded into MIDI clips, with a device and channel choice per track. The device switches are in the MIDI inputs section of Setup › Playback Engine (Setup › MIDI › MIDI Input Devices opens the same window) and are kept in the app preferences, per computer, not in the session. Controllers, pitch bend and aftertouch reach the instrument live; a pitch held on two devices or channels sounds until both release it; a full input queue releases the notes of its device and marks the take incomplete. On Linux, live play was checked with a hardware keyboard (Akai MPK mini 3) and recording with a virtual one; macOS and Windows are type-checked only, and there is no MIDI input on FreeBSD or the web. Guide: `docs/midi-input.md`. No readiness percentage change until that is measured.
|
||||
- **2026-11-14:** AAF import supports a strict CompositionMob SourceClip/Filler subset with external mono/stereo PCM WAV media, editable clips and handles, relink and absolute or relative timecode mapping. The reader shares cached object properties, caps retained property data at 128 MiB and rejects duplicate local references before expansion. AAF export, OMF and `.ptx` remain missing. No readiness percentage change.
|
||||
- **2026-11-09:** A built-in Frequency Shifter (`freq_shifter`) moves every frequency in the signal by the same number of hertz, from 0.01 Hz to 5 kHz: up, down, both ways at once, or down on the left and up on the right of a stereo track. The unwanted sideband stays at least 100 dB down from 20 Hz to 20 Hz below Nyquist at 44.1 to 96 kHz. Feedback sends the output round again for a trail of further shifts, Mix blends in the dry signal, and every change glides without a click. No readiness percentage change.
|
||||
- **2026-11-08:** Command-click near an existing automation breakpoint keeps that point as the click target with every active tool, and existing fade and clip-gain controls retain their normal priority. Empty automation space shows a crosshair and an insertion hint while Command is held. The active tool's drag gestures stay unchanged. No readiness percentage change.
|
||||
- **2026-11-05:** Command-click in an automation lane adds a point at the clicked time and value with the current editing tool (#1394), using the existing Pencil mapping. Command-click preserves the existing selection and also works on the fallback volume lanes of Master, Aux and VCA tracks. Plain clicks and clip contents stay unchanged, and one Undo removes the new point. No readiness percentage change.
|
||||
@@ -187,6 +188,7 @@ mutated and truncated movies. Field reports from the first public week are track
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-14 | minor | Strict external-WAV AAF import with bounded property caching; remaining interchange work and readiness estimates unchanged |
|
||||
| 2026-11-09 | trivial | Progress log: Frequency Shifter plugin; readiness estimates unchanged |
|
||||
| 2026-11-08 | trivial | Command-click breakpoint/control priority and insertion affordance; active-tool drags retained; readiness estimates unchanged |
|
||||
| 2026-11-05 | trivial | Progress log: Command-click adds an undoable automation point (#1394); readiness estimates unchanged |
|
||||
|
||||
@@ -151,6 +151,7 @@ fn services() -> Services {
|
||||
let d = rfd::FileDialog::new();
|
||||
let d = match purpose {
|
||||
"session.open" => d.add_filter("SoundCraft Session", &["scraft"]),
|
||||
"file.import_aaf" => d.add_filter("AAF session data", &["aaf"]),
|
||||
"file.import_midi" => d.add_filter("MIDI", &["mid", "midi", "smf"]),
|
||||
_ => d.add_filter("Audio", craft_audio::DECODE_EXTENSIONS),
|
||||
};
|
||||
|
||||
@@ -69,3 +69,7 @@ sync_github_name = true
|
||||
[people.kk376]
|
||||
real_name = "Kushagra Kumar"
|
||||
sync_github_name = true
|
||||
|
||||
# Display name explicitly chosen by the contributor on 2026-10-19.
|
||||
[people.vhhr7]
|
||||
display_name = "Vic Herrera (@vhhr)"
|
||||
|
||||
@@ -8,6 +8,7 @@ rust-version.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
soundcraft-interchange.workspace = true
|
||||
craft-score.workspace = true
|
||||
craft-xml.workspace = true
|
||||
soundcraft-time.workspace = true
|
||||
@@ -31,6 +32,7 @@ craft-docpath.workspace = true
|
||||
winsafe = { version = "0.0.29", features = ["kernel"] }
|
||||
|
||||
[dev-dependencies]
|
||||
cfb.workspace = true
|
||||
proptest.workspace = true
|
||||
zip.workspace = true
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
//! AAF boundary: the reusable interchange crate constructs the source document, then this module
|
||||
//! verifies and decodes media and maps new tracks into the destination as one undoable edit.
|
||||
use crate::{EngineError, Result};
|
||||
use serde_json::{Value, json};
|
||||
use soundcraft_interchange::{Plan, build_session};
|
||||
use soundcraft_model::{ClipContent, ClipId, Session, SourceAudio, SourceId, TrackId};
|
||||
use soundcraft_time::MAX_POSITION;
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
path::Path,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
fn bad(message: impl Into<String>) -> EngineError {
|
||||
EngineError::Io(message.into())
|
||||
}
|
||||
|
||||
pub fn preview(path: &str, media_dir: &str, composition: Option<&str>) -> Result<Value> {
|
||||
let plan = crate::io::read_aaf_plan(path, media_dir, composition)?;
|
||||
let parsed: Plan = serde_json::from_value(plan.clone()).map_err(|e| bad(e.to_string()))?;
|
||||
let built = build_session(parsed).map_err(|e| bad(e.to_string()))?;
|
||||
let s = built.session;
|
||||
let tracks: Vec<_> = s
|
||||
.tracks
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, t)| json!({"index": index, "name": t.name, "channels": t.channels(), "clips": t.clips().len()}))
|
||||
.collect();
|
||||
Ok(json!({"plan": plan, "name": s.name, "sample_rate": s.sample_rate.hz(), "frame_rate": s.frame_rate.label(),
|
||||
"timecode_start": s.timecode_start, "start_timecode": s.format_position(0, soundcraft_time::TimeFormat::Timecode),
|
||||
"sources": s.sources.len(), "tracks": tracks, "warnings": built.report.warnings}))
|
||||
}
|
||||
|
||||
/// No destination mutation until all options, times and decoded source files have been checked.
|
||||
/// Every source must be a file directly inside `media_dir`, the folder given to the analysis.
|
||||
pub fn import_into(destination: &Session, params: &Value) -> Result<(Session, Value)> {
|
||||
let plan_value = params.get("plan").ok_or_else(|| bad("`plan` from file.preview_aaf is required"))?;
|
||||
let mut plan: Plan = serde_json::from_value(plan_value.clone()).map_err(|e| bad(e.to_string()))?;
|
||||
// The plan comes from the caller, so its media is confined again here, not only at analysis.
|
||||
let media_dir = params.get("media_dir").and_then(Value::as_str).ok_or_else(|| bad("`media_dir` used for file.preview_aaf is required"))?;
|
||||
crate::file_access::check_read(media_dir).map_err(EngineError::Io)?;
|
||||
let indices = params.get("selected").and_then(Value::as_array).ok_or_else(|| bad("`selected` track indices required"))?;
|
||||
let mut selected = HashSet::new();
|
||||
for v in indices {
|
||||
let n =
|
||||
v.as_u64().and_then(|n| usize::try_from(n).ok()).filter(|n| *n < plan.tracks.len()).ok_or_else(|| bad("invalid source track index"))?;
|
||||
if !selected.insert(n) {
|
||||
return Err(bad("duplicate source track selection"));
|
||||
}
|
||||
}
|
||||
if selected.is_empty() {
|
||||
return Err(bad("select at least one source track"));
|
||||
}
|
||||
let mut i = 0;
|
||||
plan.tracks.retain(|_| {
|
||||
let keep = selected.contains(&i);
|
||||
i += 1;
|
||||
keep
|
||||
});
|
||||
let used: HashSet<String> = plan.tracks.iter().flat_map(|t| t.clips.iter().map(|c| c.source.clone())).collect();
|
||||
plan.sources.retain(|s| used.contains(&s.key));
|
||||
let built = build_session(plan).map_err(|e| bad(e.to_string()))?;
|
||||
let mut incoming = built.session;
|
||||
let media = params.get("media").and_then(Value::as_str).unwrap_or("copy");
|
||||
if media != "copy" {
|
||||
return Err(bad("only full-source copy is supported; external linking is not preserved by Save Session"));
|
||||
}
|
||||
let mapping = params.get("mapping").and_then(Value::as_str).unwrap_or("absolute");
|
||||
if !matches!(mapping, "absolute" | "relative") {
|
||||
return Err(bad("mapping must be absolute or relative"));
|
||||
}
|
||||
let offset = match params.get("offset_samples") {
|
||||
None => 0,
|
||||
Some(v) => v.as_i64().filter(|n| n.abs_diff(0) <= MAX_POSITION as u64).ok_or_else(|| bad("invalid track offset in samples"))?,
|
||||
};
|
||||
let empty = destination.tracks.is_empty() && destination.sources.is_empty();
|
||||
if !empty && incoming.sample_rate != destination.sample_rate {
|
||||
return Err(bad("sample rates differ; sample-rate conversion is not implemented"));
|
||||
}
|
||||
let origin = if empty { incoming.timecode_start } else { destination.timecode_start };
|
||||
let shift = if mapping == "absolute" { incoming.timecode_start.checked_sub(origin) } else { Some(0) }
|
||||
.and_then(|n| n.checked_add(offset))
|
||||
.ok_or_else(|| bad("time mapping overflow"))?;
|
||||
for t in &mut incoming.tracks {
|
||||
for c in &mut t.playlist_mut().ok_or_else(|| bad("source playlist missing"))?.clips {
|
||||
c.start = c
|
||||
.start
|
||||
.checked_add(shift)
|
||||
.filter(|n| *n >= 0 && *n <= MAX_POSITION)
|
||||
.ok_or_else(|| bad("mapped clip precedes session start or exceeds time limit; choose relative mapping or another offset"))?;
|
||||
if c.start.checked_add(c.length).is_none_or(|n| n > MAX_POSITION) {
|
||||
return Err(bad("mapped end exceeds time limit"));
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut total_samples = 0u64;
|
||||
for src in &incoming.sources {
|
||||
if !Path::new(&src.path).is_absolute() {
|
||||
return Err(bad("source paths must be absolute"));
|
||||
}
|
||||
total_samples = total_samples
|
||||
.checked_add(src.frames.saturating_mul(u64::from(src.channels)))
|
||||
.filter(|n| *n <= 1 << 27)
|
||||
.ok_or_else(|| bad("selected media exceeds the decoded import memory limit (512 MiB)"))?;
|
||||
crate::io::check_in_media_dir(Path::new(&src.path), Path::new(media_dir))?;
|
||||
let bytes = crate::io::read_interchange_file(Path::new(&src.path), 512 * 1024 * 1024)?;
|
||||
let info = craft_audio::probe(&bytes, Some("wav")).map_err(|e| bad(e.to_string()))?;
|
||||
if (info.sample_rate, info.channels, info.frames) != (src.sample_rate, src.channels, src.frames)
|
||||
|| soundcraft_model::FileFormat::of(&info) != soundcraft_model::FileFormat::Wav
|
||||
{
|
||||
return Err(bad(format!("media changed since analysis: {}", src.path)));
|
||||
}
|
||||
let (_, buffer) = craft_audio::decode(&bytes, Some("wav")).map_err(|e| bad(e.to_string()))?;
|
||||
incoming.pool.insert(src.id, Arc::new(SourceAudio::new(buffer)));
|
||||
}
|
||||
let mut target = destination.clone();
|
||||
if empty {
|
||||
target.sample_rate = incoming.sample_rate;
|
||||
target.frame_rate = incoming.frame_rate;
|
||||
target.timecode_start = incoming.timecode_start;
|
||||
if target.name == "Untitled" {
|
||||
target.name = incoming.name.clone();
|
||||
}
|
||||
}
|
||||
let mut source_ids = HashMap::new();
|
||||
for mut src in incoming.sources {
|
||||
let old = src.id;
|
||||
src.id = SourceId(target.alloc());
|
||||
let audio = incoming.pool.get(old).ok_or_else(|| bad("decoded media missing"))?.clone();
|
||||
target.pool.insert(src.id, audio);
|
||||
source_ids.insert(old, src.id);
|
||||
// Save writes the whole decoded source into the destination Audio Files folder.
|
||||
src.unsaved = true;
|
||||
target.sources.push(src);
|
||||
}
|
||||
let mut track_ids = Vec::new();
|
||||
for mut track in incoming.tracks {
|
||||
track.id = TrackId(target.alloc());
|
||||
track.name = target.unique_track_name(&track.name);
|
||||
let name = track.name.clone();
|
||||
for playlist in &mut track.playlists {
|
||||
playlist.name = name.clone();
|
||||
for clip in &mut playlist.clips {
|
||||
clip.id = ClipId(target.alloc());
|
||||
if let ClipContent::Audio { source, .. } = &mut clip.content {
|
||||
*source = *source_ids.get(source).ok_or_else(|| bad("source mapping missing"))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
track_ids.push(track.id);
|
||||
target.tracks.push(track);
|
||||
}
|
||||
let first_clip = target.tracks.iter().filter(|t| track_ids.contains(&t.id)).flat_map(|t| t.clips()).map(|c| c.start).min();
|
||||
let report = json!({"first_clip_sample":first_clip,"tracks":track_ids,"sources":source_ids.len(),"warnings":built.report.warnings,"handles":built.report.handles,"mapping":mapping,"shift_samples":shift,"media":media});
|
||||
Ok((target, report))
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use soundcraft_model::{ClipId, TrackId};
|
||||
use soundcraft_time::{Range, Samples};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
mod aaf;
|
||||
mod audio_midi;
|
||||
mod audiosuite;
|
||||
mod auto_rename;
|
||||
@@ -131,6 +132,7 @@ pub fn command_specs() -> &'static [CommandSpec] {
|
||||
SPECS.get_or_init(|| {
|
||||
let mut v = Vec::new();
|
||||
v.extend(file::specs());
|
||||
v.extend(aaf::specs());
|
||||
v.extend(edit::specs());
|
||||
v.extend(edit_more::specs());
|
||||
v.extend(view::specs());
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
use super::{CommandSpec, always, bad, str_param};
|
||||
use crate::Engine;
|
||||
use crate::cmd;
|
||||
|
||||
pub fn specs() -> Vec<CommandSpec> {
|
||||
vec![
|
||||
cmd!(query "file.preview_aaf", "Analyze AAF", [], None, "{path, media_dir, composition?} — read-only plan and source properties", always, |_,p| {
|
||||
let path = str_param(p,"path").ok_or_else(|| bad("file.preview_aaf","path required"))?;
|
||||
let media = str_param(p,"media_dir").ok_or_else(|| bad("file.preview_aaf","media_dir required"))?;
|
||||
crate::aaf::preview(path,media,str_param(p,"composition"))
|
||||
}),
|
||||
cmd!(
|
||||
"file.import_aaf",
|
||||
"Session Data (AAF)...",
|
||||
["File", "Import"],
|
||||
None,
|
||||
"{plan, media_dir, selected:[track indices], media?: copy, mapping?: absolute|relative, offset_samples?: 0} — new tracks, full source handles, undoable",
|
||||
stopped,
|
||||
|e, p| {
|
||||
stopped(e).map_err(|why| bad("file.import_aaf", why))?;
|
||||
let (session, report) = crate::aaf::import_into(e.session(), p)?;
|
||||
*e.session_mut() = session;
|
||||
Ok(report)
|
||||
}
|
||||
),
|
||||
]
|
||||
}
|
||||
fn stopped(e: &Engine) -> std::result::Result<(), String> {
|
||||
if e.transport.playing || e.transport.recording { Err("Stop playback and recording before importing session data".into()) } else { Ok(()) }
|
||||
}
|
||||
@@ -1121,6 +1121,126 @@ pub fn plan_takes(e: &Engine, unsaved_dir: &Path, input_channels: usize) -> Vec<
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Checks that `path` is a file directly inside the media folder `media_dir` once both are
|
||||
/// canonical (symlinks resolved), so a plan handed to an import cannot name media elsewhere.
|
||||
pub(crate) fn check_in_media_dir(path: &Path, media_dir: &Path) -> Result<()> {
|
||||
let dir = std::fs::canonicalize(media_dir).map_err(|e| EngineError::Io(format!("media folder {}: {e}", media_dir.display())))?;
|
||||
let file = std::fs::canonicalize(path).map_err(|e| EngineError::Io(format!("{}: {e}", path.display())))?;
|
||||
if file.parent() != Some(dir.as_path()) {
|
||||
return Err(EngineError::Io(format!("{} is outside the media folder {}", path.display(), dir.display())));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Bounded, root-checked media read for interchange imports.
|
||||
pub(crate) fn read_interchange_file(path: &Path, limit: u64) -> Result<Vec<u8>> {
|
||||
use std::io::Read;
|
||||
crate::file_access::check_read(path).map_err(EngineError::Io)?;
|
||||
let meta = std::fs::metadata(path).map_err(|e| EngineError::Io(e.to_string()))?;
|
||||
if !meta.is_file() || meta.len() > limit {
|
||||
return Err(EngineError::Io(format!("{}: not a regular file or exceeds import byte limit", path.display())));
|
||||
}
|
||||
let mut bytes = Vec::new();
|
||||
std::fs::File::open(path).and_then(|f| f.take(limit.saturating_add(1)).read_to_end(&mut bytes)).map_err(|e| EngineError::Io(e.to_string()))?;
|
||||
if bytes.len() as u64 > limit {
|
||||
return Err(EngineError::Io("media exceeds import byte limit".into()));
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
/// Reads an AAF with the pure-Rust interchange reader. Only the user-chosen AAF and media folder
|
||||
/// are opened; every referenced WAV must be named in that folder (exact name, no search).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) fn read_aaf_plan(path: &str, media_dir: &str, composition: Option<&str>) -> Result<Value> {
|
||||
use soundcraft_interchange::aaf::{AafOptions, read_aaf};
|
||||
crate::file_access::check_read(path).map_err(EngineError::Io)?;
|
||||
crate::file_access::check_read(media_dir).map_err(EngineError::Io)?;
|
||||
let meta = std::fs::metadata(path).map_err(|e| EngineError::Io(e.to_string()))?;
|
||||
if !meta.is_file() || meta.len() > 512 * 1024 * 1024 || !Path::new(media_dir).is_dir() {
|
||||
return Err(EngineError::Io("choose an AAF file (at most 512 MiB) and its media folder".into()));
|
||||
}
|
||||
let aaf = std::fs::canonicalize(path).map_err(|e| EngineError::Io(e.to_string()))?;
|
||||
let media_dir = std::fs::canonicalize(media_dir).map_err(|e| EngineError::Io(e.to_string()))?;
|
||||
let base = aaf.parent().map(Path::to_path_buf).unwrap_or_default();
|
||||
let stem = aaf.file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
let file = std::fs::File::open(&aaf).map_err(|e| EngineError::Io(e.to_string()))?;
|
||||
let options = AafOptions { composition, base_dir: &base, default_name: &stem };
|
||||
let plan = read_aaf(std::io::BufReader::new(file), &options, &mut LocalMedia { media_dir: Some(media_dir) })
|
||||
.map_err(|e| EngineError::Io(e.to_string()))?;
|
||||
serde_json::to_value(plan).map_err(|e| EngineError::Io(e.to_string()))
|
||||
}
|
||||
|
||||
/// Resolves AAF locators to local WAV files, optionally relinking by exact file name.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub struct LocalMedia {
|
||||
/// Canonical relink folder. `None` keeps the locator's own path.
|
||||
pub media_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl soundcraft_interchange::aaf::MediaResolver for LocalMedia {
|
||||
fn resolve(&mut self, locator: &Path) -> std::result::Result<soundcraft_interchange::aaf::MediaInfo, soundcraft_interchange::aaf::MediaError> {
|
||||
use soundcraft_interchange::aaf::{MediaError, MediaInfo, wav_info};
|
||||
let source = lenient_canonical(locator);
|
||||
let (path, relinked_from) = match &self.media_dir {
|
||||
None => (source, None),
|
||||
Some(dir) => {
|
||||
let name = source.file_name().ok_or_else(|| MediaError::Invalid(format!("Locator has no file name: {}", source.display())))?;
|
||||
let chosen = dir.join(name);
|
||||
let resolved = lenient_canonical(&chosen);
|
||||
if resolved.parent() != Some(dir.as_path()) {
|
||||
return Err(MediaError::Invalid(format!("Relink escapes media directory: {}", chosen.display())));
|
||||
}
|
||||
let from = (chosen != source).then(|| source.display().to_string());
|
||||
(resolved, from)
|
||||
}
|
||||
};
|
||||
if !path.is_file() {
|
||||
return Err(MediaError::Missing(path.display().to_string()));
|
||||
}
|
||||
crate::file_access::check_read(&path).map_err(MediaError::Invalid)?;
|
||||
let file = std::fs::File::open(&path).map_err(|e| MediaError::Invalid(format!("{}: {e}", path.display())))?;
|
||||
let info = wav_info(std::io::BufReader::new(file)).map_err(|e| MediaError::Invalid(format!("{}: {e}", path.display())))?;
|
||||
Ok(MediaInfo { path: path.display().to_string(), relinked_from, channels: info.channels, frames: info.frames, sample_rate: info.sample_rate })
|
||||
}
|
||||
}
|
||||
|
||||
/// `realpath` without requiring the path to exist: the longest existing prefix is canonical
|
||||
/// (symlinks resolved) and the remaining components are appended after lexical `.`/`..` handling.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn lenient_canonical(path: &Path) -> PathBuf {
|
||||
use std::path::Component;
|
||||
let mut lexical = PathBuf::new();
|
||||
for c in path.components() {
|
||||
match c {
|
||||
Component::CurDir => {}
|
||||
Component::ParentDir => {
|
||||
lexical.pop();
|
||||
}
|
||||
other => lexical.push(other),
|
||||
}
|
||||
}
|
||||
let mut tail = Vec::new();
|
||||
let mut prefix = lexical.as_path();
|
||||
loop {
|
||||
if let Ok(real) = std::fs::canonicalize(prefix) {
|
||||
return tail.iter().rev().fold(real, |acc: PathBuf, part| acc.join(part));
|
||||
}
|
||||
match (prefix.parent(), prefix.file_name()) {
|
||||
(Some(parent), Some(name)) => {
|
||||
tail.push(name.to_os_string());
|
||||
prefix = parent;
|
||||
}
|
||||
_ => return lexical,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub(crate) fn read_aaf_plan(_: &str, _: &str, _: Option<&str>) -> Result<Value> {
|
||||
Err(EngineError::Io("AAF import needs the desktop app: its media files are read from a local folder".into()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod exclusive_tests {
|
||||
use super::*;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
//! The engine owns the [`Session`] behind an `Arc` (copy-on-write), so undo snapshots are cheap.
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
pub mod aaf;
|
||||
pub mod autosave;
|
||||
pub mod catalog;
|
||||
pub mod catalog_more;
|
||||
|
||||
@@ -0,0 +1,414 @@
|
||||
use craft_audio::{AudioBuffer, BitDepth, EncodeOptions};
|
||||
use serde_json::{Value, json};
|
||||
use soundcraft_engine::{Engine, file_access};
|
||||
use soundcraft_model::{ChannelFormat, Session, TrackKind};
|
||||
use soundcraft_time::SampleRate;
|
||||
use std::{
|
||||
io::{Cursor, Read},
|
||||
path::PathBuf,
|
||||
sync::atomic::{AtomicU64, Ordering},
|
||||
};
|
||||
|
||||
struct Fixture {
|
||||
dir: PathBuf,
|
||||
params: Value,
|
||||
}
|
||||
impl Fixture {
|
||||
fn new() -> Self {
|
||||
static NEXT: AtomicU64 = AtomicU64::new(0);
|
||||
let dir = std::env::temp_dir().join(format!("soundcraft-aaf-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed)));
|
||||
std::fs::create_dir(&dir).unwrap();
|
||||
let path = dir.join("Source á with spaces.wav");
|
||||
let mut ch = vec![0.0; 480000];
|
||||
ch[96000] = 0.5;
|
||||
let bytes = craft_audio::encode(
|
||||
&AudioBuffer { sample_rate: 48000, channels: vec![ch] },
|
||||
&EncodeOptions::new(craft_audio::EncodeFormat::Wav).with_bit_depth(BitDepth::Int16),
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(&path, bytes).unwrap();
|
||||
let params = json!({"plan":{"schema_version":1,"name":"AAF test","sample_rate":48000,"timecode_start":[3600,1],"frame_rate":{"rate":[25,1],"drop":false},"warnings":["Test warning"],
|
||||
"sources":[{"key":"source","name":"Original source","path":std::fs::canonicalize(&path).unwrap(),"channels":1,"frames":480000,"sample_rate":48000}],
|
||||
"tracks":[{"name":"DX","channels":1,"clips":[{"name":"Cut","source":"source","start":[1,1],"end":[3,1],"offset":[2,1]}]},
|
||||
{"name":"Empty","channels":1,"clips":[]}]},"media_dir":dir,"selected":[0],"mapping":"absolute","media":"copy","offset_samples":0});
|
||||
Self { dir, params }
|
||||
}
|
||||
}
|
||||
impl Drop for Fixture {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.dir);
|
||||
}
|
||||
}
|
||||
fn existing() -> Engine {
|
||||
let mut s = Session::new("Existing", SampleRate::HZ_48000);
|
||||
s.add_track(TrackKind::Audio, ChannelFormat::Mono, Some("Keep"));
|
||||
Engine::new(s)
|
||||
}
|
||||
#[test]
|
||||
fn absolute_mapping_preserves_source_window_and_is_one_undo_step() {
|
||||
let f = Fixture::new();
|
||||
let mut e = existing();
|
||||
let before = e.session().to_json().unwrap();
|
||||
let report = e.execute("file.import_aaf", &f.params).unwrap();
|
||||
assert_eq!(report["tracks"].as_array().unwrap().len(), 1);
|
||||
assert_eq!(e.session().tracks.len(), 2);
|
||||
let c = &e.session().tracks[1].clips()[0];
|
||||
assert_eq!((c.start, c.length, c.source_offset()), (172848000, 96000, 96000));
|
||||
assert_eq!(e.session().sources[0].frames, 480000);
|
||||
assert!(e.session().sources[0].unsaved);
|
||||
let source = c.source().unwrap();
|
||||
assert_eq!(e.session().pool.get(source).unwrap().channel(0).unwrap()[96000], 0.5);
|
||||
assert_eq!(e.undo_label(), Some("Session Data (AAF)..."));
|
||||
e.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(e.session().to_json().unwrap(), before);
|
||||
}
|
||||
#[test]
|
||||
fn relative_mapping_and_track_selection_do_not_replace_existing_tracks() {
|
||||
let mut f = Fixture::new();
|
||||
let mut e = existing();
|
||||
f.params["mapping"] = json!("relative");
|
||||
f.params["offset_samples"] = json!(96000);
|
||||
e.execute("file.import_aaf", &f.params).unwrap();
|
||||
assert_eq!(e.session().tracks[0].name, "Keep");
|
||||
assert_eq!(e.session().tracks[1].name, "DX");
|
||||
assert_eq!(e.session().tracks[1].clips()[0].start, 144000);
|
||||
assert!(e.session().sources[0].unsaved);
|
||||
}
|
||||
#[test]
|
||||
fn empty_session_adopts_source_clock_and_save_collects_the_whole_source() {
|
||||
let f = Fixture::new();
|
||||
let mut e = Engine::default();
|
||||
e.execute("file.import_aaf", &f.params).unwrap();
|
||||
assert_eq!(e.session().timecode_start, 172800000);
|
||||
assert_eq!(e.session().tracks[0].clips()[0].start, 48000);
|
||||
let dest = f.dir.join("Saved/session.scraft");
|
||||
soundcraft_engine::io::save_session(&mut e, &dest.to_string_lossy()).unwrap();
|
||||
let file = f.dir.join("Saved").join(&e.session().sources[0].path);
|
||||
let info = craft_audio::probe(&std::fs::read(file).unwrap(), Some("wav")).unwrap();
|
||||
assert_eq!(info.frames, 480000);
|
||||
assert_eq!(e.session().tracks[0].clips()[0].source_offset(), 96000);
|
||||
}
|
||||
#[test]
|
||||
fn invalid_inputs_fail_without_mutation() {
|
||||
let f = Fixture::new();
|
||||
let mut e = existing();
|
||||
let before = e.session().to_json().unwrap();
|
||||
for update in [
|
||||
json!({"selected":[]}),
|
||||
json!({"selected":[99]}),
|
||||
json!({"selected":[0,0]}),
|
||||
json!({"mapping":"unknown"}),
|
||||
json!({"media":"link"}),
|
||||
json!({"offset_samples":-172900000}),
|
||||
] {
|
||||
let mut p = f.params.clone();
|
||||
for (k, v) in update.as_object().unwrap() {
|
||||
p[k] = v.clone();
|
||||
}
|
||||
assert!(e.execute("file.import_aaf", &p).is_err());
|
||||
assert_eq!(e.session().to_json().unwrap(), before);
|
||||
assert!(e.undo_label().is_none());
|
||||
}
|
||||
std::fs::remove_file(f.dir.join("Source á with spaces.wav")).unwrap();
|
||||
assert!(e.execute("file.import_aaf", &f.params).is_err());
|
||||
assert_eq!(e.session().to_json().unwrap(), before);
|
||||
}
|
||||
#[test]
|
||||
fn sample_rate_changes_and_confined_media_are_rejected() {
|
||||
let f = Fixture::new();
|
||||
let mut s = Session::new("44.1", SampleRate::HZ_44100);
|
||||
s.add_track(TrackKind::Audio, ChannelFormat::Mono, Some("Existing"));
|
||||
let mut e = Engine::new(s);
|
||||
assert!(e.execute("file.import_aaf", &f.params).unwrap_err().to_string().contains("sample rates differ"));
|
||||
let restricted = f.dir.join("allowed");
|
||||
std::fs::create_dir(&restricted).unwrap();
|
||||
let roots = file_access::AutomationRoots::new(&[restricted.as_path()], &[]).unwrap();
|
||||
let mut e = existing();
|
||||
assert!(file_access::confine(roots.as_ref(), || e.execute("file.import_aaf", &f.params)).is_err());
|
||||
assert_eq!(e.session().tracks.len(), 1);
|
||||
}
|
||||
#[test]
|
||||
fn import_confines_the_plans_media_to_the_media_folder_again() {
|
||||
// A plan is caller-supplied (MCP, automation): editing its paths must not reach other files.
|
||||
let f = Fixture::new();
|
||||
let mut e = existing();
|
||||
let before = e.session().to_json().unwrap();
|
||||
let elsewhere = f.dir.join("elsewhere");
|
||||
std::fs::create_dir(&elsewhere).unwrap();
|
||||
std::fs::copy(f.dir.join("Source á with spaces.wav"), elsewhere.join("Source á with spaces.wav")).unwrap();
|
||||
let outside = std::fs::canonicalize(elsewhere.join("Source á with spaces.wav")).unwrap();
|
||||
let traversal = elsewhere.join("..").join("elsewhere").join("Source á with spaces.wav");
|
||||
for path in [json!(outside), json!(traversal)] {
|
||||
let mut p = f.params.clone();
|
||||
p["plan"]["sources"][0]["path"] = path.clone();
|
||||
let err = e.execute("file.import_aaf", &p).unwrap_err().to_string();
|
||||
assert!(err.contains("outside the media folder"), "{path}: {err}");
|
||||
}
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let link = f.dir.join("link.wav");
|
||||
std::os::unix::fs::symlink(&outside, &link).unwrap();
|
||||
let mut p = f.params.clone();
|
||||
p["plan"]["sources"][0]["path"] = json!(link);
|
||||
assert!(e.execute("file.import_aaf", &p).unwrap_err().to_string().contains("outside the media folder"));
|
||||
}
|
||||
let mut p = f.params.clone();
|
||||
p.as_object_mut().unwrap().remove("media_dir");
|
||||
assert!(e.execute("file.import_aaf", &p).unwrap_err().to_string().contains("media_dir"));
|
||||
assert_eq!(e.session().to_json().unwrap(), before);
|
||||
assert!(e.undo_label().is_none());
|
||||
}
|
||||
#[test]
|
||||
fn playing_import_cannot_bypass_the_transport_guard_with_target_params() {
|
||||
let f = Fixture::new();
|
||||
let mut e = existing();
|
||||
e.transport.playing = true;
|
||||
let mut p = f.params.clone();
|
||||
p["tracks"] = json!([1]);
|
||||
assert!(e.execute("file.import_aaf", &p).is_err());
|
||||
assert_eq!(e.session().tracks.len(), 1);
|
||||
}
|
||||
|
||||
/// A synthetic AAF (two tracks, three edits, chained source offsets) written by pyaaf2. Its
|
||||
/// external WAVs are regenerated here with the same names, layouts and lengths.
|
||||
struct AafFolder {
|
||||
dir: PathBuf,
|
||||
}
|
||||
impl AafFolder {
|
||||
fn new() -> Self {
|
||||
let dir = Fixture::new().dir.with_extension("aaf");
|
||||
std::fs::create_dir(&dir).unwrap();
|
||||
std::fs::copy(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/synthetic-two-tracks.aaf"), dir.join("Montaje sintético.aaf")).unwrap();
|
||||
for (name, channels) in [("Diálogo á #1.wav", 1), ("Ambiente estéreo.wav", 2)] {
|
||||
let audio = AudioBuffer { sample_rate: 48000, channels: vec![vec![0.25; 384000]; channels] };
|
||||
let options = EncodeOptions::new(craft_audio::EncodeFormat::Wav).with_bit_depth(BitDepth::Int16);
|
||||
std::fs::write(dir.join(name), craft_audio::encode(&audio, &options).unwrap()).unwrap();
|
||||
}
|
||||
Self { dir }
|
||||
}
|
||||
fn preview(&self) -> soundcraft_engine::Result<Value> {
|
||||
let aaf = self.dir.join("Montaje sintético.aaf");
|
||||
Engine::default().execute("file.preview_aaf", &json!({"path": aaf, "media_dir": self.dir}))
|
||||
}
|
||||
}
|
||||
impl Drop for AafFolder {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.dir);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rust_reader_turns_an_aaf_file_into_editable_tracks() {
|
||||
let f = AafFolder::new();
|
||||
let preview = f.preview().unwrap();
|
||||
let plan = &preview["plan"];
|
||||
assert_eq!(plan["name"], "Clase AAF — cortes y handles");
|
||||
assert_eq!(plan["timecode_start"], json!([3600, 1]));
|
||||
assert_eq!(plan["frame_rate"], json!({"rate": [25, 1], "drop": false}));
|
||||
let names: Vec<_> = plan["tracks"].as_array().unwrap().iter().map(|t| t["name"].as_str().unwrap()).collect();
|
||||
assert_eq!(names, ["01 Diálogo", "02 Ambiente estéreo"]);
|
||||
assert_eq!(plan["tracks"][0]["clips"][1]["offset"], json!([7, 2]));
|
||||
let channels: Vec<_> = plan["sources"].as_array().unwrap().iter().map(|s| s["channels"].as_u64().unwrap()).collect();
|
||||
assert_eq!(channels, [1, 2]);
|
||||
assert!(plan["sources"][0]["path"].as_str().unwrap().ends_with("Diálogo á #1.wav"));
|
||||
|
||||
let mut e = Engine::default();
|
||||
e.execute("file.import_aaf", &json!({"plan": plan, "media_dir": f.dir, "selected": [0, 1]})).unwrap();
|
||||
let edits: Vec<_> = e.session().tracks.iter().flat_map(|t| t.clips()).map(|c| (c.start, c.length, c.source_offset())).collect();
|
||||
assert_eq!(edits, [(48000, 96000, 48000), (192000, 48000, 168000), (0, 240000, 72000)]);
|
||||
assert_eq!(e.session().timecode_start, 3600 * 48000);
|
||||
assert_eq!(e.session().tracks[1].channels(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_media_is_reported_and_its_edits_skipped_without_failing_the_import() {
|
||||
let f = AafFolder::new();
|
||||
std::fs::remove_file(f.dir.join("Diálogo á #1.wav")).unwrap();
|
||||
let preview = f.preview().unwrap();
|
||||
let plan = &preview["plan"];
|
||||
let missing: Vec<_> = plan["warnings"].as_array().unwrap().iter().filter_map(|w| w.as_str()).filter(|w| w.starts_with("Missing media")).collect();
|
||||
assert_eq!(missing.len(), 1, "{missing:?}");
|
||||
assert!(missing[0].contains("Diálogo á #1.wav") && missing[0].contains("2 edit(s) skipped"), "{}", missing[0]);
|
||||
// The dialogue track keeps its name but loses its two edits; the ambience edit is intact.
|
||||
assert_eq!(plan["tracks"][0]["clips"].as_array().unwrap().len(), 0);
|
||||
assert_eq!(plan["tracks"][1]["clips"].as_array().unwrap().len(), 1);
|
||||
assert_eq!(plan["sources"].as_array().unwrap().len(), 1);
|
||||
let mut e = Engine::default();
|
||||
e.execute("file.import_aaf", &json!({"plan": plan, "media_dir": f.dir, "selected": [0, 1]})).unwrap();
|
||||
let edits: Vec<_> = e.session().tracks.iter().flat_map(|t| t.clips()).map(|c| (c.start, c.length, c.source_offset())).collect();
|
||||
assert_eq!(edits, [(0, 240000, 72000)]);
|
||||
|
||||
// With no media at all there is nothing to import.
|
||||
std::fs::remove_file(f.dir.join("Ambiente estéreo.wav")).unwrap();
|
||||
let err = f.preview().unwrap_err().to_string();
|
||||
assert!(err.contains("none of the referenced files were found"), "{err}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn media_that_is_present_but_not_a_wav_still_fails() {
|
||||
let f = AafFolder::new();
|
||||
std::fs::write(f.dir.join("Diálogo á #1.wav"), b"RIFF\0\0\0\0WAVEnot audio").unwrap();
|
||||
assert!(f.preview().is_err());
|
||||
}
|
||||
|
||||
/// The fixture with its first WAV locator (`Di%C3%A1logo%20%C3%A1%20%231.wav`, 32 UTF-16 units)
|
||||
/// replaced by `url`, padded to the same length so the property stream stays well formed.
|
||||
fn with_locator(f: &AafFolder, url: &str) -> soundcraft_engine::Result<Value> {
|
||||
let original = "Di%C3%A1logo%20%C3%A1%20%231.wav";
|
||||
assert_eq!(url.encode_utf16().count(), original.encode_utf16().count(), "{url}");
|
||||
let aaf = f.dir.join("Montaje sintético.aaf");
|
||||
let mut bytes = std::fs::read(&aaf).unwrap();
|
||||
let from: Vec<u8> = original.encode_utf16().flat_map(u16::to_le_bytes).collect();
|
||||
let to: Vec<u8> = url.encode_utf16().flat_map(u16::to_le_bytes).collect();
|
||||
let at = bytes.windows(from.len()).position(|w| w == from.as_slice()).unwrap();
|
||||
bytes[at..at + to.len()].copy_from_slice(&to);
|
||||
std::fs::write(&aaf, bytes).unwrap();
|
||||
f.preview()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn locators_that_try_to_leave_the_aaf_folder_are_refused() {
|
||||
for url in [
|
||||
"../../../../../../etc/passwd.wav",
|
||||
"%2E%2E/%2E%2E/%2E%2E/secret1.wav",
|
||||
"file:///tmp/../etc/shadow000.wav",
|
||||
"http://evil.example/payload0.wav",
|
||||
"file://server/share/payload0.wav",
|
||||
"Di%C3%A1logo%20%C3%A1%20%231.wa/",
|
||||
"Di%C3%A1logo%20%C3%A1%20%001.wav",
|
||||
] {
|
||||
let f = AafFolder::new();
|
||||
let err = with_locator(&f, url).unwrap_err().to_string();
|
||||
assert!(err.contains("ocator"), "{url}: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_absolute_locator_only_names_a_file_in_the_chosen_media_folder() {
|
||||
// A locator pointing anywhere on disk is reduced to its file name and looked up only in the
|
||||
// media folder the user chose: the real file elsewhere is never opened.
|
||||
let f = AafFolder::new();
|
||||
let preview = with_locator(&f, "file:///etc/Dlogo%20%C3%A1_1.wav").unwrap();
|
||||
let w: Vec<_> = preview["plan"]["warnings"].as_array().unwrap().iter().filter_map(|w| w.as_str()).collect();
|
||||
assert!(
|
||||
w.iter().any(
|
||||
|w| w.starts_with("Missing media") && w.contains(&std::fs::canonicalize(&f.dir).unwrap().join("Dlogo á_1.wav").display().to_string())
|
||||
),
|
||||
"{w:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Offsets into a structured-storage (CFB) file, enough to rewrite one FAT entry.
|
||||
struct Cfb {
|
||||
bytes: Vec<u8>,
|
||||
sector: usize,
|
||||
}
|
||||
impl Cfb {
|
||||
fn new(bytes: Vec<u8>) -> Self {
|
||||
let sector = 1 << u16::from_le_bytes([bytes[0x1E], bytes[0x1F]]);
|
||||
Self { bytes, sector }
|
||||
}
|
||||
fn u32_at(&self, at: usize) -> u32 {
|
||||
u32::from_le_bytes(self.bytes[at..at + 4].try_into().unwrap())
|
||||
}
|
||||
fn fat_entry(&self, i: u32) -> usize {
|
||||
let per = self.sector / 4;
|
||||
let fat_sector = self.u32_at(0x4C + 4 * (i as usize / per));
|
||||
(fat_sector as usize + 1) * self.sector + 4 * (i as usize % per)
|
||||
}
|
||||
fn chain(&self, start: u32) -> Vec<u32> {
|
||||
let mut out = vec![start];
|
||||
while let next @ 0..=0xFFFF_FFF9 = self.u32_at(self.fat_entry(*out.last().unwrap())) {
|
||||
out.push(next);
|
||||
}
|
||||
out
|
||||
}
|
||||
fn point(&mut self, from: u32, to: u32) {
|
||||
let at = self.fat_entry(from);
|
||||
self.bytes[at..at + 4].copy_from_slice(&to.to_le_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn looped_sector_chains_fail_instead_of_hanging() {
|
||||
let fixture = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/synthetic-two-tracks.aaf")).unwrap();
|
||||
let base = Cfb::new(fixture);
|
||||
let root_start = base.u32_at(base.sector + 0x74);
|
||||
// (chain, start sector): directory, mini FAT, mini stream (root entry).
|
||||
let chains = [("directory", base.u32_at(0x30)), ("mini FAT", base.u32_at(0x3C)), ("mini stream", root_start)];
|
||||
for (name, start) in chains {
|
||||
let chain = base.chain(start);
|
||||
assert!(chain.len() >= 2, "{name}: fixture chain too short to loop");
|
||||
let last = *chain.last().unwrap();
|
||||
// Back to the start, and onto itself in the middle (a sector reached twice).
|
||||
for (from, to) in [(last, start), (chain[1], chain[1])] {
|
||||
let mut cfb = Cfb::new(base.bytes.clone());
|
||||
cfb.point(from, to);
|
||||
let f = AafFolder::new();
|
||||
let aaf = f.dir.join("Montaje sintético.aaf");
|
||||
std::fs::write(&aaf, &cfb.bytes).unwrap();
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
let media = f.dir.clone();
|
||||
std::thread::spawn(move || {
|
||||
let _ = tx.send(Engine::default().execute("file.preview_aaf", &json!({"path": aaf, "media_dir": media})).map(|_| ()));
|
||||
});
|
||||
let result =
|
||||
rx.recv_timeout(std::time::Duration::from_secs(30)).unwrap_or_else(|_| panic!("{name} {from}->{to}: reader did not terminate"));
|
||||
assert!(result.is_err(), "{name} {from}->{to}: a looped chain was accepted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relinked_sources_are_reported_once_however_many_edits_use_them() {
|
||||
let f = AafFolder::new();
|
||||
let moved = f.dir.join("moved media");
|
||||
std::fs::create_dir(&moved).unwrap();
|
||||
for name in ["Diálogo á #1.wav", "Ambiente estéreo.wav"] {
|
||||
std::fs::rename(f.dir.join(name), moved.join(name)).unwrap();
|
||||
}
|
||||
let aaf = f.dir.join("Montaje sintético.aaf");
|
||||
let preview = Engine::default().execute("file.preview_aaf", &json!({"path": aaf, "media_dir": moved})).unwrap();
|
||||
let relinks = preview["plan"]["warnings"].as_array().unwrap().iter().filter(|w| w.as_str().unwrap().starts_with("Relinked ")).count();
|
||||
// Three edits, two source files: the dialogue source is used twice.
|
||||
assert_eq!(relinks, 2);
|
||||
assert_eq!(preview["plan"]["sources"].as_array().unwrap().len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unknown_composition_id_is_refused() {
|
||||
let f = AafFolder::new();
|
||||
let aaf = f.dir.join("Montaje sintético.aaf");
|
||||
let err = Engine::default()
|
||||
.execute("file.preview_aaf", &json!({"path": aaf, "media_dir": f.dir, "composition": "urn:smpte:umid:00"}))
|
||||
.unwrap_err()
|
||||
.to_string();
|
||||
assert!(err.contains("Choose exactly one composition"), "{err}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repeated_local_mob_references_fail_before_property_expansion() {
|
||||
// A small index can otherwise expand one storage's properties once per repeated reference.
|
||||
let mut bytes = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/synthetic-two-tracks.aaf")).unwrap();
|
||||
let mut index = Vec::new();
|
||||
{
|
||||
let mut cfb = cfb::CompoundFile::open(Cursor::new(bytes.as_slice())).unwrap();
|
||||
cfb.open_stream("/Header-2/Content-3b03/Mobs-1901 index").unwrap().read_to_end(&mut index).unwrap();
|
||||
}
|
||||
let count = u32::from_le_bytes(index[0..4].try_into().unwrap()) as usize;
|
||||
let key_size = usize::from(index[14]);
|
||||
assert!(count >= 2 && matches!(key_size, 16 | 32));
|
||||
let entry = 8 + key_size;
|
||||
let original_index = index.clone();
|
||||
let first_local = index[15..19].to_vec();
|
||||
index[15 + entry..19 + entry].copy_from_slice(&first_local);
|
||||
|
||||
// This small stream is contiguous in the fixture's mini stream; replace only its index bytes.
|
||||
let at = bytes.windows(original_index.len()).position(|window| window == original_index.as_slice()).unwrap();
|
||||
bytes[at..at + index.len()].copy_from_slice(&index);
|
||||
|
||||
let f = AafFolder::new();
|
||||
std::fs::write(f.dir.join("Montaje sintético.aaf"), bytes).unwrap();
|
||||
let err = f.preview().unwrap_err().to_string();
|
||||
assert!(err.contains("duplicate local reference in mobs"), "{err}");
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "soundcraft-interchange"
|
||||
description = "Rational-time interchange plans and editable session construction"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license = "MIT"
|
||||
rust-version.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
soundcraft-model.workspace = true
|
||||
soundcraft-time.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
thiserror.workspace = true
|
||||
cfb.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -0,0 +1,28 @@
|
||||
# Interchange core
|
||||
|
||||
Pure Rust Plan → Session constructor, originally developed in vhhr7/soundcraft_helper.
|
||||
Rational endpoints are converted to samples independently; sources retain complete media
|
||||
bounds and clips retain source offsets. No processes, UI or filesystem access.
|
||||
|
||||
`aaf` reads a strict subset of AAF (structured storage, via the `cfb` crate) into a Plan:
|
||||
timeline slots of SourceClip/Filler, resolved through MasterMobs to SourceMobs with a
|
||||
WAVEDescriptor and one external file locator. Gain, fades, transitions, selectors, nested
|
||||
sequences, embedded essence and split channels fail explicitly. The caller supplies the
|
||||
opened AAF and a `MediaResolver` that confines, relinks and probes each WAV; the engine's
|
||||
resolver accepts only files named exactly in the media folder the user chose.
|
||||
|
||||
The reader's plans were checked byte-for-byte against the earlier pyaaf2 prototype on the
|
||||
synthetic fixture, twelve edited variants of it and a 22-track/124-edit real-world AAF.
|
||||
|
||||
## Untrusted input and provenance
|
||||
|
||||
AAF files are treated as hostile input; the bounds (sector chains, directory size, stream
|
||||
size, collection counts, source-chain depth) and the locator rules (local paths only, no
|
||||
`..`, relative locators stay under the AAF's folder, missing media reported per file rather
|
||||
than aborting) are listed in the `aaf` module documentation and covered by tests in
|
||||
`crates/engine/tests/aaf_import.rs`.
|
||||
|
||||
The storage layout, class and property identifiers and MobID text form were learned by
|
||||
reading pyaaf2 (MIT, Mark Reid); no pyaaf2 code was copied, and pyaaf2 also wrote the
|
||||
synthetic test fixture. No code from the AAF SDK or from any GPL/LGPL/MPL project was read or
|
||||
used.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,287 @@
|
||||
//! Reusable interchange plan -> SoundCraft session. No processes, UI, or filesystem access.
|
||||
//! Readers supply rational seconds. Endpoints are rounded independently (nearest, ties away
|
||||
//! from zero), so adjacent edits share exactly the same boundary without cumulative drift.
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
pub mod aaf;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use soundcraft_model::{ChannelFormat, Clip, ClipId, Session, Source, SourceId, Track, TrackId, TrackKind};
|
||||
use soundcraft_time::{FrameRate, MAX_POSITION, SampleRate};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("interchange: {0}")]
|
||||
pub struct ImportError(pub String);
|
||||
type Result<T> = std::result::Result<T, ImportError>;
|
||||
fn invalid(s: &str) -> ImportError {
|
||||
ImportError(s.into())
|
||||
}
|
||||
|
||||
/// Rational seconds [numerator, denominator]. Both must be nonnegative, denominator > 0.
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
pub struct Rational(pub i64, pub i64);
|
||||
impl Rational {
|
||||
pub fn samples(self, hz: u32) -> Result<i64> {
|
||||
if self.0 < 0 || self.1 <= 0 {
|
||||
return Err(invalid("negative time or invalid denominator"));
|
||||
}
|
||||
let n = i128::from(self.0) * i128::from(hz);
|
||||
let d = i128::from(self.1);
|
||||
let v = (n + d / 2) / d;
|
||||
if v > i128::from(MAX_POSITION) {
|
||||
return Err(invalid("time exceeds SoundCraft limit"));
|
||||
}
|
||||
i64::try_from(v).map_err(|_| invalid("time overflow"))
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Plan {
|
||||
pub schema_version: u32,
|
||||
pub name: String,
|
||||
pub sample_rate: u32,
|
||||
pub timecode_start: Rational,
|
||||
pub frame_rate: Option<TimecodeRate>,
|
||||
pub sources: Vec<Media>,
|
||||
pub tracks: Vec<ImportTrack>,
|
||||
pub warnings: Vec<String>,
|
||||
}
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct TimecodeRate {
|
||||
pub rate: Rational,
|
||||
pub drop: bool,
|
||||
}
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Media {
|
||||
pub key: String,
|
||||
pub name: String,
|
||||
pub path: String,
|
||||
pub channels: u16,
|
||||
pub frames: u64,
|
||||
pub sample_rate: u32,
|
||||
}
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ImportTrack {
|
||||
pub name: String,
|
||||
pub channels: u16,
|
||||
pub clips: Vec<ImportClip>,
|
||||
}
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ImportClip {
|
||||
pub name: String,
|
||||
pub source: String,
|
||||
pub start: Rational,
|
||||
pub end: Rational,
|
||||
pub offset: Rational,
|
||||
}
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct HandleReport {
|
||||
pub clip: String,
|
||||
pub before: i64,
|
||||
pub after: i64,
|
||||
}
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Report {
|
||||
pub warnings: Vec<String>,
|
||||
pub handles: Vec<HandleReport>,
|
||||
}
|
||||
pub struct Imported {
|
||||
pub session: Session,
|
||||
pub report: Report,
|
||||
}
|
||||
|
||||
fn layout(channels: u16) -> Result<ChannelFormat> {
|
||||
match channels {
|
||||
1 => Ok(ChannelFormat::Mono),
|
||||
2 => Ok(ChannelFormat::Stereo),
|
||||
_ => Err(invalid("only mono/stereo supported")),
|
||||
}
|
||||
}
|
||||
fn name(s: &str) -> Result<()> {
|
||||
if s.chars().count() > soundcraft_model::MAX_NAME_CHARS || s.is_empty() {
|
||||
return Err(invalid("name empty or too long for SoundCraft"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn frame_rate(tc: &TimecodeRate) -> Result<FrameRate> {
|
||||
let Rational(n, d) = tc.rate;
|
||||
if n <= 0 || d <= 0 {
|
||||
return Err(invalid("invalid frame rate"));
|
||||
}
|
||||
FrameRate::ALL
|
||||
.into_iter()
|
||||
.find(|r| {
|
||||
let (rn, rd) = r.rational();
|
||||
i128::from(n) * i128::from(rd) == i128::from(rn) * i128::from(d) && r.is_drop() == tc.drop
|
||||
})
|
||||
.ok_or_else(|| invalid("unsupported frame rate/drop combination"))
|
||||
}
|
||||
/// Build transactionally. On any error no partial session is returned. The caller must verify
|
||||
/// media bytes against the metadata before using the plan; see the CLI for a bounded probe.
|
||||
pub fn build_session(plan: Plan) -> Result<Imported> {
|
||||
if plan.schema_version != 1 {
|
||||
return Err(invalid("unsupported interchange schema"));
|
||||
}
|
||||
if plan.sources.len() > 100_000 || plan.tracks.len() > 100_000 || plan.tracks.iter().map(|t| t.clips.len()).sum::<usize>() > 100_000 {
|
||||
return Err(invalid("too many sources/tracks/clips"));
|
||||
}
|
||||
name(&plan.name)?;
|
||||
let sr = SampleRate::new(plan.sample_rate).map_err(|e| ImportError(e.to_string()))?;
|
||||
let mut s = Session::new(&plan.name, sr);
|
||||
s.timecode_start = plan.timecode_start.samples(sr.hz())?;
|
||||
if let Some(tc) = &plan.frame_rate {
|
||||
s.frame_rate = frame_rate(tc)?;
|
||||
}
|
||||
let mut ids = HashMap::new();
|
||||
for m in &plan.sources {
|
||||
name(&m.name)?;
|
||||
layout(m.channels)?;
|
||||
if m.sample_rate != sr.hz() || m.frames == 0 || m.frames > MAX_POSITION as u64 || m.path.is_empty() {
|
||||
return Err(invalid("invalid media metadata or mixed sample rates (resampling unsupported)"));
|
||||
}
|
||||
let id = SourceId(s.alloc());
|
||||
if ids.insert(m.key.as_str(), (id, m.frames, m.channels)).is_some() {
|
||||
return Err(invalid("duplicate source key"));
|
||||
}
|
||||
s.sources.push(Source {
|
||||
id,
|
||||
name: m.name.clone(),
|
||||
path: m.path.clone(),
|
||||
channels: m.channels,
|
||||
frames: m.frames,
|
||||
sample_rate: m.sample_rate,
|
||||
format: soundcraft_model::FileFormat::Wav,
|
||||
time_reference: 0,
|
||||
unsaved: false,
|
||||
});
|
||||
}
|
||||
let mut report = Report { warnings: plan.warnings.clone(), handles: Vec::new() };
|
||||
for t in &plan.tracks {
|
||||
name(&t.name)?;
|
||||
let track_id = TrackId(s.alloc());
|
||||
// Construct directly: add_track intentionally renames duplicates, interchange must not.
|
||||
let mut track = Track::new(track_id, &t.name, TrackKind::Audio, layout(t.channels)?, s.next_track_color());
|
||||
let mut previous_end = 0;
|
||||
for c in &t.clips {
|
||||
name(&c.name)?;
|
||||
let (source, frames, channels) = ids.get(c.source.as_str()).ok_or_else(|| invalid("unknown source key"))?;
|
||||
if *channels != t.channels {
|
||||
return Err(invalid("clip/track layout mismatch"));
|
||||
}
|
||||
let start = c.start.samples(sr.hz())?;
|
||||
let end = c.end.samples(sr.hz())?;
|
||||
let offset = c.offset.samples(sr.hz())?;
|
||||
if end <= start || start < previous_end {
|
||||
return Err(invalid("zero/negative duration or overlapping/out-of-order clips"));
|
||||
}
|
||||
let length = end - start;
|
||||
let source_end = offset.checked_add(length).ok_or_else(|| invalid("source window overflow"))?;
|
||||
if source_end > *frames as i64 {
|
||||
return Err(invalid("clip extends beyond source; refusing truncated handles"));
|
||||
}
|
||||
let clip = Clip::audio(ClipId(s.alloc()), &c.name, *source, offset, start, length);
|
||||
track.playlist_mut().ok_or_else(|| invalid("missing playlist"))?.clips.push(clip);
|
||||
report.handles.push(HandleReport { clip: c.name.clone(), before: offset, after: *frames as i64 - source_end });
|
||||
previous_end = end;
|
||||
}
|
||||
s.tracks.push(track);
|
||||
}
|
||||
s.comments = "Imported by soundcraft-interchange schema v1; see accompanying import report for limitations.".into();
|
||||
Ok(Imported { session: s, report })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
fn plan() -> Plan {
|
||||
Plan {
|
||||
schema_version: 1,
|
||||
name: "Test".into(),
|
||||
sample_rate: 48000,
|
||||
timecode_start: Rational(3600, 1),
|
||||
frame_rate: Some(TimecodeRate { rate: Rational(25, 1), drop: false }),
|
||||
warnings: vec![],
|
||||
sources: vec![Media { key: "s".into(), name: "src".into(), path: "a.wav".into(), channels: 1, frames: 480000, sample_rate: 48000 }],
|
||||
tracks: vec![ImportTrack {
|
||||
name: "DX".into(),
|
||||
channels: 1,
|
||||
clips: vec![ImportClip {
|
||||
name: "cut".into(),
|
||||
source: "s".into(),
|
||||
start: Rational(1, 1),
|
||||
end: Rational(3, 1),
|
||||
offset: Rational(2, 1),
|
||||
}],
|
||||
}],
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn positions_offsets_handles_and_roundtrip() {
|
||||
let result = build_session(plan()).unwrap();
|
||||
let c = &result.session.tracks[0].clips()[0];
|
||||
assert_eq!((c.start, c.length, c.source_offset()), (48000, 96000, 96000));
|
||||
assert_eq!((result.report.handles[0].before, result.report.handles[0].after), (96000, 288000));
|
||||
assert_eq!(result.session.timecode_start, 172800000);
|
||||
let back = Session::from_json(&result.session.to_json().unwrap()).unwrap();
|
||||
assert_eq!(back.tracks[0].clips()[0], *c);
|
||||
}
|
||||
#[test]
|
||||
fn adjacent_fractional_frame_boundaries_never_drift() {
|
||||
for n in 1..10000 {
|
||||
let a = Rational(n * 1001, 24000).samples(48000).unwrap();
|
||||
let b = Rational((n + 1) * 1001, 24000).samples(48000).unwrap();
|
||||
assert_eq!(b - a, 2002);
|
||||
}
|
||||
assert_eq!(Rational(1, 96000).samples(48000).unwrap(), 1);
|
||||
}
|
||||
#[test]
|
||||
fn fractional_sample_boundaries_use_absolute_endpoints() {
|
||||
let mut p = plan();
|
||||
p.sample_rate = 44100;
|
||||
p.sources[0].sample_rate = 44100;
|
||||
p.sources[0].frames = 4410000;
|
||||
p.tracks[0].clips = (0..1000)
|
||||
.map(|n| ImportClip {
|
||||
name: "frame".into(),
|
||||
source: "s".into(),
|
||||
start: Rational(n * 1001, 24000),
|
||||
end: Rational((n + 1) * 1001, 24000),
|
||||
offset: Rational(n * 1001, 24000),
|
||||
})
|
||||
.collect();
|
||||
let s = build_session(p).unwrap().session;
|
||||
let clips = s.tracks[0].clips();
|
||||
for pair in clips.windows(2) {
|
||||
assert_eq!(pair[0].end(), pair[1].start);
|
||||
}
|
||||
assert_eq!(clips[999].end(), 1839338);
|
||||
assert_eq!(clips.iter().map(|c| c.length).sum::<i64>(), 1839338);
|
||||
}
|
||||
#[test]
|
||||
fn invalid_windows_and_metadata_are_rejected() {
|
||||
let mut p = plan();
|
||||
p.tracks[0].clips[0].offset = Rational(9, 1);
|
||||
assert!(build_session(p).is_err());
|
||||
let mut p = plan();
|
||||
p.sources[0].sample_rate = 44100;
|
||||
assert!(build_session(p).is_err());
|
||||
assert!(Rational(1, 0).samples(48000).is_err());
|
||||
assert!(Rational(i64::MAX, 1).samples(48000).is_err());
|
||||
assert!(Rational(-1, 1).samples(48000).is_err());
|
||||
}
|
||||
#[test]
|
||||
fn stereo_names_and_order_are_preserved() {
|
||||
let mut p = plan();
|
||||
p.sources[0].channels = 2;
|
||||
p.tracks[0].channels = 2;
|
||||
p.tracks.push(ImportTrack { name: "DX".into(), channels: 1, clips: vec![] });
|
||||
let s = build_session(p).unwrap().session;
|
||||
assert_eq!(s.tracks.iter().map(|t| t.name.as_str()).collect::<Vec<_>>(), vec!["DX", "DX"]);
|
||||
assert_eq!(s.tracks[0].channels(), 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
//! Session-data import UI. File parsing goes through engine commands; successful insertion is
|
||||
//! a single undoable command. Nothing in this window replaces or saves the active document.
|
||||
use crate::SoundApp;
|
||||
use egui::{RichText, ScrollArea};
|
||||
use serde_json::{Value, json};
|
||||
use std::sync::mpsc::{self, Receiver};
|
||||
|
||||
pub struct ImportState {
|
||||
pub open: bool,
|
||||
pub path: String,
|
||||
pub media_dir: String,
|
||||
/// CompositionMob to read when the AAF holds several; empty lets the reader require one.
|
||||
composition: String,
|
||||
/// (name, MobID) choices reported by the reader for a multi-composition AAF.
|
||||
compositions: Vec<(String, String)>,
|
||||
preview: Option<Value>,
|
||||
selected: Vec<bool>,
|
||||
filter: String,
|
||||
absolute: bool,
|
||||
offset: String,
|
||||
error: Option<String>,
|
||||
busy: Option<Receiver<Result<Value, String>>>,
|
||||
pending: bool,
|
||||
report: Option<Value>,
|
||||
}
|
||||
impl Default for ImportState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
open: false,
|
||||
path: String::new(),
|
||||
media_dir: String::new(),
|
||||
composition: String::new(),
|
||||
compositions: Vec::new(),
|
||||
preview: None,
|
||||
selected: Vec::new(),
|
||||
filter: String::new(),
|
||||
absolute: true,
|
||||
offset: "0".into(),
|
||||
error: None,
|
||||
busy: None,
|
||||
pending: false,
|
||||
report: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ImportState {
|
||||
pub fn set_path(&mut self, path: String) {
|
||||
self.media_dir = std::path::Path::new(&path).parent().map_or(String::new(), |p| p.display().to_string());
|
||||
self.path = path;
|
||||
self.composition.clear();
|
||||
self.compositions.clear();
|
||||
self.invalidate();
|
||||
}
|
||||
/// A typed path is a different file: forget its compositions, and follow it with the media
|
||||
/// folder unless the user pointed that folder somewhere other than the previous AAF's folder.
|
||||
fn path_edited(&mut self, previous: &str) {
|
||||
let parent = |p: &str| std::path::Path::new(p).parent().map_or(String::new(), |d| d.display().to_string());
|
||||
if self.media_dir == parent(previous) {
|
||||
self.media_dir = parent(&self.path);
|
||||
}
|
||||
self.composition.clear();
|
||||
self.compositions.clear();
|
||||
self.invalidate();
|
||||
}
|
||||
/// Drops the current preview and any analysis still running, whose plan would belong to the
|
||||
/// previous file or folder. The worker's late result goes to a closed channel.
|
||||
fn invalidate(&mut self) {
|
||||
self.preview = None;
|
||||
self.busy = None;
|
||||
self.error = None;
|
||||
}
|
||||
pub fn inspect(&self) -> Value {
|
||||
json!({"open":self.open,"path":self.path,"media_dir":self.media_dir,"busy":self.busy.is_some(),"preview":self.preview,"selected":self.selected,"error":self.error,"report":self.report})
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn analyze(&mut self, ctx: &egui::Context) {
|
||||
if self.busy.is_some() {
|
||||
return;
|
||||
}
|
||||
self.error = None;
|
||||
self.preview = None;
|
||||
let path = self.path.clone();
|
||||
let media = self.media_dir.clone();
|
||||
let mut params = json!({"path":path,"media_dir":media});
|
||||
if !self.composition.is_empty() {
|
||||
params["composition"] = json!(self.composition);
|
||||
}
|
||||
let roots = soundcraft_engine::file_access::current();
|
||||
let ctx = ctx.clone();
|
||||
let (tx, rx) = mpsc::channel();
|
||||
self.busy = Some(rx);
|
||||
std::thread::spawn(move || {
|
||||
let result = soundcraft_engine::file_access::confine(roots.as_ref(), || {
|
||||
soundcraft_engine::Engine::default().execute("file.preview_aaf", ¶ms).map_err(|e| e.to_string())
|
||||
});
|
||||
let _ = tx.send(result);
|
||||
ctx.request_repaint();
|
||||
});
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn analyze(&mut self, _: &egui::Context) {
|
||||
self.error = Some("AAF import needs the desktop app: its media files are read from a local folder".into());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn command(app: &mut SoundApp, p: &Value) -> Result<Value, String> {
|
||||
if let Some(path) = p.get("path").and_then(Value::as_str) {
|
||||
app.aaf_import.set_path(path.to_string());
|
||||
}
|
||||
if let Some(dir) = p.get("media_dir").and_then(Value::as_str) {
|
||||
app.aaf_import.media_dir = dir.to_string();
|
||||
app.aaf_import.invalidate();
|
||||
}
|
||||
app.aaf_import.open = true;
|
||||
Ok(app.aaf_import.inspect())
|
||||
}
|
||||
|
||||
pub fn show(app: &mut SoundApp, ctx: &egui::Context) {
|
||||
let mut state = std::mem::take(&mut app.aaf_import);
|
||||
if let Some(rx) = &state.busy {
|
||||
let result = rx.try_recv();
|
||||
match result {
|
||||
Ok(Ok(preview)) => {
|
||||
state.selected = vec![true; preview.get("tracks").and_then(Value::as_array).map_or(0, Vec::len)];
|
||||
state.preview = Some(preview);
|
||||
state.busy = None;
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
let choices = composition_choices(&e);
|
||||
if !choices.is_empty() {
|
||||
state.compositions = choices;
|
||||
}
|
||||
state.error = Some(e);
|
||||
state.busy = None;
|
||||
}
|
||||
Err(mpsc::TryRecvError::Disconnected) => {
|
||||
state.error = Some("AAF reader stopped unexpectedly".into());
|
||||
state.busy = None;
|
||||
}
|
||||
Err(mpsc::TryRecvError::Empty) => {
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(50));
|
||||
}
|
||||
}
|
||||
}
|
||||
if state.pending {
|
||||
state.pending = false;
|
||||
let indices: Vec<_> = state.selected.iter().enumerate().filter_map(|(i, on)| on.then_some(i)).collect();
|
||||
let params = json!({"plan":state.preview.as_ref().and_then(|v|v.get("plan")),"media_dir":state.media_dir,"selected":indices,"media":"copy","mapping":if state.absolute{"absolute"}else{"relative"},"offset_samples":state.offset.parse::<i64>().ok()});
|
||||
match app.run("file.import_aaf", params) {
|
||||
Ok(v) => {
|
||||
state.report = Some(v);
|
||||
state.open = false;
|
||||
app.ui.status = "AAF imported as new editable tracks. Save the session to collect copied media.".into();
|
||||
}
|
||||
Err(e) => state.error = Some(e),
|
||||
}
|
||||
}
|
||||
if state.open {
|
||||
let mut open = true;
|
||||
egui::Window::new("Import Session Data — AAF").id(egui::Id::unique("import_aaf")).open(&mut open).default_size([1080.0,690.0]).min_size([850.0,560.0]).show(ctx,|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("AAF file");
|
||||
let before=state.path.clone();
|
||||
let edited=ui.add_enabled(state.busy.is_none(),egui::TextEdit::singleline(&mut state.path).desired_width((ui.available_width()-200.0).max(200.0))).changed();
|
||||
if edited { state.path_edited(&before); }
|
||||
if ui.add_enabled(state.busy.is_none(),egui::Button::new("Browse…")).clicked()
|
||||
&& let Some(path)=app.services.pick_open.as_ref().and_then(|pick|pick("file.import_aaf",&["aaf"])) {
|
||||
match crate::dialogs::unicode(&path) { Ok(p)=>state.set_path(p.to_string()), Err(e)=>state.error=Some(e.to_string()) }
|
||||
}
|
||||
if ui.add_enabled(state.busy.is_none()&&!state.path.is_empty()&&!state.media_dir.is_empty(),egui::Button::new("Analyze AAF")).clicked() { state.analyze(ctx); }
|
||||
});
|
||||
if state.busy.is_some() { ui.horizontal(|ui|{ui.spinner();ui.label("Reading source properties and locating media…");}); }
|
||||
if !state.compositions.is_empty() {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Composition");
|
||||
let current=state.compositions.iter().find(|(_,id)|*id==state.composition).map_or("Choose one…".to_string(),|(n,_)|n.clone());
|
||||
// Locked while analyzing, so a finished analysis always matches the selection.
|
||||
ui.add_enabled_ui(state.busy.is_none(),|ui|{
|
||||
craft_ui::ComboBox::from_id_salt("aaf_composition").selected_text(current).show_ui(ui,|ui|{
|
||||
for (name,id) in &state.compositions {
|
||||
if ui.selectable_label(state.composition==*id,format!("{name} ({id})")).clicked() { state.composition=id.clone(); state.preview=None; }
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
if let Some(error)=&state.error { ui.colored_label(ui.visuals().error_fg_color,error); }
|
||||
ui.separator();
|
||||
let preview=state.preview.clone();
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(300.0);
|
||||
ui.group(|ui| {
|
||||
ui.label(RichText::new("Source Properties").strong());
|
||||
if let Some(p)=&preview {
|
||||
ui.label(format!("Name: {}",p["name"].as_str().unwrap_or("")));
|
||||
ui.label("Type: AAF • external PCM WAV");
|
||||
ui.label(format!("Start: {}",p["start_timecode"].as_str().unwrap_or("")));
|
||||
ui.label(format!("Frame rate: {} fps",p["frame_rate"].as_str().unwrap_or("")));
|
||||
ui.label(format!("Sample rate: {} Hz",p["sample_rate"]));
|
||||
ui.label(format!("Source files: {}",p["sources"]));
|
||||
} else { ui.label("Choose an AAF and analyze it to preview the montage."); }
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
ui.group(|ui| {
|
||||
ui.label(RichText::new("Media Options").strong());
|
||||
ui.label("Locate source WAV files in:");
|
||||
if ui.add_enabled(state.busy.is_none(),egui::TextEdit::singleline(&mut state.media_dir).desired_width(275.0)).changed(){state.preview=None;}
|
||||
if ui.add_enabled(state.busy.is_none(),egui::Button::new("Choose media folder…")).clicked()
|
||||
&& let Some(dir)=app.services.pick_folder.as_ref().and_then(|pick|pick(std::path::Path::new(&state.media_dir))){
|
||||
match crate::dialogs::unicode(&dir) { Ok(d)=>{state.media_dir=d.to_string();state.invalidate();} Err(e)=>state.error=Some(e.to_string()) }
|
||||
}
|
||||
ui.label("Copy full sources when saving");
|
||||
ui.small("Save the session before moving or removing original files.");
|
||||
ui.small("All available handles are retained. Sources are not consolidated or trimmed.");
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
ui.group(|ui| {
|
||||
ui.label(RichText::new("Timecode Mapping").strong());
|
||||
ui.radio_value(&mut state.absolute,true,"Maintain absolute timecode");
|
||||
ui.radio_value(&mut state.absolute,false,"Relative to session start");
|
||||
ui.horizontal(|ui|{ui.label("Offset (samples)");ui.add(egui::TextEdit::singleline(&mut state.offset).desired_width(110.0));});
|
||||
ui.small(format!("Destination: {} Hz • {} fps",app.engine.session().sample_rate.hz(),app.engine.session().frame_rate.label()));
|
||||
ui.small("An empty destination adopts the source rate and timecode. No sample-rate conversion.");
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
ui.label(RichText::new("Initial import scope").strong());
|
||||
ui.small("New tracks and editable clips. Clip gain, automation, parametric fades, video, plugins and routing are not transferred. Existing playlists are not replaced.");
|
||||
});
|
||||
ui.add_space(12.0);
|
||||
ui.vertical(|ui| {
|
||||
ui.set_min_width(450.0);
|
||||
ui.horizontal(|ui|{
|
||||
ui.label("Tracks");ui.text_edit_singleline(&mut state.filter);
|
||||
if ui.button("All").clicked(){state.selected.fill(true);}
|
||||
if ui.button("Clear").clicked(){state.selected.fill(false);}
|
||||
});
|
||||
ui.separator();
|
||||
ScrollArea::vertical().id_salt("aaf_tracks").max_height(400.0).show(ui,|ui| {
|
||||
egui::Grid::new("aaf_track_table").striped(true).min_col_width(120.0).show(ui,|ui|{
|
||||
ui.strong("Import / Source");ui.strong("Clips");ui.strong("Destination");ui.end_row();
|
||||
if let Some(tracks)=preview.as_ref().and_then(|p|p["tracks"].as_array()) {
|
||||
for (i,t) in tracks.iter().enumerate() {
|
||||
let name=t["name"].as_str().unwrap_or("");
|
||||
if !name.to_lowercase().contains(&state.filter.to_lowercase()){continue;}
|
||||
let label=format!("{} ({})",name,if t["channels"].as_u64()==Some(2){"Stereo"}else{"Mono"});
|
||||
if let Some(on)=state.selected.get_mut(i){ui.checkbox(on,label);}else{ui.label(label);}
|
||||
ui.label(t["clips"].to_string());ui.label("New Track");ui.end_row();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
let warnings=preview.as_ref().and_then(|p|p["warnings"].as_array());
|
||||
ui.collapsing(format!("Compatibility and media report ({} notices)",warnings.map_or(0,Vec::len)),|ui|{
|
||||
ScrollArea::vertical().id_salt("aaf_warnings").max_height(130.0).show(ui,|ui|{
|
||||
if let Some(warnings)=warnings {for w in warnings{ui.small(w.as_str().unwrap_or(""));}}
|
||||
});
|
||||
});
|
||||
ui.label(format!("{} tracks selected",state.selected.iter().filter(|x|**x).count()));
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Cancel").clicked(){state.open=false;}
|
||||
let ready=state.preview.is_some() && state.busy.is_none() && state.selected.iter().any(|x|*x) && state.offset.parse::<i64>().is_ok() && !app.engine.transport.playing && !app.engine.transport.recording;
|
||||
if ui.add_enabled(ready,egui::Button::new("Import")).clicked(){state.pending=true;ctx.request_repaint();}
|
||||
if app.engine.transport.playing || app.engine.transport.recording {ui.label("Stop transport before importing.");}
|
||||
if state.pending {ui.spinner();ui.label("Preparing media and new tracks…");}
|
||||
});
|
||||
});
|
||||
if !open {
|
||||
state.open = false;
|
||||
}
|
||||
}
|
||||
if let Some(report) = &state.report {
|
||||
let mut open = true;
|
||||
egui::Window::new("AAF Import Report").id(egui::Id::unique("aaf_import_report")).open(&mut open).default_size([640.0, 400.0]).show(
|
||||
ctx,
|
||||
|ui| {
|
||||
ui.heading("Session data imported");
|
||||
ui.label(format!("{} new tracks • {} complete sources", report["tracks"].as_array().map_or(0, Vec::len), report["sources"]));
|
||||
ui.label("Clips remain editable. Use Save Session to collect copied media.");
|
||||
if ui.button("Go to first imported clip").clicked()
|
||||
&& let Some(at) = report["first_clip_sample"].as_i64()
|
||||
{
|
||||
let _ = app.run("transport.locate", json!({"at":at}));
|
||||
}
|
||||
if ui.button("Copy complete report").clicked() {
|
||||
ctx.copy_text(serde_json::to_string_pretty(report).unwrap_or_default());
|
||||
}
|
||||
ScrollArea::vertical().max_height(300.0).show(ui, |ui| {
|
||||
if let Some(warnings) = report["warnings"].as_array() {
|
||||
for w in warnings {
|
||||
ui.label(w.as_str().unwrap_or(""));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
if !open {
|
||||
state.report = None;
|
||||
}
|
||||
}
|
||||
app.aaf_import = state;
|
||||
}
|
||||
|
||||
/// (name, MobID) pairs from the reader's "Choose exactly one composition" error, so the window
|
||||
/// can offer a choice instead of asking for an ID it gives no way to enter.
|
||||
fn composition_choices(error: &str) -> Vec<(String, String)> {
|
||||
let Some(list) = error.split_once("Choose exactly one composition by MobID: ").map(|(_, l)| l) else { return Vec::new() };
|
||||
list.split("(\"")
|
||||
.filter_map(|entry| {
|
||||
let (name, rest) = entry.split_once("\", \"")?;
|
||||
let id = rest.split('"').next()?;
|
||||
id.starts_with("urn:smpte:umid:").then(|| (name.to_string(), id.to_string()))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn several_compositions_become_choices() {
|
||||
let e = r#"io: interchange: Choose exactly one composition by MobID: [("Reel 1", "urn:smpte:umid:060a2b34.01"), ("Alt cut", "urn:smpte:umid:060a2b34.02")]"#;
|
||||
assert_eq!(
|
||||
composition_choices(e),
|
||||
[("Reel 1".to_string(), "urn:smpte:umid:060a2b34.01".to_string()), ("Alt cut".to_string(), "urn:smpte:umid:060a2b34.02".to_string())]
|
||||
);
|
||||
assert!(composition_choices("Missing media: x.wav").is_empty());
|
||||
}
|
||||
#[test]
|
||||
fn a_new_file_discards_the_analysis_still_running_for_the_previous_one() {
|
||||
let mut state = ImportState::default();
|
||||
let (tx, rx) = mpsc::channel();
|
||||
state.set_path("/a/first.aaf".into());
|
||||
state.busy = Some(rx);
|
||||
state.set_path("/b/second.aaf".into());
|
||||
assert!(state.busy.is_none());
|
||||
assert!(tx.send(Ok(json!({"plan": {}}))).is_err());
|
||||
assert!(state.preview.is_none());
|
||||
assert_eq!(state.media_dir, "/b");
|
||||
}
|
||||
#[test]
|
||||
fn a_typed_path_moves_the_derived_media_folder_but_keeps_a_chosen_one() {
|
||||
let mut state = ImportState::default();
|
||||
state.set_path("/a/first.aaf".into());
|
||||
state.composition = "urn:smpte:umid:01".into();
|
||||
state.path = "/b/second.aaf".into();
|
||||
state.path_edited("/a/first.aaf");
|
||||
assert_eq!(state.media_dir, "/b");
|
||||
assert!(state.composition.is_empty());
|
||||
state.media_dir = "/media/elsewhere".into();
|
||||
state.path = "/c/third.aaf".into();
|
||||
state.path_edited("/b/second.aaf");
|
||||
assert_eq!(state.media_dir, "/media/elsewhere");
|
||||
}
|
||||
#[test]
|
||||
fn menu_opens_preview_but_programmatic_import_does_not_open_a_dialog() {
|
||||
let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, crate::Services::default());
|
||||
assert!(app.run("file.import_aaf", json!({})).is_err());
|
||||
assert!(!app.aaf_import.open);
|
||||
crate::menus::invoke_menu(&mut app, "file.import_aaf", "File > Import > Session Data...");
|
||||
assert!(app.aaf_import.open);
|
||||
assert!(app.engine.session().tracks.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,9 @@ use super::services::Services;
|
||||
use super::state::MainWindow;
|
||||
use super::{
|
||||
ControlRequest, Engine, Gesture, HashMap, MeterDisplay, OutputTrouble, Player, Range, Receiver, Samples, SoundApp, TrackId, TransportRequest,
|
||||
Trouble, UiState, Value, VecDeque, bounce, dialogs, edit_window, extra_windows, fonts, import, json, menus, midi_editor, mix_window, ops_windows,
|
||||
palette, panels, preferences, recovery, sampler_window, score_editor, shortcuts, theme, updates_ui, video_track, video_window, windows,
|
||||
Trouble, UiState, Value, VecDeque, aaf_import, bounce, dialogs, edit_window, extra_windows, fonts, import, json, menus, midi_editor, mix_window,
|
||||
ops_windows, palette, panels, preferences, recovery, sampler_window, score_editor, shortcuts, theme, updates_ui, video_track, video_window,
|
||||
windows,
|
||||
};
|
||||
|
||||
mod audio;
|
||||
@@ -61,6 +62,7 @@ impl SoundApp {
|
||||
preset_dir: None,
|
||||
last_autosave: None,
|
||||
dialogs: dialogs::Dialogs::default(),
|
||||
aaf_import: aaf_import::ImportState::default(),
|
||||
updates_rt: updates_ui::Runtime::default(),
|
||||
meters: HashMap::new(),
|
||||
main_meter: MeterDisplay::default(),
|
||||
@@ -352,6 +354,7 @@ impl SoundApp {
|
||||
score_editor::show(self, &ctx);
|
||||
palette::show(self, &ctx);
|
||||
dialogs::show(self, &ctx);
|
||||
aaf_import::show(self, &ctx);
|
||||
updates_ui::show(self, &ctx);
|
||||
// The sampler's drop rects are current now, so route any captured drop in this pass.
|
||||
self.route_dropped_files();
|
||||
|
||||
@@ -45,7 +45,7 @@ pub fn unicode(path: &std::path::Path) -> Result<&str, NotUnicode> {
|
||||
}
|
||||
|
||||
/// Opens a dropped, picked or command-line file by its extension: a session opens (asking to save
|
||||
/// first), MIDI imports, and anything else imports as audio, decoded in the background so a long
|
||||
/// first), an AAF opens the Session Data window, MIDI imports, and anything else imports as audio, decoded in the background so a long
|
||||
/// file doesn't freeze the window (#597). A name that is not valid Unicode goes on the status line.
|
||||
pub fn open_path(app: &mut SoundApp, path: &std::path::Path) {
|
||||
let p = match unicode(path) {
|
||||
@@ -59,6 +59,8 @@ pub fn open_path(app: &mut SoundApp, path: &std::path::Path) {
|
||||
let lower = p.to_ascii_lowercase();
|
||||
let r = if lower.ends_with(".scraft") {
|
||||
run_or_ask(app, "session.open", json!({"path": p}))
|
||||
} else if lower.ends_with(".aaf") {
|
||||
app.run("window.import_aaf", json!({"path": p}))
|
||||
} else if lower.ends_with(".mid") || lower.ends_with(".midi") || lower.ends_with(".smf") {
|
||||
app.run("file.import_midi", json!({"path": p}))
|
||||
} else {
|
||||
|
||||
@@ -13,6 +13,7 @@ pub const UPDATE_APP: craft_update::app::App = craft_update::app::App {
|
||||
..craft_update::suite::SOUNDCRAFT
|
||||
};
|
||||
|
||||
pub mod aaf_import;
|
||||
pub mod appearance;
|
||||
pub mod bounce;
|
||||
pub mod control;
|
||||
@@ -329,6 +330,7 @@ pub struct SoundApp {
|
||||
pub preset_dir: Option<std::path::PathBuf>,
|
||||
last_autosave: Option<std::time::Instant>,
|
||||
pub dialogs: dialogs::Dialogs,
|
||||
pub aaf_import: aaf_import::ImportState,
|
||||
pub(crate) updates_rt: updates_ui::Runtime,
|
||||
pub meters: HashMap<TrackId, MeterDisplay>,
|
||||
pub main_meter: MeterDisplay,
|
||||
|
||||
@@ -68,6 +68,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, Option<&str>)] = &[
|
||||
("window.time_ops", "Time Operations", "", None),
|
||||
("window.midi_ops", "MIDI Operations", "", None),
|
||||
("window.rtp", "MIDI Real-Time Properties", "", None),
|
||||
("window.import_aaf", "Import Session Data (AAF)", "", None),
|
||||
("window.playback_engine", "Playback Engine", "", None),
|
||||
("ui.audio_device", "Audio Device", "", None),
|
||||
("window.io_setup", "I/O Setup", "", None),
|
||||
@@ -524,6 +525,7 @@ fn params_for(path: &str, id: &str) -> Value {
|
||||
/// Menu items that open a SoundCraft window when clicked (programmatic calls still run the command).
|
||||
const MENU_WINDOWS: &[(&str, &str)] = &[
|
||||
("Setup > Appearance", "window.ui_customization"),
|
||||
("File > Import > Session Data...", "file.import_aaf"),
|
||||
("Setup > Hardware...", "window.playback_engine"),
|
||||
("Setup > Playback Engine...", "window.playback_engine"),
|
||||
("Setup > MIDI > MIDI Input Devices...", "window.playback_engine"),
|
||||
@@ -560,6 +562,10 @@ pub fn live_label(app: &SoundApp, id: Option<&str>) -> Option<String> {
|
||||
|
||||
/// Menu-style invocation: may open a dialog.
|
||||
pub fn invoke_menu(app: &mut SoundApp, id: &str, path: &str) {
|
||||
if id == "file.import_aaf" || path == "File > Import > Session Data..." {
|
||||
let _ = crate::aaf_import::command(app, &json!({}));
|
||||
return;
|
||||
}
|
||||
if id == "setup.preferences" {
|
||||
let _ = app.run(id, json!({"value": true}));
|
||||
return;
|
||||
@@ -594,6 +600,10 @@ pub fn invoke_menu(app: &mut SoundApp, id: &str, path: &str) {
|
||||
/// Keyboard shortcut for a dialog command, or one that would close a modified session: open its
|
||||
/// dialog. Returns true when handled.
|
||||
pub fn invoke_shortcut_dialog(app: &mut SoundApp, id: &str) -> bool {
|
||||
if id == "file.import_aaf" {
|
||||
let _ = crate::aaf_import::command(app, &json!({}));
|
||||
return true;
|
||||
}
|
||||
(wants_dialog(id) && app.dialogs.open_for_command(&app.engine, id)) || crate::dialogs::ask_to_save(app, id, &json!({}))
|
||||
}
|
||||
|
||||
@@ -604,6 +614,9 @@ fn wants_dialog(id: &str) -> bool {
|
||||
|
||||
/// Handle UI-layer commands. Returns None when `id` is not a UI command.
|
||||
pub fn run_ui_command(app: &mut SoundApp, id: &str, p: &Value) -> Option<Result<Value, String>> {
|
||||
if id == "window.import_aaf" {
|
||||
return Some(crate::aaf_import::command(app, p));
|
||||
}
|
||||
if matches!(id, "ui.dock" | "ui.dock.reset") {
|
||||
return Some(crate::docking::command(app, id, p));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# File-format parity
|
||||
|
||||
> **Last reviewed:** 2026-10-19 · **Last updated:** 2026-11-11 · **Change:** minor (audio formats come from craft-audio; previously trivial: bounces carry a BWF time reference, #1296) · **Target:** Avid Pro Tools Ultimate 2026.4.1
|
||||
> **Last reviewed:** 2026-11-14 · **Last updated:** 2026-11-14 · **Change:** minor (strict external-WAV AAF import; previously minor: audio formats come from craft-audio) · **Target:** Avid Pro Tools Ultimate 2026.4.1
|
||||
|
||||
Every format Pro Tools reads or writes, and ours. The Pro Tools list comes from the document types
|
||||
its bundle declares (`CFBundleDocumentTypes` in Info.plist: names only, nothing else read) and its
|
||||
@@ -9,7 +9,7 @@ documented import/bounce options. Ours comes from `craft-audio` in craft-libs (`
|
||||
`crates/engine/src/score.rs`, `crates/engine/src/clip_group_file.rs` and `crates/video`.
|
||||
|
||||
**File formats: ~40 % ready** (estimated: weighted by how often a Pro Tools user hits each row;
|
||||
session interchange carries a third of the weight and is at 0 %). Remaining ≈ 70–120 h.
|
||||
session interchange carries a third of the weight and has only a strict AAF import subset). Remaining ≈ 70–120 h.
|
||||
|
||||
Legend: ✅ supported and tested · 🟡 partial · ❌ missing · — not applicable.
|
||||
|
||||
@@ -19,7 +19,7 @@ Legend: ✅ supported and tested · 🟡 partial · ❌ missing · — not appli
|
||||
|---|---|---|---|---|
|
||||
| Pro Tools session `.ptx` (and `.ptf` from 7–9) | native | ❌ | ❌ | Proprietary, undocumented. Owner decision needed on black-box format study (G-03) |
|
||||
| Session templates `.ptxt` | read/write | ❌ | ❌ | We have no templates at all (G-16) |
|
||||
| AAF (Advanced Authoring Format) | import/export | ❌ | ❌ | #40. The post-production handoff from picture editors (G-03) |
|
||||
| AAF (Advanced Authoring Format) | import/export | 🟡 | ❌ | #40. Strict subset: CompositionMob SourceClip/Filler edits with external mono/stereo PCM WAV; editable clips, handles, relink and timecode mapping. Gain, fades, transitions, embedded essence, split channels, mixed rates and export are unsupported (G-03) |
|
||||
| OMF | import/export | ❌ | ❌ | Legacy, still delivered by some editors |
|
||||
| Media Composer–compatible session | export | ❌ | ❌ | AAF variant |
|
||||
| ADM BWF (Dolby Atmos master) | import/export | ❌ | ❌ | G-12 |
|
||||
@@ -81,6 +81,7 @@ Legend: ✅ supported and tested · 🟡 partial · ❌ missing · — not appli
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-14 | minor | Strict external-WAV AAF import with editable clips, relink and timecode mapping; export and the wider AAF/OMF feature set remain unsupported; readiness estimate unchanged |
|
||||
| 2026-11-11 | minor | Audio formats come from `craft-audio` (craft-libs); `crates/audio-io` is gone. New on import: Opus, AC-3/E-AC-3, `.mov`/`.mka` audio; AAC, ALAC and MP2 no longer go through symphonia; `.aifc` is a writable name |
|
||||
| 2026-11-02 | trivial | WAV bounces (mix and stems) write a `bext` TimeReference: session timecode start plus bounce start (#1296) |
|
||||
| 2026-10-19 | trivial | WAV and AIFF-C Float32 encoders retain finite headroom (#791); whole-file, streaming and bounce regression tests |
|
||||
|
||||
+12
-6
@@ -1,6 +1,6 @@
|
||||
# Where SoundCraft falls short of Pro Tools
|
||||
|
||||
> **Last reviewed:** 2026-10-25 · **Last updated:** 2026-11-18 · **Change:** minor (G-02 shrunk: MIDI input devices work; previously minor: G-05: plugin editors on Linux/X11; previously trivial: G-09: the pt-BR catalog now covers helper-passed tooltips, the status bar, the remove-session prompt and engine error text; G-08: Frequency Shifter, 28 processors; G-04: volume automation read at every sample, #1354; G-01: `setup.playback_engine` applies the device buffer in the desktop app; G-04: Clip Looping crossfade and loop count) · **Target:** Avid Pro Tools Ultimate 2026.4.1
|
||||
> **Last reviewed:** 2026-11-14 · **Last updated:** 2026-11-18 · **Change:** minor (G-02 shrunk: MIDI input devices work; G-03: strict external-WAV AAF import; previously minor: G-05: plugin editors on Linux/X11; previously trivial: G-09: the pt-BR catalog now covers helper-passed tooltips, the status bar, the remove-session prompt and engine error text; G-08: Frequency Shifter, 28 processors; G-04: volume automation read at every sample, #1354; G-01: `setup.playback_engine` applies the device buffer in the desktop app; G-04: Clip Looping crossfade and loop count) · **Target:** Avid Pro Tools Ultimate 2026.4.1
|
||||
|
||||
Every known shortfall, one entry each, ranked by how much it stops a Pro Tools user from doing
|
||||
real work in SoundCraft. This is the work list: pick from the top. Rows marked **alpha blocker**
|
||||
@@ -17,7 +17,7 @@ When you close a gap, delete its entry (or shrink it) in the same PR, and bump t
|
||||
|---|---|---|---|---:|
|
||||
| G-01 | **Alpha blocker.** No channel routing or duplex low-latency path (device, rate and buffer choice done; ASIO opt-in) | Hardware | [hardware-parity.md](hardware-parity.md) | 15–25 |
|
||||
| G-02 | **Alpha blocker.** MIDI devices: input works (checked on Linux only); no output, clock or loop/merge recording | Hardware / MIDI | [hardware-parity.md](hardware-parity.md) | 12–22 |
|
||||
| G-03 | **Alpha blocker.** Cannot exchange sessions with Pro Tools (no AAF/OMF, no `.ptx`) | File formats | [file-format-parity.md](file-format-parity.md) | 50–90 |
|
||||
| G-03 | **Alpha blocker.** Session exchange remains incomplete (strict external-WAV AAF import only; no AAF/OMF export, OMF import or `.ptx`) | File formats | [file-format-parity.md](file-format-parity.md) | 50–90 |
|
||||
| G-04 | Open correctness bugs in features counted as done (~25 issues) | Stability | this file | 25–40 |
|
||||
| G-05 | (Entitlement part: alpha blocker for the mix row) Third-party VST3s blocked in the signed macOS build; AU editors missing | Ecosystem | [plugin-parity.md](plugin-parity.md) | 10–15 |
|
||||
| G-06 | (Record-to-disk part: alpha blocker for the tracking row) Sources decoded whole into RAM; recording into RAM | Performance | [hardware-parity.md](hardware-parity.md) | 15–25 |
|
||||
@@ -84,10 +84,15 @@ When you close a gap, delete its entry (or shrink it) in the same PR, and bump t
|
||||
|
||||
### G-03. Session interchange with Pro Tools
|
||||
|
||||
- **Missing:** opening or saving `.ptx`/`.ptf`, AAF and OMF import and export (#40), Media
|
||||
Composer–compatible sessions. Our session format is `.scraft` JSON.
|
||||
- **Impact:** a main-format requirement for beta. A Pro Tools user cannot bring a project in
|
||||
or hand one back; post-production (picture editors deliver AAF) is blocked.
|
||||
- **Done (2026-11-14):** strict AAF import for CompositionMob SourceClip/Filler edits with external
|
||||
mono/stereo PCM WAV media. It creates editable clips with source handles, relink and absolute or
|
||||
relative timecode mapping. The reader bounds cached property data to 128 MiB and rejects duplicate
|
||||
local references before expanding objects.
|
||||
- **Missing:** gain, fades, transitions, embedded essence, split channels and mixed sample rates in
|
||||
AAF; AAF export; OMF import and export; opening or saving `.ptx`/`.ptf`; Media
|
||||
Composer–compatible sessions (#40). Our session format is `.scraft` JSON.
|
||||
- **Impact:** a main-format requirement for beta. Only the strict AAF subset can come in; other AAFs
|
||||
and handing a session back remain blocked for post-production interchange.
|
||||
- **Estimate:** AAF/OMF import + export ≈ 50–90 h (FilmCraft already writes AAF/OMF; we can learn
|
||||
from it but not share code). `.ptx` is proprietary and undocumented: owner decision on whether
|
||||
black-box format study is in the clean-room rules; not included in the estimate.
|
||||
@@ -247,6 +252,7 @@ missing. Out of scope unless the owner decides otherwise.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-14 | minor | G-03: strict external-WAV AAF import with bounded property caching; AAF/OMF export, OMF import and `.ptx` remain; estimates unchanged |
|
||||
| 2026-11-13 | trivial | G-09: the pt-BR catalog now covers tooltips localized inside buttons and toggles, the Edit-window status bar, the remove-session question, the send help text and engine errors shown in the status line; estimates unchanged |
|
||||
| 2026-11-09 | trivial | G-08: 28 processors + 3 instruments with the Frequency Shifter |
|
||||
| 2026-11-04 | trivial | G-04: track and master volume automation read at every sample, so breakpoints act on their own sample in any block size (#1354); estimates unchanged |
|
||||
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
# SoundCraft roadmap: milestones and what's next
|
||||
|
||||
> **Last reviewed:** 2026-11-05 · **Last updated:** 2026-11-18 · **Change:** minor (MIDI input landed, the gate row needs checking on macOS and Windows; previously trivial: 28 built-in processors with the Frequency Shifter; previously trivial: G-05 estimate after Linux/X11 plugin editors; previously trivial: M15: partial pt-BR catalog in PR #1346) · **Target:** Avid Pro Tools Ultimate 2026.4.1
|
||||
> **Last reviewed:** 2026-11-14 · **Last updated:** 2026-11-18 · **Change:** minor (MIDI input landed, the gate row needs checking on macOS and Windows; strict external-WAV AAF import; previously trivial: 28 built-in processors with the Frequency Shifter; G-05 estimate after Linux/X11 plugin editors; M15: partial pt-BR catalog; readiness estimates unchanged) · **Target:** Avid Pro Tools Ultimate 2026.4.1
|
||||
|
||||
Forward-looking plan. Status and numbers: [`../ROADMAP.md`](../ROADMAP.md) and
|
||||
[`target-app-parity.md`](target-app-parity.md); the ranked work list: [`gaps.md`](gaps.md).
|
||||
@@ -27,7 +27,7 @@ main platform). Any **no** keeps SoundCraft **pre-alpha**, and those rows are th
|
||||
| Edit: select, trim, fade, comp playlists, Slip/Shuffle/Grid | yes (rough) | Every Edit menu command; property-tested with undo; open bugs #3, #5, #140 don't block the workflow | — |
|
||||
| Mix with built-in and third-party plugins, sends, busses, automation | partial (passes on CLAP/AU) | 28 built-in processors; CLAP and AU host on the signed macOS build, but its missing entitlement blocks third-party VST3 (#153). No AU plugin windows yet; VST3 windows on macOS, Windows and Linux/X11 | 1–2 (entitlement) |
|
||||
| Bounce mix and stems; save and reopen the session | yes (rough) | WAV/BWF/AIFF/FLAC bounce, stems, `.scraft` save/reopen with plugin state; bugs #59, #103 in bus bounce and aux latency (PRs open) | — |
|
||||
| Exchange a session with Pro Tools or a picture editor | **no** | No `.ptx`, AAF or OMF import or export (#40, G-03) | 50–90 |
|
||||
| Exchange a session with Pro Tools or a picture editor | **no** | Strict external-WAV AAF import works, but AAF export, OMF and `.ptx` do not (#40, G-03) | 50–90 |
|
||||
|
||||
**Result: pre-alpha.** Three workflows fail. Passing them is ~110–180 h, about 70 % of it
|
||||
parallelizable (interfaces, MIDI and AAF are independent crates).
|
||||
@@ -47,7 +47,7 @@ Status: ✅ done · 🟡 in progress · ⬜ not started.
|
||||
| M10 | Public releases on all platforms | ✅ v0.3.0 (2026-10-08) and v0.4.0 (2026-10-10) released for every platform | — |
|
||||
| M11 | Third-party plugin hosting (CLAP, VST3, AU), video, surround | 🟡 mostly done | 40–60 |
|
||||
| M12 | **Hardware**: audio interfaces, MIDI devices, sync, control surfaces | ⬜ | 110–180 |
|
||||
| M13 | **Interchange**: AAF/OMF import/export, disk streaming, record to disk | ⬜ | 65–115 |
|
||||
| M13 | **Interchange**: AAF/OMF import/export, disk streaming, record to disk | 🟡 strict external-WAV AAF import; export, OMF and disk streaming missing | 65–115 |
|
||||
| M14 | **Fidelity harness** against Pro Tools (null tests, plugin responses) | ⬜ | 20–30 |
|
||||
| M15 | **Localization**: catalog, fonts/RTL, the 8 Pro Tools languages first | 🟡 partial (pt-BR catalog; needs native review; PRs #141, #143 open) | 45–80 |
|
||||
| M16 | Built-in plugin depth, sidechain, ARA | ⬜ | 110–170 |
|
||||
@@ -89,6 +89,7 @@ There is no `cargo xtask scorecard` in this repo; the measured number is `cargo
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-18 | minor | MIDI input devices landed (G-02 shrunk); the MIDI gate row is unverified until checked on macOS and Windows |
|
||||
| 2026-11-14 | minor | M13 is in progress with strict external-WAV AAF import; the exchange gate still fails without AAF export, OMF or `.ptx`; estimates unchanged |
|
||||
| 2026-11-09 | trivial | 28 built-in processors with the Frequency Shifter |
|
||||
| 2026-11-05 | trivial | M15: a pt-BR catalog covers menus and `text`/`localized_format!` strings; remains native review, CJK/RTL and the other languages. Estimates unchanged |
|
||||
| 2026-10-30 | trivial | G-05 down to 10–15 h and the mix row's VST3 windows updated: VST3 and embedded CLAP editors are hosted on Linux/X11 (#527) |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Target-app parity: SoundCraft vs Avid Pro Tools
|
||||
|
||||
> **Last reviewed:** 2026-11-05 · **Last updated:** 2026-11-09 · **Change:** trivial (Frequency Shifter: 28 built-in processors; previously trivial: G-09/localization: pt-BR catalog; percentages unchanged) · **Target:** Avid Pro Tools Ultimate 2026.4.1 (bundle 26.4.1.179, macOS)
|
||||
> **Last reviewed:** 2026-11-14 · **Last updated:** 2026-11-14 · **Change:** minor (strict external-WAV AAF import; previously trivial: Frequency Shifter: 28 built-in processors; G-09/localization: pt-BR catalog; readiness estimates unchanged) · **Target:** Avid Pro Tools Ultimate 2026.4.1 (bundle 26.4.1.179, macOS)
|
||||
|
||||
The authoritative assessment of how close SoundCraft is to Pro Tools. [`ROADMAP.md`](../ROADMAP.md)
|
||||
summarizes it, [`gaps.md`](gaps.md) itemizes every shortfall, and the per-dimension docs go deeper:
|
||||
@@ -81,7 +81,7 @@ post-production, tracking) can switch. "Ready" is depth, correctness and fidelit
|
||||
|---|---:|---:|---|---:|---|---|
|
||||
| Features | 45 % | **~45 %** | estimated | 520–810 | [area table](#feature-areas) | Menu breadth 94 % measured, but depth is thin: see the area table |
|
||||
| UI/UX fidelity | 10 % | **~55 %** | estimated | 60–100 | [ui-parity.md](ui-parity.md) | Edit/Mix windows, every menu, floating windows; open UX bugs #3 #5 #6 #7 #140 #144; shortcuts only recently right on Windows/Linux (#15, #41); generic plugin UIs |
|
||||
| File formats | 10 % | **~40 %** | estimated | 70–120 | [file-format-parity.md](file-format-parity.md) | WAV/BWF/RF64/AIFF/FLAC read+write, compressed formats read; no `.ptx`, AAF, OMF, ADM BWF, MP3/AAC export, video export |
|
||||
| File formats | 10 % | **~40 %** | estimated | 70–120 | [file-format-parity.md](file-format-parity.md) | WAV/BWF/RF64/AIFF/FLAC read+write, compressed formats read; strict external-WAV AAF import; no `.ptx`, AAF/OMF export, OMF import, ADM BWF, MP3/AAC export, video export |
|
||||
| Hardware | 10 % | **~12 %** | estimated | 110–180 | [hardware-parity.md](hardware-parity.md) | Default output and default input device only, fixed 512-sample block, no ASIO, no MIDI devices, no control surfaces, no sync |
|
||||
| Stability | 10 % | **~45 %** | estimated | 50–80 | [gaps.md](gaps.md) | Never-crash rules and proptests (random edits, mutated sessions, hostile params); but ~25 open correctness bugs, a launch failure (#142), an X11 llvmpipe failure (#107) |
|
||||
| Performance | 5 % | **~35 %** | estimated (unmeasured) | 40–70 | [hardware-parity.md](hardware-parity.md) | Parallel strip rendering and PDC exist; whole files decoded into RAM, recording into RAM (#84 open), no track-count or latency benchmarks |
|
||||
@@ -122,7 +122,7 @@ immersive delivery, video, notation, and languages other than English.
|
||||
|---|---:|---|
|
||||
| Interaction fidelity | ×0.90 | Shortcut collisions and dead shortcuts (#140 Heal, #144 Mix/Edit vs zoom, #7 Export); Multitool handles don't adjust audio (#5); generic plugin parameter panels (#138, #139); clip deletion inconsistencies (#3, #4) |
|
||||
| Stability on real machines | ×0.92 | 26 open core-path bugs, e.g. bounce and latency (#59, #103), playback speed (#101), session saves (#86, #91), plus a launch failure (#142). Never-crash rules and property tests hold up: no crash reports on macOS since #16 |
|
||||
| File exchange with Pro Tools users | ×0.85 | Engineers trade sessions, not stems. No `.ptx`, AAF or OMF (#40); WAV/BWF stems and MIDI files do work, so the factor isn't lower |
|
||||
| File exchange with Pro Tools users | ×0.85 | Engineers trade sessions, not stems. Only a strict external-WAV AAF import subset works; `.ptx`, AAF export and OMF do not (#40). WAV/BWF stems and MIDI files work, so the factor isn't lower |
|
||||
| **Result** | 50.6 × 0.90 × 0.92 × 0.85 = **35.6 % ≈ 36 %** | |
|
||||
|
||||
This comes out *below* the full number (~40 %), which is unusual. The
|
||||
@@ -188,7 +188,7 @@ Weights by what Pro Tools users actually spend time on. **Breadth** = the featur
|
||||
| Elastic Audio, TCE, Beat Detective, pitch | 5 % | 70 % | **35 %** | 40–60 | Pitch-preserving warp on Elastic tracks, TCE, conform to tempo, Beat Detective and Identify Beat, audio-to-MIDI. Missing: per-algorithm choice (polyphonic/rhythmic/monophonic/varispeed/X-Form), warp markers UI depth, Elastic Pitch, quality vs Pro Tools unmeasured |
|
||||
| Surround and immersive | 5 % | 55 % | **35 %** | 50–80 | Formats stereo → 9.1.6 and Ambisonics, surround panner, fold-down, multichannel bounce, object/bed routing. Missing: Dolby Atmos renderer integration and ADM BWF, MPEG-H (new in 2026.4), binaural/headphone monitoring, surround automation; bug #89 |
|
||||
| Video and post | 5 % | 60 % | **40 %** | 40–60 | Video track, H.264/ProRes/MJPEG decoders, sync offset, relinking, timecode rulers. Missing: HEVC/DNx/AV1, video bounce/export, timecode sync to external machines, speech-to-text transcript, field-recorder/iXML conform |
|
||||
| Session, file management, interchange | 10 % | 55 % | **35 %** | 60–100 | `.scraft` + Audio Files, Save Copy In, Import Session Data, clip groups, session text export, audio-health report. Missing: `.ptx` read/write, AAF/OMF (#40), session templates, track presets, workspace/Soundbase browser, disk streaming of long sources, batch rename; bugs #86, #91, #136 |
|
||||
| Session, file management, interchange | 10 % | 55 % | **35 %** | 60–100 | `.scraft` + Audio Files, Save Copy In, Import Session Data, clip groups, session text export, audio-health report, strict external-WAV AAF import. Missing: `.ptx` read/write, AAF export, OMF import/export (#40), session templates, track presets, workspace/Soundbase browser, disk streaming of long sources, batch rename; bugs #86, #91, #136 |
|
||||
| Collaboration, cloud, Sketch, Splice | 2 % | 0 % | **0 %** | not estimated | Avid services; out of scope unless the owner decides otherwise |
|
||||
| Agent control (CLI, control channel, MCP) | 1 % | 100 % | **100 %** | 3 | Ahead of Pro Tools' scripting SDK; one open bug (#145) |
|
||||
| **Weighted** | 100 % | **~70 %** | **~45 %** | **~520–810** | |
|
||||
@@ -203,7 +203,7 @@ platform:
|
||||
used, the mix runs in fixed 512-sample blocks, input and output are separate streams, and
|
||||
takes are held in RAM.
|
||||
- MIDI recording: **no**. There is no MIDI device layer.
|
||||
- Session interchange with Pro Tools or picture editors: **no**. No AAF/OMF/`.ptx`.
|
||||
- Session interchange with Pro Tools or picture editors: **no**. Strict external-WAV AAF import works, but AAF export, OMF and `.ptx` do not.
|
||||
|
||||
Editing, mixing with plugins, bouncing, and saving and reopening pass (with known bugs).
|
||||
|
||||
@@ -245,6 +245,7 @@ serializes more, because it needs hands-on testing.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-14 | minor | Strict external-WAV AAF import added to format, interchange and alpha-gate evidence; readiness estimates unchanged |
|
||||
| 2026-11-09 | trivial | Built-in plugin counts: 28 processors + 3 instruments with the Frequency Shifter. Percentages unchanged |
|
||||
| 2026-11-05 | trivial | Localization row: English plus a near-complete pt-BR catalog for fixed UI strings (PR #1346), not native-reviewed. Percentages and hours unchanged |
|
||||
| 2026-10-24 | trivial | Built-in plugin counts: 27 processors + 3 instruments on `main`, and 24 + 2 in the 3bc2d92 code snapshot; the sampler (#108) is no longer listed as missing. Percentages unchanged |
|
||||
|
||||
@@ -31,6 +31,7 @@ const LAYERS: &[(&str, u8)] = &[
|
||||
("au-host", 1),
|
||||
("model", 2),
|
||||
("mix", 3),
|
||||
("interchange", 3),
|
||||
("engine", 4),
|
||||
("playback", 4),
|
||||
("automation", 5),
|
||||
|
||||
Reference in New Issue
Block a user