From 84e591e1ca56eb24ea5219739f5416c53c3f5b6b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 25 Oct 2026 17:05:28 -0700 Subject: [PATCH 01/46] Zoom Toggle: Alt+Shift+E and Alt-click cancel it and keep the current view Cancel Zoom Toggle (view.zoom_toggle_cancel, Alt+Shift+E, Option+Shift+E on a Mac) turns Zoom Toggle off without going back to the view it stored: the zoom, the horizontal and vertical scroll and the track heights stay as they are. An Alt-click (Option-click) on the Zoom Toggle button runs the same command. The next Zoom Toggle zooms in from the current view and goes back to it. When the command runs, from a key, the button or the control channel, the Edit window clears the vertical scroll position that Zoom Toggle would restore. --- ROADMAP.md | 4 ++- crates/engine/src/cmd/zoom_toggle.rs | 32 ++++++++++++++++-- crates/ui-egui/src/edit_window.rs | 12 ++++++- crates/ui-egui/src/lib.rs | 3 ++ crates/ui-egui/tests/it/zoom_toggle.rs | 45 +++++++++++++++++++++++++- docs/ui-parity.md | 4 ++- 6 files changed, 94 insertions(+), 6 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index cc80cc78..8eac794f 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -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-10-25 · **Change:** trivial (Auto Pan stereo balance, 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-10-24 · **Last updated:** 2026-10-25 · **Change:** trivial (Cancel Zoom Toggle, Auto Pan stereo balance, 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 @@ -122,6 +122,7 @@ mutated and truncated movies. Field reports from the first public week are track ## Progress log +- **2026-10-25:** Alt+Shift+E (`view.zoom_toggle_cancel`) and an Alt-click on the Zoom Toggle button cancel Zoom Toggle and keep the current view: the zoom, the scroll and the track heights stay as they are, and the button is no longer lit. The next Zoom Toggle zooms in from that view and goes back to it. No readiness percentage change. - **2026-10-25:** Auto Pan moves the balance of a stereo track: the left channel's level falls as the position moves right and the right channel's as it moves left, at constant power, and each channel stays on its own side. At the center the track passes unchanged, so a wide or out-of-phase stereo image keeps its width, and the envelope follower follows the louder channel. No readiness percentage change. - **2026-10-24:** Clip List › Auto Rename (`clip.auto_rename`) sets the names that editing gives the clips it separates from the selected clips: a name, a starting number, a number of places (zeros before the number) and a suffix. The piece after each cut takes the next name, the piece before it keeps its name, and all the pieces count up one number sequence. Pieces that Strip Silence names with its own Rename fields, or removes, take no Auto Rename name. Copied clips keep their scheme when they are pasted, saved sessions hold the schemes, and Import Session Data brings them along. No readiness percentage change. - **2026-10-24:** While the Strip Silence window is open, the Edit window draws a rectangle around each range that Strip would keep on the selected tracks, padded by Clip Start Pad and Clip End Pad, and the rectangles follow the sliders as they move. They are removed when the window closes. `edit.strip_silence_preview` returns the same ranges without changing the session. No readiness percentage change. @@ -175,6 +176,7 @@ mutated and truncated movies. Field reports from the first public week are track | Date | Change | Summary | |---|---|---| +| 2026-10-25 | trivial | Progress log: Cancel Zoom Toggle; readiness estimates unchanged | | 2026-10-25 | trivial | Progress log: Auto Pan stereo balance; readiness estimates unchanged | | 2026-10-24 | trivial | Progress log: Clip List Auto Rename; readiness estimates unchanged | | 2026-10-24 | trivial | Progress log: Strip Silence rectangles; readiness estimates unchanged | diff --git a/crates/engine/src/cmd/zoom_toggle.rs b/crates/engine/src/cmd/zoom_toggle.rs index 24781759..2735133d 100644 --- a/crates/engine/src/cmd/zoom_toggle.rs +++ b/crates/engine/src/cmd/zoom_toggle.rs @@ -1,4 +1,5 @@ -//! Zoom Toggle: zoom in on the edit selection, then back out to the view before. +//! Zoom Toggle: zoom in on the edit selection, then back out to the view before. Cancel Zoom Toggle turns it off +//! and keeps the current view. use super::{CommandSpec, always, f64_or}; use soundcraft_model::{TrackHeight, ZoomToggle}; use soundcraft_time::MAX_POSITION; @@ -7,7 +8,16 @@ use crate::{Engine, Result, cmd}; use serde_json::{Value, json}; pub fn specs() -> Vec { - vec![cmd!(noundo "view.zoom_toggle", "Zoom Toggle", [], None, "{width_px?: 1200, height_px?: 600}", always, toggle)] + vec![ + cmd!(noundo "view.zoom_toggle", "Zoom Toggle", [], None, "{width_px?: 1200, height_px?: 600}", always, toggle), + cmd!(noundo "view.zoom_toggle_cancel", "Cancel Zoom Toggle", [], Some("Alt+Shift+E"), "{}", always, cancel), + ] +} + +/// Forget the view Zoom Toggle would go back to, leaving the zoom, scroll and track heights as they are. +fn cancel(e: &mut Engine, _: &Value) -> Result { + let was_on = e.session_mut().edit.zoom_toggle.take().is_some(); + Ok(json!({"on": false, "canceled": was_on})) } fn toggle(e: &mut Engine, p: &Value) -> Result { @@ -73,6 +83,24 @@ mod tests { assert_eq!(view(&e), (500.0, 1000, vec![Medium, Fit(299), Medium])); } + #[test] + fn cancel_keeps_the_zoomed_view_and_the_next_toggle_zooms_in_again() { + let mut e = engine(json!({"tracks": ["Audio 1", "Audio 3"], "start": 48_000, "end": 96_000})); + e.execute("view.zoom_toggle", &json!({"width_px": 1000.0, "height_px": 500.0})).unwrap(); + let zoomed = view(&e); + assert_eq!(e.execute("view.zoom_toggle_cancel", &json!({})).unwrap(), json!({"on": false, "canceled": true})); + assert_eq!(e.session().edit.zoom_toggle, None); + assert_eq!(view(&e), zoomed, "cancel keeps the view Zoom Toggle zoomed in to"); + assert_eq!(e.execute("view.zoom_toggle_cancel", &json!({})).unwrap(), json!({"on": false, "canceled": false})); + assert_eq!(view(&e), zoomed); + e.execute("view.zoom_set", &json!({"samples_per_px": 200.0})).unwrap(); + assert_eq!(e.execute("view.zoom_toggle", &json!({"width_px": 1000.0, "height_px": 500.0})).unwrap(), json!({"on": true})); + e.execute("view.zoom_toggle", &json!({})).unwrap(); + assert_eq!(view(&e), (200.0, 48_000, vec![Fit(249), Medium, Fit(249)]), "the toggle goes back to the view it saw after the cancel"); + let spec = crate::cmd::command_specs().iter().find(|c| c.id == "view.zoom_toggle_cancel").unwrap(); + assert_eq!(spec.shortcut, Some("Alt+Shift+E")); + } + #[test] fn hostile_sizes_and_stored_views_stay_in_range() { let mut e = engine(json!({"tracks": ["Audio 1"], "start": 0, "end": MAX_POSITION})); diff --git a/crates/ui-egui/src/edit_window.rs b/crates/ui-egui/src/edit_window.rs index 1f25fb6f..749bfada 100644 --- a/crates/ui-egui/src/edit_window.rs +++ b/crates/ui-egui/src/edit_window.rs @@ -78,6 +78,11 @@ impl EditLayout { pub fn scroll_by(&mut self, dy: f32, view_h: f32) { self.scroll_y = (self.scroll_y + dy).clamp(0.0, (self.content_h - view_h + 40.0).max(0.0)); } + + /// Clears the vertical scroll position Zoom Toggle would restore, so Cancel Zoom Toggle keeps the current scroll. + pub(crate) fn forget_zoom_back(&mut self) { + self.zoom_back = None; + } } pub fn rect([x0, y0, x1, y1]: [f32; 4]) -> Rect { @@ -469,8 +474,13 @@ fn hscrollbar(app: &mut SoundApp, ui: &mut Ui, sb: Rect, tl: Rect) { } } -/// Zoom Toggle sized to the track area on screen. +/// Zoom Toggle sized to the track area on screen. With Alt held (an Alt-click on the button) it cancels Zoom Toggle +/// instead and keeps the current view. pub fn zoom_toggle(app: &mut SoundApp) { + if app.docking_context.as_ref().is_some_and(|c| c.input(|i| i.modifiers.alt)) { + let _ = app.run("view.zoom_toggle_cancel", json!({})); + return; + } let [x0, y0, x1, y1] = app.edit_layout.timeline; let _ = app.run("view.zoom_toggle", json!({"width_px": x1 - x0, "height_px": y1 - y0})); } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 7b564f92..91694a07 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -597,6 +597,9 @@ impl SoundApp { // Re-selecting a scrolling mode resumes the playhead follow. self.edit_layout.follow_hold = false; } + if id == "view.zoom_toggle_cancel" { + self.edit_layout.forget_zoom_back(); + } if id == "track.clear_clip_indicators" { self.meters.values_mut().chain([&mut self.main_meter]).for_each(|m| m.clip = false); } diff --git a/crates/ui-egui/tests/it/zoom_toggle.rs b/crates/ui-egui/tests/it/zoom_toggle.rs index d3badcff..2011c812 100644 --- a/crates/ui-egui/tests/it/zoom_toggle.rs +++ b/crates/ui-egui/tests/it/zoom_toggle.rs @@ -1,5 +1,5 @@ use egui::os::OperatingSystem; -use egui::{Key, vec2}; +use egui::{Key, Modifiers, vec2}; use egui_kittest::{Harness, kittest::Queryable}; use serde_json::json; use soundcraft_ui_egui::{Services, SoundApp}; @@ -41,3 +41,46 @@ fn e_fits_the_selection_to_the_edit_window_and_the_button_goes_back() { assert_eq!(view(h.state()), before, "{os:?}"); } } + +#[test] +fn alt_shift_e_and_an_alt_click_cancel_zoom_toggle_and_keep_the_zoomed_view() { + for os in [OperatingSystem::Mac, OperatingSystem::Windows, OperatingSystem::Nix] { + for alt_click in [false, true] { + let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); + let bass = app.engine.session().track_by_name("Bass").unwrap().id.0; + app.engine.execute("edit.select", &json!({"tracks": [bass], "start": 96_000, "end": 192_000})).unwrap(); + let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).with_os(os).build_ui_state( + |ui, app: &mut SoundApp| { + app.logic(&ui.ctx().clone()); + app.ui(ui); + }, + app, + ); + h.run_steps(5); + let view = |a: &SoundApp| (a.engine.session().edit.zoom, a.edit_layout.rows.clone(), a.edit_layout.scroll_y); + let before = view(h.state()); + h.get_by_label("Zoom Toggle (E)").click(); + h.run_steps(1); + let zoomed = view(h.state()); + assert_ne!(zoomed, before, "{os:?}"); + + if alt_click { + h.get_by_label("Zoom Toggle (E)").click_modifiers(Modifiers::ALT); + } else { + h.key_press_modifiers(Modifiers::ALT | Modifiers::SHIFT, Key::E); + } + h.run_steps(2); + let how = if alt_click { "Alt-click" } else { "Alt+Shift+E" }; + assert_eq!(h.state().engine.session().edit.zoom_toggle, None, "{os:?} {how}"); + assert_eq!(view(h.state()), zoomed, "{os:?} {how} keeps the zoomed view"); + + // The next toggle zooms in from here and goes back here, not to the view before the cancel. + h.get_by_label("Zoom Toggle (E)").click(); + h.run_steps(1); + assert!(h.state().engine.session().edit.zoom_toggle.is_some(), "{os:?} {how}"); + h.get_by_label("Zoom Toggle (E)").click(); + h.run_steps(1); + assert_eq!(view(h.state()), zoomed, "{os:?} {how}"); + } + } +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index f7d06d57..0778d0b1 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity -> **Last reviewed:** 2026-10-16 · **Last updated:** 2026-10-16 · **Change:** minor (Scroll Into View in the track name menu) · **Target:** Avid Pro Tools Ultimate 2026.4.1 +> **Last reviewed:** 2026-10-16 · **Last updated:** 2026-10-25 · **Change:** minor (Cancel Zoom Toggle) · **Target:** Avid Pro Tools Ultimate 2026.4.1 How SoundCraft feels in the hands of a Pro Tools user: tools, modes, modifiers, shortcuts, windows, meters. Measured from `crates/model/src/session.rs` (tools, modes), the command @@ -21,6 +21,7 @@ Legend: ✅ matches · 🟡 partial · ❌ missing. | Live waveform fade preview | ✅ | Waveform amplitude updates during fade-length and midpoint-curvature drags, sharing the curve's temporary envelope. Mono/stereo, waveform styles, zoom and clip gain remain effective; release preserves the displayed waveform with one undo step and cached peaks | | Edit modes: Shuffle, Slip, Spot, Grid (absolute/relative) | ✅ | Spot dialog present | | Grid and nudge values, all timebases | ✅ | Bars/Beats, Min:Secs, Timecode, Feet+Frames, Samples | +| Zoom Toggle | 🟡 | E (Commands focus) and the button zoom to the edit selection with Fit To Window heights and back; Alt+Shift+E and Alt-click cancel it and keep the view. The Zoom Toggle preferences (Vertical Zoom, Horizontal Zoom, Track Height, Track View, Separate Grid Settings When Zoomed In, Zoom Toggle Follows Edit Selection, Remove Range Selection After Zooming In) are not present | | Keyboard focus modes (Commands, Clip List, Groups) | 🟡 | Commands focus single-key editing ✅; list focus partial | | Link timeline/edit, link track/edit, Tab to transient, insertion follows playback | ✅ | | | Mirrored MIDI, MIDI merge, layered editing | 🟡 | Stored and partly honoured | @@ -69,6 +70,7 @@ Legend: ✅ matches · 🟡 partial · ❌ missing. | Date | Change | Summary | |---|---|---| +| 2026-10-25 | minor | Zoom Toggle row: Alt+Shift+E and Alt-click cancel Zoom Toggle and keep the view. Readiness estimate unchanged | | 2026-10-16 | minor | Track name menu: Scroll Into View brings the track to the top of the Edit window and the left of the Mix. Readiness estimate unchanged | | 2026-10-13 | minor | A plugin opens when it's inserted (#486) | | 2026-10-13 | minor | Drag across checkboxes (#399) | From afa1532aba213624faffd6e75de3e0d255eca3c6 Mon Sep 17 00:00:00 2001 From: SusieeTheFemboy <96988330+SusieeTheLinuxUser@users.noreply.github.com> Date: Mon, 26 Oct 2026 23:50:39 +0100 Subject: [PATCH 02/46] Mix: clamp clip-FX gain and send-level automation (fixes #884) A shared session or an MCP clip.effects_set could store clip-FX gain or a send-level automation point far above any fader (up to the +200 dB cap in db_to_gain). Clamp clip-FX gain to the slider's +24 dB, send-level lanes to +12 dB, and every loaded automation point to its AutoParam range on sanitize. Co-Authored-By: opencode beam-free Co-Authored-By: MiniMax M3 Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/clip_more.rs | 17 +++++++++++++++-- crates/mix/src/lib.rs | 9 +++++++-- crates/model/src/session.rs | 2 ++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/clip_more.rs b/crates/engine/src/cmd/clip_more.rs index a2ebd8b3..7a2564c8 100644 --- a/crates/engine/src/cmd/clip_more.rs +++ b/crates/engine/src/cmd/clip_more.rs @@ -196,8 +196,14 @@ fn unloop(e: &mut Engine, p: &Value) -> Result { fn effects_set(e: &mut Engine, p: &Value) -> Result { let ids = clip_ids_param(e, p); let params = p.get("params").and_then(Value::as_object).ok_or_else(|| bad("clip.effects_set", "`params` must be an object of numbers"))?; - let vals: Vec<(String, f64)> = - params.iter().filter_map(|(k, v)| v.as_f64().filter(|x| x.is_finite()).map(|x| (k.chars().take(64).collect(), x))).collect(); + let vals: Vec<(String, f64)> = params + .iter() + .filter_map(|(k, v)| v.as_f64().filter(|x| x.is_finite()).map(|x| (k.chars().take(64).collect(), x))) + .map(|(k, v)| { + let v = if k == "gain" { v.clamp(f64::from(soundcraft_dsp::MIN_DB), f64::from(soundcraft_mix::CLIP_FX_MAX_GAIN_DB)) } else { v }; + (k, v) + }) + .collect(); let s = e.session_mut(); for c in &ids { for (k, v) in &vals { @@ -316,6 +322,13 @@ mod tests { (Engine::new(s), t, ids) } + #[test] + fn effects_set_caps_gain() { + let (mut e, _t, ids) = engine_with(&[(0, 100, 0)]); + e.execute("clip.effects_set", &json!({"clip": ids[0].0, "params": {"gain": 500.0}})).unwrap(); + assert_eq!(e.session().edit.values.get(&format!("clip_fx.{}.gain", ids[0].0)).copied(), Some(24.0)); + } + #[test] fn unloop_removes_copies() { let (mut e, t, ids) = engine_with(&[(0, 100, 0), (100, 100, 0), (200, 100, 0), (300, 100, 50)]); diff --git a/crates/mix/src/lib.rs b/crates/mix/src/lib.rs index 8276220e..9051f062 100644 --- a/crates/mix/src/lib.rs +++ b/crates/mix/src/lib.rs @@ -76,6 +76,11 @@ pub fn main_channels(s: &Session) -> usize { /// (insert slots use their index). pub const INSTRUMENT_SLOT: usize = usize::MAX; +/// Top of the clip effects gain slider; a stored or wired gain is clamped to it (#884). +pub const CLIP_FX_MAX_GAIN_DB: f32 = 24.0; +/// Top of a send fader, the same +12 dB `AutoParam::SendLevel` ranges up to (#884). +pub const SEND_LEVEL_MAX_DB: f32 = 12.0; + /// Hosted third-party plugin ids (CLAP or VST3): created off the audio thread in realtime use. pub fn is_third_party(id: &str) -> bool { id.starts_with(soundcraft_clap_host::ID_PREFIX) @@ -1279,7 +1284,7 @@ impl ClipFx { c.set_param(p, v); } } else if k == "gain" { - self.gain_db = v; + self.gain_db = if v.is_nan() { 0.0 } else { v.clamp(soundcraft_dsp::MIN_DB, CLIP_FX_MAX_GAIN_DB) }; } } } @@ -1967,7 +1972,7 @@ fn send_level(t: &Track, i: usize, base: f32, pos: Samples) -> f32 { && let Some(l) = t.lane(&AutoParam::SendLevel(u8::try_from(i).unwrap_or(0))) && !l.points.is_empty() { - return l.value_at(pos, base); + return l.value_at(pos, base).clamp(soundcraft_dsp::MIN_DB, SEND_LEVEL_MAX_DB); } base } diff --git a/crates/model/src/session.rs b/crates/model/src/session.rs index 5283ff83..9f5221ab 100644 --- a/crates/model/src/session.rs +++ b/crates/model/src/session.rs @@ -626,6 +626,8 @@ impl Session { } for l in &mut t.automation { l.points.retain(|p| p.value.is_finite()); + let (lo, hi, _) = l.param.range(); + l.points.iter_mut().for_each(|p| p.value = p.value.clamp(lo, hi)); l.points.iter_mut().for_each(|p| bound(&mut p.at)); l.points.sort_by_key(|p| p.at); } From dcdcca47049238c467ba995d0adb99ec0cc70003 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 28 Oct 2026 03:31:06 -0700 Subject: [PATCH 03/46] Zoom Toggle: a cancel with Zoom Toggle off keeps the scroll to restore Cancel Zoom Toggle clears the saved vertical scroll only when it turns Zoom Toggle off, so a cancel run before the next frame after turning it off no longer drops the scroll position the toggle-off restores. --- crates/ui-egui/src/app/commands.rs | 2 +- crates/ui-egui/src/edit_window/tests.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index b569f0f2..49b2da00 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -30,7 +30,7 @@ impl SoundApp { // Re-selecting a scrolling mode resumes the playhead follow. self.edit_layout.follow_hold = false; } - if id == "view.zoom_toggle_cancel" { + if id == "view.zoom_toggle_cancel" && v["canceled"] == true { self.edit_layout.forget_zoom_back(); } if id == "track.clear_clip_indicators" { diff --git a/crates/ui-egui/src/edit_window/tests.rs b/crates/ui-egui/src/edit_window/tests.rs index f7f94bbe..3de95f6c 100644 --- a/crates/ui-egui/src/edit_window/tests.rs +++ b/crates/ui-egui/src/edit_window/tests.rs @@ -246,6 +246,16 @@ fn hold_clears_when_playhead_returns_or_transport_stops() { ); } +/// Cancel Zoom Toggle with Zoom Toggle already off keeps the scroll position a pending toggle-off restores. +#[test] +fn a_cancel_with_zoom_toggle_off_keeps_the_scroll_to_restore() { + let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, crate::Services::default()); + app.edit_layout.zoom_back = Some(120.0); + let v = app.run("view.zoom_toggle_cancel", json!({})).unwrap(); + assert_eq!(v["canceled"], json!(false)); + assert_eq!(app.edit_layout.zoom_back, Some(120.0)); +} + fn harness(n: usize) -> Harness<'static, SoundApp> { let mut engine = soundcraft_engine::Engine::default(); engine.execute("track.new", &json!({"count": n})).unwrap(); From 14a081304ba9386b10c50be2ba3fcb70c7fe4e1b Mon Sep 17 00:00:00 2001 From: ydking0911 Date: Fri, 30 Oct 2026 11:35:49 +0900 Subject: [PATCH 04/46] Clip menu: act on the whole edit selection when the right-clicked clip is part of it --- crates/ui-egui/src/edit_window/input.rs | 28 +++++- crates/ui-egui/tests/it/clip_menu.rs | 127 +++++++++++++++++++----- 2 files changed, 127 insertions(+), 28 deletions(-) diff --git a/crates/ui-egui/src/edit_window/input.rs b/crates/ui-egui/src/edit_window/input.rs index 88538b99..ad7a2225 100644 --- a/crates/ui-egui/src/edit_window/input.rs +++ b/crates/ui-egui/src/edit_window/input.rs @@ -511,7 +511,9 @@ fn clip_context_menu(app: &mut SoundApp, ui: &mut Ui, clip: Option) { } return; }; - let ids = json!([c.0]); + // A clip of the edit selection acts on the whole selection (the commands default to it); any other clip acts alone. + let in_selection = clip_in_selection(app.engine.session(), c); + let target = if in_selection { json!({}) } else { json!({"clips": [c.0]}) }; for (label, cmd) in [ ("Mute/Unmute", "edit.mute_clips"), ("Edit Lock/Unlock", "clip.edit_lock"), @@ -522,7 +524,7 @@ fn clip_context_menu(app: &mut SoundApp, ui: &mut Ui, clip: Option) { ("Send to Back", "clip.send_to_back"), ] { if ui.button(label).clicked() { - let _ = app.run(cmd, json!({"clips": ids})); + let _ = app.run(cmd, target.clone()); } } ui.separator(); @@ -531,7 +533,25 @@ fn clip_context_menu(app: &mut SoundApp, ui: &mut Ui, clip: Option) { app.dialogs.open_rename_clip(c, &name); } if ui.button("Delete").clicked() { - let _ = app.run("edit.select", json!({"clips": ids})); - let _ = app.run("edit.clear", json!({})); + let selected: Vec = app.engine.session().edit.selected_clips.iter().map(|id| id.0).collect(); + if !in_selection { + let _ = app.run("edit.select", json!({"clips": [c.0]})); + let _ = app.run("edit.clear", json!({})); + } else if selected.is_empty() { + let _ = app.run("edit.clear", json!({})); + } else { + // Selected clips go by id (an empty range), so clips between them that the span covers stay. + let _ = app.run("edit.clear", json!({"clips": selected, "start": 0})); + } } } + +/// Whether `c` is part of the edit selection: one of the selected clips or, when no clip is selected, a clip on a +/// selected track that the selected range overlaps. An insertion point selects nothing. +fn clip_in_selection(s: &Session, c: ClipId) -> bool { + let ed = &s.edit; + if !ed.selected_clips.is_empty() { + return ed.selected_clips.contains(&c); + } + !ed.selection.is_empty() && s.find_clip(c).is_some_and(|(t, clip)| ed.selected_tracks.contains(&t) && clip.range().overlaps(&ed.selection)) +} diff --git a/crates/ui-egui/tests/it/clip_menu.rs b/crates/ui-egui/tests/it/clip_menu.rs index 8da61fd7..7330e319 100644 --- a/crates/ui-egui/tests/it/clip_menu.rs +++ b/crates/ui-egui/tests/it/clip_menu.rs @@ -1,6 +1,7 @@ //! Regression: the clip context menu must stay open while the pointer moves onto it, so its //! Delete item can be used. It used to vanish once the pointer left the lane, because the lane -//! returned early (no hover position) before the menu was drawn. +//! returned early (no hover position) before the menu was drawn. A right-click on a clip of the +//! edit selection acts on the whole selection (#1191). use egui::{Event, Modifiers, PointerButton, pos2, vec2}; use egui_kittest::Harness; @@ -24,15 +25,16 @@ fn press(h: &mut Harness<'_, SoundApp>, x: f32, y: f32, button: PointerButton) { s.push(Event::PointerButton { pos, button, pressed: false, modifiers: Modifiers::NONE }); } -fn kick_clip_count(h: &Harness<'_, SoundApp>) -> usize { +fn clip_count(h: &Harness<'_, SoundApp>, track: &str) -> usize { let s = h.state().engine.session(); - s.tracks.iter().find(|t| t.name == "Kick").map_or(0, |t| t.clips().len()) + s.tracks.iter().find(|t| t.name == track).map_or(0, |t| t.clips().len()) } -/// Moving the pointer from a right-clicked clip onto the menu's Delete item keeps the menu open; clicking Delete -/// removes one Kick clip. -#[test] -fn clip_menu_stays_open_while_moving_onto_delete() { +fn kick_clip_count(h: &Harness<'_, SoundApp>) -> usize { + clip_count(h, "Kick") +} + +fn demo() -> Harness<'static, SoundApp> { let engine = soundcraft_engine::demo::demo_engine(); let app = SoundApp::new(engine, None, Services::default()); let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).with_pixels_per_point(2.0).build_ui_state( @@ -46,26 +48,103 @@ fn clip_menu_stays_open_while_moving_onto_delete() { for _ in 0..6 { step(&mut h); } + h +} + +/// Selects the whole session on `tracks`, as a drag across their clips does. +fn select_all_of(h: &mut Harness<'_, SoundApp>, tracks: &[&str]) { + h.state_mut().engine.execute("edit.select", &serde_json::json!({"tracks": tracks, "start": 0, "end": 48_000 * 600})).unwrap(); +} + +/// Right-clicks the Kick clip and clicks `item` in its menu, moving onto the item first as a real pointer would. +fn kick_menu(h: &mut Harness<'_, SoundApp>, item: &str) { + press(h, 880.0, 240.0, PointerButton::Secondary); + for _ in 0..10 { + step(h); + } + // Ask the newly laid-out menu where the item is instead of pinning coordinates that change with egui's item metrics. + let at = h.get_by_label(item).rect().center(); + h.state_mut().synthetic.push(Event::PointerMoved(at)); + for _ in 0..10 { + step(h); + } + press(h, at.x, at.y, PointerButton::Primary); + for _ in 0..15 { + step(h); + } +} + +/// Moving the pointer from a right-clicked clip onto the menu's Delete item keeps the menu open; clicking Delete +/// removes one Kick clip. +#[test] +fn clip_menu_stays_open_while_moving_onto_delete() { + let mut h = demo(); let before = kick_clip_count(&h); assert!(before > 0, "the demo session should have a recorded Kick clip"); - // Right-click the Kick clip, then move the pointer into the menu and down to Delete. - press(&mut h, 880.0, 240.0, PointerButton::Secondary); - for _ in 0..10 { - step(&mut h); - } - // Move (no click) onto the menu's Delete item, as a real pointer would, so the lane loses - // its hover. Ask the newly laid-out menu where the item is instead of pinning coordinates - // that change with egui's item metrics. - let delete = h.get_by_label("Delete").rect().center(); - h.state_mut().synthetic.push(Event::PointerMoved(delete)); - for _ in 0..10 { - step(&mut h); - } - press(&mut h, delete.x, delete.y, PointerButton::Primary); - for _ in 0..15 { - step(&mut h); - } + kick_menu(&mut h, "Delete"); assert_eq!(kick_clip_count(&h), before - 1, "clicking Delete in the clip menu should remove the clip"); } + +/// Delete on a clip of a drag selection clears the whole selection, as Edit > Clear does, in one undo step (#1191). +#[test] +fn delete_on_a_selected_clip_clears_the_whole_selection() { + let mut h = demo(); + let (kick, snare) = (clip_count(&h, "Kick"), clip_count(&h, "Snare")); + assert!(snare > 1, "the demo session should have several Snare clips"); + select_all_of(&mut h, &["Kick", "Snare"]); + + kick_menu(&mut h, "Delete"); + + assert_eq!((clip_count(&h, "Kick"), clip_count(&h, "Snare")), (0, 0), "every selected clip should be cleared"); + h.state_mut().engine.execute("edit.undo", &serde_json::json!({})).unwrap(); + assert_eq!((clip_count(&h, "Kick"), clip_count(&h, "Snare")), (kick, snare), "one undo should bring them all back"); +} + +/// A clip outside the selection is still deleted on its own, and the selection's clips stay. +#[test] +fn delete_on_a_clip_outside_the_selection_removes_only_that_clip() { + let mut h = demo(); + let (kick, snare) = (clip_count(&h, "Kick"), clip_count(&h, "Snare")); + select_all_of(&mut h, &["Snare"]); + + kick_menu(&mut h, "Delete"); + + assert_eq!((clip_count(&h, "Kick"), clip_count(&h, "Snare")), (kick - 1, snare)); +} + +/// With clips selected one by one (Grabber shift-click), Delete removes exactly those clips, not the other clips +/// their span covers. +#[test] +fn delete_on_selected_clips_keeps_the_unselected_clips_between_them() { + let mut h = demo(); + let ids = |h: &Harness<'_, SoundApp>, track: &str| -> Vec { + let s = h.state().engine.session(); + s.tracks.iter().filter(|t| t.name == track).flat_map(|t| t.clips()).map(|c| c.id.0).collect() + }; + let (kick, snare) = (ids(&h, "Kick"), ids(&h, "Snare")); + let last_snare = *snare.last().unwrap(); + let clips: Vec = kick.iter().copied().chain([last_snare]).collect(); + h.state_mut().engine.execute("edit.select", &serde_json::json!({ "clips": clips })).unwrap(); + + kick_menu(&mut h, "Delete"); + + assert!(ids(&h, "Kick").is_empty(), "the selected Kick clips should be removed"); + let left: Vec = snare.iter().copied().filter(|id| *id != last_snare).collect(); + assert_eq!(ids(&h, "Snare"), left, "only the selected Snare clip should be removed"); +} + +/// The menu's other entries act on the whole selection too. +#[test] +fn mute_on_a_selected_clip_mutes_every_selected_clip() { + let mut h = demo(); + select_all_of(&mut h, &["Kick", "Snare"]); + + kick_menu(&mut h, "Mute/Unmute"); + + let s = h.state().engine.session(); + let clips: Vec<_> = s.tracks.iter().filter(|t| t.name == "Kick" || t.name == "Snare").flat_map(|t| t.clips()).collect(); + assert!(clips.len() > 2); + assert!(clips.iter().all(|c| c.muted), "every selected clip should be muted"); +} From 4740e8d4c438070ef8d4b725fa6ab69ea3914e55 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 24 Oct 2026 17:32:25 +0000 Subject: [PATCH 05/46] Export only the MIDI notes a trimmed clip still plays Found while testing crates/engine/src/io.rs:350-362 (export_midi) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/io/midi.rs | 7 +++++-- crates/engine/tests/it/midi_offset.rs | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/io/midi.rs b/crates/engine/src/io/midi.rs index f97b5709..44f7be31 100644 --- a/crates/engine/src/io/midi.rs +++ b/crates/engine/src/io/midi.rs @@ -66,12 +66,15 @@ pub fn export_midi(e: &Engine, only: Option<&[TrackId]>) -> Result> { for c in t.clips() { if let ClipContent::Midi { sequence } = &c.content { let base = s.tempo.samples_to_ticks(c.start, s.sample_rate); - for n in &sequence.notes { + // Only what plays: notes starting inside the clip, cut at its end. + let clip_end = s.tempo.samples_to_ticks(c.end(), s.sample_rate); + for n in sequence.notes.iter().filter(|n| n.start.saturating_add(base) < clip_end) { let mut n = *n; n.start = n.start.saturating_add(base); + n.length = n.length.min(clip_end - n.start).max(1); seq.notes.push(n); } - for ev in &sequence.ctrls { + for ev in sequence.ctrls.iter().filter(|ev| ev.tick.saturating_add(base) < clip_end) { let mut ev = *ev; ev.tick = ev.tick.saturating_add(base); seq.ctrls.push(ev); diff --git a/crates/engine/tests/it/midi_offset.rs b/crates/engine/tests/it/midi_offset.rs index e4a1b1ba..8e6fb7ae 100644 --- a/crates/engine/tests/it/midi_offset.rs +++ b/crates/engine/tests/it/midi_offset.rs @@ -28,3 +28,25 @@ fn midi_track_offset_moves_the_notes_like_moving_the_clip() { e.execute("edit.move_clips", &json!({"clip": clip, "by": 24_000})).unwrap(); assert!(render(&e) == offset, "the offset must match moving the clip by 24000 samples"); } + +#[test] +fn export_midi_leaves_out_what_a_trimmed_clip_no_longer_plays() { + let mut e = Engine::default(); + let r = e.execute("track.new", &json!({"kind": "instrument", "name": "Trim", "instrument": "subtractive_synth"})).unwrap(); + let track = r["tracks"][0].as_u64().unwrap(); + let r = e.execute("midi.new_clip", &json!({"track": track, "start": 0, "length": 96_000})).unwrap(); + let clip = r["clip"].as_u64().unwrap(); + e.execute("midi.note_add", &json!({"clip": clip, "pitch": 60, "start_ticks": 0, "length_ticks": 960, "velocity": 100})).unwrap(); + e.execute("midi.note_add", &json!({"clip": clip, "pitch": 62, "start_ticks": 800, "length_ticks": 960, "velocity": 100})).unwrap(); + e.execute("midi.note_add", &json!({"clip": clip, "pitch": 64, "start_ticks": 2000, "length_ticks": 960, "velocity": 100})).unwrap(); + // 24000 samples is 960 ticks at 120 bpm. + let id = e.session().tracks[0].clips()[0].id; + e.session_mut().find_clip_mut(id).unwrap().trim_end_to(24_000); + + let bytes = soundcraft_engine::io::export_midi(&e, None).unwrap(); + let smf = soundcraft_midi::read_smf(&bytes).unwrap(); + let notes = &smf.tracks[0].sequence.notes; + assert_eq!(notes.len(), 2, "only notes starting inside the clip are exported"); + let late = notes.iter().find(|n| n.pitch == 62).unwrap(); + assert_eq!(late.start + late.length, 960, "a note running past the clip end is cut at it"); +} From 440999a51f9cd143cbecad20c7a0b4d1b6fc5f09 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:18:02 +0000 Subject: [PATCH 06/46] Play transport.play {from} at the requested position, not the selection Fixes #1069 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd/transport.rs | 5 +++-- crates/engine/src/lib.rs | 2 ++ crates/ui-egui/src/app/playback.rs | 14 ++++++++++++++ crates/ui-egui/src/tests.rs | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/transport.rs b/crates/engine/src/cmd/transport.rs index 50827802..7246265e 100644 --- a/crates/engine/src/cmd/transport.rs +++ b/crates/engine/src/cmd/transport.rs @@ -9,9 +9,10 @@ pub fn specs() -> Vec { vec![ cmd!(noundo "transport.play", "Play", [], Some("Space"), "{from?: position}", always, |e, p| { if let Some(at) = position_param(e, "transport.play", p, "from")? { - e.transport_requests.push(TransportRequest::Locate(at.max(0))); + e.transport_requests.push(TransportRequest::PlayFrom(at.max(0))); + } else { + e.transport_requests.push(TransportRequest::Play); } - e.transport_requests.push(TransportRequest::Play); Ok(json!({})) }), cmd!(noundo "transport.stop", "Stop", [], Some("Space"), "{}", always, |e, _| { e.transport_requests.push(TransportRequest::Stop); Ok(json!({})) }), diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 7d21a704..40c3cee9 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -84,6 +84,8 @@ pub enum TransportRequest { /// Stop the old session's transport without applying stop-time edits to the new document. ResetSession, Play, + /// Start playing at this position (or move there if already playing), ignoring the selection. + PlayFrom(Samples), Stop, TogglePlay, Record, diff --git a/crates/ui-egui/src/app/playback.rs b/crates/ui-egui/src/app/playback.rs index 48ab859e..818e45e8 100644 --- a/crates/ui-egui/src/app/playback.rs +++ b/crates/ui-egui/src/app/playback.rs @@ -343,6 +343,20 @@ impl SoundApp { self.play_from_selection(); } } + TransportRequest::PlayFrom(at) => { + if self.is_playing() { + if let Some(p) = &self.player { + p.locate(at); + } + if let Some(sim) = &mut self.sim { + sim.0 = at; + } + self.last_write_at = i64::MIN; + self.engine.transport.position = at; + } else { + self.start_play(at, None, None); + } + } TransportRequest::Stop | TransportRequest::Pause => self.stop_play(), TransportRequest::TogglePlay => { if self.is_playing() { diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index eccddcd3..e6ca84e9 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -62,6 +62,21 @@ fn new_session_cancels_play_queued_before_the_next_frame() { assert_eq!(app.engine.transport.position, 0); } +#[test] +fn play_from_starts_at_from_regardless_of_the_selection() { + let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); + app.run("edit.select", json!({"tracks": ["Kick"], "start": 7_632_000, "end": 7_680_000})).unwrap(); + app.run("transport.play", json!({"from": 4_560_000})).unwrap(); + app.handle_transport(0.25); + assert!(app.is_playing()); + assert_eq!(app.engine.transport.position, 4_560_000 + 12_000); + + app.run("transport.play", json!({"from": 96_000})).unwrap(); + app.handle_transport(0.25); + assert!(app.is_playing()); + assert_eq!(app.engine.transport.position, 96_000 + 12_000); +} + #[test] fn record_with_nothing_armed_says_what_to_do() { let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()); From ffb95ebcf3e01116131298015e19f9876cf6f2bb Mon Sep 17 00:00:00 2001 From: ydking0911 Date: Fri, 30 Oct 2026 13:47:53 +0900 Subject: [PATCH 07/46] Clip menu: pass the clicked clip's track when Delete removes selected clips by id --- crates/ui-egui/src/edit_window/input.rs | 9 ++++++--- crates/ui-egui/tests/it/clip_menu.rs | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/edit_window/input.rs b/crates/ui-egui/src/edit_window/input.rs index ad7a2225..8529db9a 100644 --- a/crates/ui-egui/src/edit_window/input.rs +++ b/crates/ui-egui/src/edit_window/input.rs @@ -533,15 +533,18 @@ fn clip_context_menu(app: &mut SoundApp, ui: &mut Ui, clip: Option) { app.dialogs.open_rename_clip(c, &name); } if ui.button("Delete").clicked() { - let selected: Vec = app.engine.session().edit.selected_clips.iter().map(|id| id.0).collect(); + let s = app.engine.session(); + let selected: Vec = s.edit.selected_clips.iter().map(|id| id.0).collect(); + let track: Vec = s.find_clip(c).map(|(t, _)| t.0).into_iter().collect(); if !in_selection { let _ = app.run("edit.select", json!({"clips": [c.0]})); let _ = app.run("edit.clear", json!({})); } else if selected.is_empty() { let _ = app.run("edit.clear", json!({})); } else { - // Selected clips go by id (an empty range), so clips between them that the span covers stay. - let _ = app.run("edit.clear", json!({"clips": selected, "start": 0})); + // Selected clips go by id (an empty range), so clips between them that the span covers stay. The clicked + // clip's track satisfies Clear's track check even when the track selection was emptied meanwhile. + let _ = app.run("edit.clear", json!({"clips": selected, "tracks": track, "start": 0})); } } } diff --git a/crates/ui-egui/tests/it/clip_menu.rs b/crates/ui-egui/tests/it/clip_menu.rs index 7330e319..bfac15b6 100644 --- a/crates/ui-egui/tests/it/clip_menu.rs +++ b/crates/ui-egui/tests/it/clip_menu.rs @@ -135,6 +135,26 @@ fn delete_on_selected_clips_keeps_the_unselected_clips_between_them() { assert_eq!(ids(&h, "Snare"), left, "only the selected Snare clip should be removed"); } +/// Selected clips are deleted even when the track selection was emptied after selecting them (Edit > Selection > +/// Remove Edit from Top keeps the clip selection). +#[test] +fn delete_on_selected_clips_works_without_a_track_selection() { + let mut h = demo(); + let kick = clip_count(&h, "Kick"); + let clips: Vec = { + let s = h.state().engine.session(); + s.tracks.iter().filter(|t| t.name == "Kick").flat_map(|t| t.clips()).map(|c| c.id.0).collect() + }; + let e = &mut h.state_mut().engine; + e.execute("edit.select", &serde_json::json!({ "clips": clips })).unwrap(); + e.execute("edit.remove_selection_top", &serde_json::json!({})).unwrap(); + assert!(e.session().edit.selected_tracks.is_empty() && !e.session().edit.selected_clips.is_empty()); + + kick_menu(&mut h, "Delete"); + + assert_eq!(clip_count(&h, "Kick"), kick - clips.len(), "the selected Kick clips should be removed"); +} + /// The menu's other entries act on the whole selection too. #[test] fn mute_on_a_selected_clip_mutes_every_selected_clip() { From 9f5f312051f3658586de9cd547675a65fbaa2a4e Mon Sep 17 00:00:00 2001 From: ydking0911 Date: Fri, 30 Oct 2026 14:30:58 +0900 Subject: [PATCH 08/46] Clear: close the gaps of clips removed by id in Shuffle --- crates/engine/src/cmd/edit.rs | 8 +------- crates/engine/src/edit.rs | 27 +++++++++++++++++++++++++++ crates/engine/src/edit/tests.rs | 16 ++++++++++++++++ crates/engine/tests/it/edit_modes.rs | 16 ++++++++++++++++ 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index 98797a26..65c88f4a 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -376,13 +376,7 @@ fn clear(e: &mut Engine, p: &Value) -> Result { let s = e.session_mut(); let mut n = 0; if range.is_empty() && !ids.is_empty() { - for t in &mut s.tracks { - if let Some(pl) = t.playlist_mut() { - let before = pl.clips.len(); - pl.clips.retain(|c| !ids.contains(&c.id)); - n += before - pl.clips.len(); - } - } + n = ops::remove_clips(s, &ids, sh); s.edit.selected_clips.clear(); } else { for t in &tracks { diff --git a/crates/engine/src/edit.rs b/crates/engine/src/edit.rs index 9966a841..f83d199f 100644 --- a/crates/engine/src/edit.rs +++ b/crates/engine/src/edit.rs @@ -177,6 +177,33 @@ pub fn clear_range(s: &mut Session, track: TrackId, range: Range, shuffle: bool) removed } +/// Remove the clips `ids` from every track. In Shuffle the later clips on each track close the gaps they leave, +/// the latest gap first so the earlier ones stay where they were. Returns how many clips went. +pub fn remove_clips(s: &mut Session, ids: &[ClipId], shuffle: bool) -> usize { + let mut gaps: Vec<(TrackId, Range)> = Vec::new(); + for t in &mut s.tracks { + let track = t.id; + if let Some(pl) = t.playlist_mut() { + pl.clips.retain(|c| { + let gone = ids.contains(&c.id); + if gone { + gaps.push((track, c.range())); + } + !gone + }); + } + } + let n = gaps.len(); + if shuffle { + gaps.sort_by_key(|(t, r)| (t.0, std::cmp::Reverse(r.start))); + for (track, r) in gaps { + let moved = ripple(s, track, r.end, -r.len()); + follow_automation(s, track, r.end, moved); + } + } + n +} + /// Copy the material inside `range` (clips trimmed to the range), relative to `range.start`. pub fn copy_range(s: &Session, track: TrackId, range: Range) -> Vec { let t = TimeCtx::of(s); diff --git a/crates/engine/src/edit/tests.rs b/crates/engine/src/edit/tests.rs index 716624a3..82d40a42 100644 --- a/crates/engine/src/edit/tests.rs +++ b/crates/engine/src/edit/tests.rs @@ -159,6 +159,22 @@ fn clear_slip_and_shuffle() { assert_eq!(clips(&s, t), vec![(1000, 1000, 1000), (2000, 2000, 3000)]); } +#[test] +fn remove_clips_closes_each_gap_in_shuffle_only() { + let split = |shuffle| { + let (mut s, t) = session_with_clip(); + separate_at(&mut s, t, 2000); + separate_at(&mut s, t, 3000); + separate_at(&mut s, t, 4000); + let ids: Vec = s.track(t).unwrap().clips().iter().map(|c| c.id).collect(); + // The first and third pieces: [1000, 2000) and [3000, 4000). + assert_eq!(remove_clips(&mut s, &[ids[0], ids[2]], shuffle), 2); + clips(&s, t) + }; + assert_eq!(split(false), vec![(2000, 1000, 2000), (4000, 1000, 4000)]); + assert_eq!(split(true), vec![(1000, 1000, 2000), (2000, 1000, 4000)]); +} + #[test] fn copy_paste_overwrites() { let (mut s, t) = session_with_clip(); diff --git a/crates/engine/tests/it/edit_modes.rs b/crates/engine/tests/it/edit_modes.rs index 09433057..17258d76 100644 --- a/crates/engine/tests/it/edit_modes.rs +++ b/crates/engine/tests/it/edit_modes.rs @@ -299,6 +299,22 @@ fn shuffle_clear_moves_automation_with_the_clips() { assert_eq!(points(&e, t), [0, 7_000, 18_000, 27_000]); } +/// Clearing selected clips by id closes their gaps in Shuffle, as clearing their ranges does, and moves the +/// automation with the clips. +#[test] +fn shuffle_clear_by_clip_id_closes_each_gap() { + for (mode, want, want_points) in [ + ("shuffle", [(0, 10_000), (20_000, 10_000)], [0, 9_000, 20_000, 29_000]), + ("slip", [(0, 10_000), (40_000, 10_000)], [0, 9_000, 40_000, 49_000]), + ] { + let (mut e, t, ids) = long(mode, &[(0, 10_000, 0), (20_000, 10_000, 0), (30_000, 10_000, 0), (40_000, 10_000, 0)]); + set_points(&mut e, t, &[0, 9_000, 40_000, 49_000]); + run(&mut e, "edit.clear", json!({"clips": [ids[1].0, ids[2].0], "tracks": [t.0], "start": 0})); + assert_eq!(clips(&e, t), want, "{mode}"); + assert_eq!(points(&e, t), want_points, "{mode}"); + } +} + #[test] fn relative_grid_pastes_land_on_grid_lines_at_any_tempo() { let (mut e, t, [a, _]) = engine("relative_grid"); From 5a1324b8bc2b0d74dcb969eb0d2e3c8a786f1cf7 Mon Sep 17 00:00:00 2001 From: ydking0911 Date: Fri, 30 Oct 2026 16:13:42 +0900 Subject: [PATCH 09/46] Clear: lift clips removed by id in Shuffle so crossfade partners don't overlap --- crates/engine/src/edit.rs | 33 +++++++++++++-------------------- crates/engine/src/edit/tests.rs | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/crates/engine/src/edit.rs b/crates/engine/src/edit.rs index f83d199f..9fdb49f0 100644 --- a/crates/engine/src/edit.rs +++ b/crates/engine/src/edit.rs @@ -177,28 +177,21 @@ pub fn clear_range(s: &mut Session, track: TrackId, range: Range, shuffle: bool) removed } -/// Remove the clips `ids` from every track. In Shuffle the later clips on each track close the gaps they leave, -/// the latest gap first so the earlier ones stay where they were. Returns how many clips went. +/// Remove the clips `ids` from every track. In Shuffle the later clips on each track close the holes the movable +/// ones leave, as a Shuffle move lifts them (see [`lift_plan`]), so a crossfade partner keeps its material. Returns +/// how many clips went. pub fn remove_clips(s: &mut Session, ids: &[ClipId], shuffle: bool) -> usize { - let mut gaps: Vec<(TrackId, Range)> = Vec::new(); - for t in &mut s.tracks { - let track = t.id; - if let Some(pl) = t.playlist_mut() { - pl.clips.retain(|c| { - let gone = ids.contains(&c.id); - if gone { - gaps.push((track, c.range())); - } - !gone - }); + let ids: HashSet = ids.iter().copied().collect(); + let mut n = 0; + for track in s.tracks.iter().map(|t| t.id).collect::>() { + if shuffle { + n += lift_all(s, track, &ids).len(); } - } - let n = gaps.len(); - if shuffle { - gaps.sort_by_key(|(t, r)| (t.0, std::cmp::Reverse(r.start))); - for (track, r) in gaps { - let moved = ripple(s, track, r.end, -r.len()); - follow_automation(s, track, r.end, moved); + // Locked clips don't lift; they go without closing up, as everything does outside Shuffle. + if let Some(pl) = s.track_mut(track).and_then(|t| t.playlist_mut()) { + let before = pl.clips.len(); + pl.clips.retain(|c| !ids.contains(&c.id)); + n += before - pl.clips.len(); } } n diff --git a/crates/engine/src/edit/tests.rs b/crates/engine/src/edit/tests.rs index 82d40a42..cd84d6f0 100644 --- a/crates/engine/src/edit/tests.rs +++ b/crates/engine/src/edit/tests.rs @@ -175,6 +175,24 @@ fn remove_clips_closes_each_gap_in_shuffle_only() { assert_eq!(split(true), vec![(1000, 1000, 2000), (2000, 1000, 4000)]); } +#[test] +fn remove_clips_in_shuffle_keeps_crossfade_partners_apart() { + // `(start, end)` of each clip; the second one goes. + let remove_second = |spans: &[(Samples, Samples)]| { + let (mut s, t) = session_with_clip(); + let ids: Vec = spans.iter().map(|_| s.new_clip_id()).collect(); + if let Some(pl) = s.track_mut(t).and_then(|t| t.playlist_mut()) { + pl.clips = ids.iter().zip(spans).map(|(id, (a, b))| Clip::audio(*id, "c", SourceId(500), *a, *a, b - a)).collect(); + } + assert_eq!(remove_clips(&mut s, &[ids[1]], true), 1); + clips(&s, t).into_iter().map(|(start, len, _)| (start, start + len)).collect::>() + }; + // Crossfaded with the clip before: the hole starts where that one ends. + assert_eq!(remove_second(&[(0, 1050), (950, 2000), (2000, 3000)]), vec![(0, 1050), (1050, 2050)]); + // Crossfaded with the clip after: the hole ends where that one starts. + assert_eq!(remove_second(&[(0, 1000), (1000, 2050), (1950, 3000), (4000, 5000)]), vec![(0, 1000), (1000, 2050), (3050, 4050)]); +} + #[test] fn copy_paste_overwrites() { let (mut s, t) = session_with_clip(); From 3bd3965c51e48348e697bd861a580fa2f725387e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Mittelst=C3=A4dt?= <62167861+TheGalitube@users.noreply.github.com> Date: Fri, 30 Oct 2026 07:29:26 +0000 Subject: [PATCH 10/46] Reject oversized CAF cookie lengths Found while testing crates/audio-io/src/caf.rs:23 Co-Authored-By: GPT-6-Luna --- crates/audio-io/src/caf.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/audio-io/src/caf.rs b/crates/audio-io/src/caf.rs index 94ae7f04..9d3d9ccb 100644 --- a/crates/audio-io/src/caf.rs +++ b/crates/audio-io/src/caf.rs @@ -20,7 +20,7 @@ fn chunks(b: &[u8], mut pos: usize) -> Result<()> { // Whether the packet table lists each packet's size and frame count (variable per packet). let (mut lists_sizes, mut lists_frames, mut described) = (false, false, false); while let (Some(kind), Some(size)) = (b.get(pos..pos + 4), be_u64(b, pos + 4)) { - let (body, size) = (pos + 12, size as i64); + let body = pos + 12; let used = match kind { b"desc" if size == 32 => { lists_sizes = be_u32(b, body + 16) == Some(0); @@ -28,12 +28,12 @@ fn chunks(b: &[u8], mut pos: usize) -> Result<()> { described = true; Some(32) } - b"data" if size == -1 => Some(4), + b"data" if size == u64::MAX => Some(4), b"chan" if size >= 12 => be_u32(b, body + 8).map(|n| 12 + u64::from(n) * 20), b"pakt" if size >= 24 && described => packet_table(b, body, lists_sizes, lists_frames)?, - b"kuki" if size >= 0 && size as u64 > b.len().saturating_sub(body) as u64 => return Err(malformed("magic cookie")), + b"kuki" if size > b.len().saturating_sub(body) as u64 => return Err(malformed("magic cookie")), b"desc" | b"pakt" | b"chan" => None, - _ => u64::try_from(size).ok(), + _ => Some(size), }; match used.filter(|_| described).and_then(|n| usize::try_from(n).ok()).and_then(|n| body.checked_add(n)) { Some(next) if next < b.len() => pos = next, @@ -85,3 +85,14 @@ fn varint(b: &[u8], at: usize) -> Option<(u64, usize)> { } None } + +#[cfg(test)] +mod tests { + #[test] + fn rejects_cookie_size_above_signed_range() { + let mut bytes = b"caff\0\x01\0\0kuki".to_vec(); + bytes.extend_from_slice(&(1u64 << 63).to_be_bytes()); + + assert!(super::check(&bytes, 0).is_err()); + } +} From 90e8f60bad69b06f5a0e3c81ce971a46d9c83ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Mittelst=C3=A4dt?= <62167861+TheGalitube@users.noreply.github.com> Date: Fri, 30 Oct 2026 07:51:31 +0000 Subject: [PATCH 11/46] Reject skipped drop-frame timecode labels Found while testing crates/time/src/format.rs:120 Co-Authored-By: GPT-6-Luna --- crates/time/src/format.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/time/src/format.rs b/crates/time/src/format.rs index 65a338ee..3268ef0f 100644 --- a/crates/time/src/format.rs +++ b/crates/time/src/format.rs @@ -120,6 +120,12 @@ pub fn parse_position( if tc.minutes >= 60 || tc.seconds >= 60 || tc.frames >= rate.nominal().max(1) { return Err(err()); } + if rate.is_drop() && tc.seconds == 0 && tc.minutes % 10 != 0 { + let dropped = if rate.nominal() >= 60 { 4 } else { 2 }; + if tc.frames < dropped { + return Err(err()); + } + } Ok(tc.to_samples(rate, sr).saturating_sub(tc_start)) } TimeFormat::FeetFrames => { @@ -213,6 +219,20 @@ mod tests { assert!(parse_position("", TimeFormat::BarsBeats, sr, &map, rate, 0, 0).is_err()); } + #[test] + fn drop_frame_skipped_labels_are_rejected() { + let (sr, map, _) = ctx(); + for (rate, skipped) in [ + (FrameRate::Fps29_97Drop, &["00:01:00;00", "00:01:00;01"][..]), + (FrameRate::Fps59_94Drop, &["00:01:00;00", "00:01:00;01", "00:01:00;02", "00:01:00;03"][..]), + ] { + for text in skipped { + assert!(parse_position(text, TimeFormat::Timecode, sr, &map, rate, 0, 0).is_err(), "accepted skipped label {text} at {rate:?}"); + } + assert!(parse_position("00:10:00;00", TimeFormat::Timecode, sr, &map, rate, 0, 0).is_ok()); + } + } + #[test] fn bar_lengths() { let (sr, map, rate) = ctx(); From 8da40bef96db521705db4ba00de640fd985d74c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Mittelst=C3=A4dt?= <62167861+TheGalitube@users.noreply.github.com> Date: Fri, 30 Oct 2026 08:58:10 +0000 Subject: [PATCH 12/46] Reject overflowing WAV byte rates Found while testing crates/audio-io/src/wav.rs:514 Co-Authored-By: GPT-6-Luna --- crates/audio-io/src/wav.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/audio-io/src/wav.rs b/crates/audio-io/src/wav.rs index 532c2460..9edbb3d8 100644 --- a/crates/audio-io/src/wav.rs +++ b/crates/audio-io/src/wav.rs @@ -503,6 +503,7 @@ pub(crate) fn header( ) -> Result> { let block = usize::from(bits / 8).checked_mul(channels).ok_or_else(|| AudioError::TooLarge("block size overflow".into()))?; let block_align = u16::try_from(block).map_err(|_| AudioError::Encode("too many channels for WAV".into()))?; + let byte_rate = sample_rate.checked_mul(u32::from(block_align)).ok_or_else(|| AudioError::Encode("WAV byte rate overflow".into()))?; let data_len = u64::from(block_align).checked_mul(frames).ok_or_else(|| AudioError::TooLarge("data size overflow".into()))?; let extensible = channels > 2 || bits > 16 || mask.is_some_and(|m| m != channel_mask(channels)); let fmt_tag = if is_float { WAVE_FORMAT_IEEE_FLOAT } else { WAVE_FORMAT_PCM }; @@ -511,7 +512,7 @@ pub(crate) fn header( fmt.extend_from_slice(&(if extensible { WAVE_FORMAT_EXTENSIBLE } else { fmt_tag }).to_le_bytes()); fmt.extend_from_slice(&(channels as u16).to_le_bytes()); fmt.extend_from_slice(&sample_rate.to_le_bytes()); - fmt.extend_from_slice(&sample_rate.saturating_mul(u32::from(block_align)).to_le_bytes()); + fmt.extend_from_slice(&byte_rate.to_le_bytes()); fmt.extend_from_slice(&block_align.to_le_bytes()); fmt.extend_from_slice(&bits.to_le_bytes()); if extensible { @@ -560,3 +561,14 @@ pub(crate) fn header( head.extend_from_slice(&(if rf64 { u32::MAX } else { data_len as u32 }).to_le_bytes()); Ok(head) } + +#[cfg(test)] +mod tests { + use super::header; + + #[test] + fn rejects_byte_rate_overflow() { + let result = header(2, 1_100_000_000, (16, false), None, None, 0, false); + assert!(result.is_err(), "overflowing byte rate was accepted"); + } +} From ddfe991a8700bb741967f7effa61dc37c22d7f7c Mon Sep 17 00:00:00 2001 From: Kushagra Kumar Date: Sat, 31 Oct 2026 05:02:20 +0530 Subject: [PATCH 13/46] Reject overflowing FLAC vendor string lengths Vorbis comment pre-flight validation skipped the vendor string unread without checking whether its declared length fit inside the metadata block. An overflowing vendor length caused the comment count lookup to evaluate to None and return false from comments_overrun, allowing malformed buffers to bypass pre-flight rejection and reach Symphonia. Validate the vendor string length against the remaining bytes in the block before advancing, and add a regression test for Vorbis comment blocks with overflowing vendor lengths. --- crates/audio-io/src/flac.rs | 9 ++++++--- crates/audio-io/tests/it/malformed.rs | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/audio-io/src/flac.rs b/crates/audio-io/src/flac.rs index 1aef23b9..8f489047 100644 --- a/crates/audio-io/src/flac.rs +++ b/crates/audio-io/src/flac.rs @@ -511,10 +511,13 @@ pub(crate) fn empty_stream_info(b: &[u8], at: usize) -> Option { Some(AudioInfo { format: FileFormat::Flac, sample_format, sample_rate, channels, frames: 0, bwf: None }) } -/// Whether a comment in a (little-endian) Vorbis comment block claims more than the block holds. -/// The vendor string is skipped unread. +/// Whether a vendor string or comment in a (little-endian) Vorbis comment block claims more than +/// the block holds. fn comments_overrun(b: &[u8], body: usize, end: usize) -> bool { - let Some(vendor) = le_u32(b, body) else { return false }; + let Some(vendor) = le_u32(b, body).filter(|_| body.saturating_add(4) <= end) else { return false }; + if vendor as usize > end - (body + 4) { + return true; + } let at = (body + 4).saturating_add(vendor as usize); let Some(count) = le_u32(b, at).filter(|_| at.saturating_add(4) <= end) else { return false }; overruns(b, at + 4, end, le_u32, std::iter::repeat_n(0, count as usize)) diff --git a/crates/audio-io/tests/it/malformed.rs b/crates/audio-io/tests/it/malformed.rs index 0351725d..5e243b89 100644 --- a/crates/audio-io/tests/it/malformed.rs +++ b/crates/audio-io/tests/it/malformed.rs @@ -366,6 +366,7 @@ fn packets_longer_than_any_codec_uses_are_refused() { } } +/// FLAC metadata blocks with field lengths exceeding their block boundary are refused as malformed. #[test] fn flac_metadata_fields_beyond_their_block_are_refused() { let with_block = |kind: u8, body: &[u8]| { @@ -376,7 +377,8 @@ fn flac_metadata_fields_beyond_their_block_are_refused() { let picture = |data: u32| [&[0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0][..], &[0; 16], &data.to_be_bytes(), &[1, 2, 3]].concat(); assert_eq!(decode(&with_block(6, &picture(3)), None).unwrap().1.frames(), 300); let comment = [&0u32.to_le_bytes()[..], &1u32.to_le_bytes(), &u32::MAX.to_le_bytes()].concat(); - for f in [with_block(6, &picture(0x7fff_fff0)), with_block(4, &comment)] { + let vendor_overflow = [&0x7fff_fff0u32.to_le_bytes()[..], &0u32.to_le_bytes()].concat(); + for f in [with_block(6, &picture(0x7fff_fff0)), with_block(4, &comment), with_block(4, &vendor_overflow)] { assert!(matches!(decode(&f, None), Err(AudioError::Malformed(m)) if m.contains("larger than its block"))); } } From cc02045a2d4f305673f30fe8e833d0076055ed01 Mon Sep 17 00:00:00 2001 From: Kushagra Kumar Date: Sat, 31 Oct 2026 05:02:24 +0530 Subject: [PATCH 14/46] Contributors: add kk376 to people.toml --- contributors/people.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index 1f6e43e8..abd1e8d1 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -68,3 +68,7 @@ sync_github_name = true [people.dylanmtaylor] sync_github_name = true + +[people.kk376] +real_name = "Kushagra Kumar" +sync_github_name = true From f7b0805de65444a6a80e6f1884d151ba0ffe8e3f Mon Sep 17 00:00:00 2001 From: Kushagra Kumar Date: Sat, 31 Oct 2026 05:35:09 +0530 Subject: [PATCH 15/46] fix(engine): bound MIDI import tempo and track floods (#890) import_midi_bytes capped meter changes at MAX_MIDI_METERS (10,000), but left imported tempo events and synth tracks unbounded. Dense MIDI files inserted unlimited tempo markers into the session tempo map, degrading linear tick-to-sample conversions across playback and audio processing, and instantiated up to 4,096 synth tracks for controller-only tracks. Add MAX_MIDI_TEMPOS (10,000) and MAX_MIDI_TRACKS (512) caps checked before session mutation, and collapse consecutive equal tempo events. --- crates/engine/src/io/midi.rs | 20 +++++++++++- crates/engine/src/io/render.rs | 56 +++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/io/midi.rs b/crates/engine/src/io/midi.rs index f97b5709..9711eccd 100644 --- a/crates/engine/src/io/midi.rs +++ b/crates/engine/src/io/midi.rs @@ -2,18 +2,36 @@ use super::{ChannelFormat, Clip, ClipContent, Engine, EngineError, Result, Sampl /// Most meter changes a MIDI file may bring into the tempo map; scores have a handful. pub(super) const MAX_MIDI_METERS: usize = 10_000; +/// Most tempo changes a MIDI file may bring into the tempo map: conversions walk the tempo events. +pub(super) const MAX_MIDI_TEMPOS: usize = 10_000; +/// Most synth tracks a MIDI file may create in the session. +pub(super) const MAX_MIDI_TRACKS: usize = 512; /// Import a Standard MIDI File as MIDI tracks (one per SMF track). pub fn import_midi_bytes(e: &mut Engine, bytes: &[u8], at: Samples, tempo_map: bool) -> Result> { let smf = soundcraft_midi::read_smf(bytes).map_err(|err| EngineError::Io(err.to_string()))?; - let s = e.session_mut(); if tempo_map { // Each meter is placed by walking the ones before it. if smf.meters.len() > MAX_MIDI_METERS { return Err(EngineError::Io(format!("MIDI file: more than {MAX_MIDI_METERS} meter changes"))); } + if smf.tempos.len() > MAX_MIDI_TEMPOS { + return Err(EngineError::Io(format!("MIDI file: more than {MAX_MIDI_TEMPOS} tempo changes"))); + } + } + let tracks_to_import = smf.tracks.iter().filter(|tr| !tr.sequence.notes.is_empty() || !tr.sequence.ctrls.is_empty()).count(); + if tracks_to_import > MAX_MIDI_TRACKS { + return Err(EngineError::Io(format!("MIDI file: more than {MAX_MIDI_TRACKS} tracks"))); + } + let s = e.session_mut(); + if tempo_map { + let mut last_bpm = None; for (tick, bpm) in &smf.tempos { + if last_bpm == Some(*bpm) { + continue; + } let _ = s.tempo.set_tempo(*tick, *bpm); + last_bpm = Some(*bpm); } for (tick, n, d) in &smf.meters { let _ = s.tempo.set_meter(*tick, u32::from(*n), u32::from(*d)); diff --git a/crates/engine/src/io/render.rs b/crates/engine/src/io/render.rs index 5d0f0f94..a8186da6 100644 --- a/crates/engine/src/io/render.rs +++ b/crates/engine/src/io/render.rs @@ -1,6 +1,6 @@ use super::import::add_source; #[cfg(test)] -use super::midi::{MAX_MIDI_METERS, import_midi_bytes}; +use super::midi::{MAX_MIDI_METERS, MAX_MIDI_TEMPOS, MAX_MIDI_TRACKS, import_midi_bytes}; use super::{AudioBuffer, Clip, ClipContent, Engine, EngineError, FileFormat, Range, Result, Samples, Session, TrackId, TrackKind}; /// Consolidate `r` on a track into one new clip backed by a rendered source. The clip covers the @@ -196,6 +196,60 @@ mod name_tests { assert!(err.to_string().contains("meter changes"), "{err}"); } + /// A MIDI file with more tempo changes than MAX_MIDI_TEMPOS is refused without mutating the session. + #[test] + fn midi_with_more_tempo_changes_than_performances_have_is_refused() { + let note = soundcraft_midi::Note { pitch: 60, velocity: 100, release_velocity: 64, channel: 0, start: 0, length: 960 }; + let sequence = soundcraft_midi::Sequence { notes: vec![note], ..Default::default() }; + let smf = |n: usize| soundcraft_midi::Smf { + tracks: vec![soundcraft_midi::SmfTrack { name: String::new(), sequence: sequence.clone() }], + tempos: (0..n as i64).map(|beat| (beat * 960, 100.0 + (beat % 40) as f64)).collect(), + ..Default::default() + }; + let mut e = Engine::default(); + let err = import_midi_bytes(&mut e, &soundcraft_midi::write_smf(&smf(MAX_MIDI_TEMPOS + 1)).unwrap(), 0, true).unwrap_err(); + assert!(err.to_string().contains("tempo changes"), "{err}"); + assert_eq!((e.session().tempo.tempos().len(), e.session().tracks.len()), (1, 0), "nothing is imported"); + import_midi_bytes(&mut e, &soundcraft_midi::write_smf(&smf(MAX_MIDI_TEMPOS)).unwrap(), 0, true).unwrap(); + assert_eq!(e.session().tempo.tempos().len(), MAX_MIDI_TEMPOS); + } + + /// A MIDI file with more tracks than MAX_MIDI_TRACKS is refused without mutating the session. + #[test] + fn midi_with_more_tracks_than_supported_is_refused() { + let note = soundcraft_midi::Note { pitch: 60, velocity: 100, release_velocity: 64, channel: 0, start: 0, length: 960 }; + let sequence = soundcraft_midi::Sequence { notes: vec![note], ..Default::default() }; + let smf = |n: usize| soundcraft_midi::Smf { + tracks: (0..n).map(|i| soundcraft_midi::SmfTrack { name: format!("Tr {i}"), sequence: sequence.clone() }).collect(), + ..Default::default() + }; + let mut e = Engine::default(); + let err = import_midi_bytes(&mut e, &soundcraft_midi::write_smf(&smf(MAX_MIDI_TRACKS + 1)).unwrap(), 0, false).unwrap_err(); + assert!(err.to_string().contains("tracks"), "{err}"); + assert_eq!(e.session().tracks.len(), 0, "no tracks imported"); + import_midi_bytes(&mut e, &soundcraft_midi::write_smf(&smf(MAX_MIDI_TRACKS)).unwrap(), 0, false).unwrap(); + assert_eq!(e.session().tracks.len(), MAX_MIDI_TRACKS); + } + + /// Consecutive equal tempo events in a MIDI file are collapsed to actual tempo changes. + #[test] + fn midi_collapses_equal_consecutive_tempos() { + let note = soundcraft_midi::Note { pitch: 60, velocity: 100, release_velocity: 64, channel: 0, start: 0, length: 960 }; + let sequence = soundcraft_midi::Sequence { notes: vec![note], ..Default::default() }; + let smf = soundcraft_midi::Smf { + tracks: vec![soundcraft_midi::SmfTrack { name: String::new(), sequence }], + tempos: vec![(0, 120.0), (960, 120.0), (1920, 140.0), (2880, 140.0), (3840, 100.0)], + ..Default::default() + }; + let mut e = Engine::default(); + import_midi_bytes(&mut e, &soundcraft_midi::write_smf(&smf).unwrap(), 0, true).unwrap(); + let tempos = e.session().tempo.tempos(); + assert_eq!(tempos.len(), 3); + assert!((tempos[0].bpm - 120.0).abs() < 1e-3); + assert!((tempos[1].bpm - 140.0).abs() < 1e-3); + assert!((tempos[2].bpm - 100.0).abs() < 1e-3); + } + #[test] fn new_sources_take_the_first_free_file_name() { let mut s = Session::default(); From af4dd7ce4c798c92421140b99fd927cce1665c67 Mon Sep 17 00:00:00 2001 From: Kushagra Kumar Date: Sat, 31 Oct 2026 05:35:13 +0530 Subject: [PATCH 16/46] Contributors: add kk376 to people.toml --- contributors/people.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index 1f6e43e8..abd1e8d1 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -68,3 +68,7 @@ sync_github_name = true [people.dylanmtaylor] sync_github_name = true + +[people.kk376] +real_name = "Kushagra Kumar" +sync_github_name = true From e8bc4758ccb4881e6c427fbccd0f0df750d31dd8 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 30 Oct 2026 20:12:19 -0400 Subject: [PATCH 17/46] fix(flatpak): allow reading launcher version pins (#1210) * fix(flatpak): allow reading launcher version pins * fix(flatpak): allow reading launcher version pins --- packaging/linux/flatpak/ai.storyteller.soundcraft.bundle.yml | 1 + packaging/linux/flatpak/ai.storyteller.soundcraft.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/packaging/linux/flatpak/ai.storyteller.soundcraft.bundle.yml b/packaging/linux/flatpak/ai.storyteller.soundcraft.bundle.yml index 977ec3ee..ffce6828 100644 --- a/packaging/linux/flatpak/ai.storyteller.soundcraft.bundle.yml +++ b/packaging/linux/flatpak/ai.storyteller.soundcraft.bundle.yml @@ -18,6 +18,7 @@ runtime-version: '25.08' sdk: org.freedesktop.Sdk command: soundcraft finish-args: + - --filesystem=xdg-data/ArtCraft/versions:ro # Display: Wayland first; X11 only when no Wayland compositor is running. - --socket=wayland - --socket=fallback-x11 diff --git a/packaging/linux/flatpak/ai.storyteller.soundcraft.yml b/packaging/linux/flatpak/ai.storyteller.soundcraft.yml index 4af6251f..02bad718 100644 --- a/packaging/linux/flatpak/ai.storyteller.soundcraft.yml +++ b/packaging/linux/flatpak/ai.storyteller.soundcraft.yml @@ -23,6 +23,7 @@ sdk-extensions: - org.freedesktop.Sdk.Extension.rust-stable command: soundcraft finish-args: + - --filesystem=xdg-data/ArtCraft/versions:ro # Display: Wayland first; X11 only when no Wayland compositor is running. - --socket=wayland - --socket=fallback-x11 From 966e253873734b6e25f11b2009ccb2313ac03a3a Mon Sep 17 00:00:00 2001 From: Kushagra Kumar Date: Sat, 31 Oct 2026 05:50:50 +0530 Subject: [PATCH 18/46] fix(engine): skip duplicate MIDI tempos only when session tempo matches Collapse consecutive duplicate SMF tempos only if the session tempo at the event tick already matches, so existing session tempo markers are overridden as expected. --- crates/engine/src/io/midi.rs | 4 +--- crates/engine/src/io/render.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/io/midi.rs b/crates/engine/src/io/midi.rs index 9711eccd..4f2bc153 100644 --- a/crates/engine/src/io/midi.rs +++ b/crates/engine/src/io/midi.rs @@ -25,13 +25,11 @@ pub fn import_midi_bytes(e: &mut Engine, bytes: &[u8], at: Samples, tempo_map: b } let s = e.session_mut(); if tempo_map { - let mut last_bpm = None; for (tick, bpm) in &smf.tempos { - if last_bpm == Some(*bpm) { + if s.tempo.tempo_at_tick(*tick) == *bpm { continue; } let _ = s.tempo.set_tempo(*tick, *bpm); - last_bpm = Some(*bpm); } for (tick, n, d) in &smf.meters { let _ = s.tempo.set_meter(*tick, u32::from(*n), u32::from(*d)); diff --git a/crates/engine/src/io/render.rs b/crates/engine/src/io/render.rs index a8186da6..dafa8897 100644 --- a/crates/engine/src/io/render.rs +++ b/crates/engine/src/io/render.rs @@ -250,6 +250,23 @@ mod name_tests { assert!((tempos[2].bpm - 100.0).abs() < 1e-3); } + /// A MIDI file replaces an existing session tempo event even if the MIDI file has consecutive equal tempos. + #[test] + fn midi_import_replaces_differing_existing_session_tempo() { + let note = soundcraft_midi::Note { pitch: 60, velocity: 100, release_velocity: 64, channel: 0, start: 0, length: 960 }; + let sequence = soundcraft_midi::Sequence { notes: vec![note], ..Default::default() }; + let smf = soundcraft_midi::Smf { + tracks: vec![soundcraft_midi::SmfTrack { name: String::new(), sequence }], + tempos: vec![(0, 120.0), (960, 120.0)], + ..Default::default() + }; + let mut e = Engine::default(); + e.session_mut().tempo.set_tempo(960, 80.0).unwrap(); + assert_eq!(e.session().tempo.tempo_at_tick(960), 80.0); + import_midi_bytes(&mut e, &soundcraft_midi::write_smf(&smf).unwrap(), 0, true).unwrap(); + assert_eq!(e.session().tempo.tempo_at_tick(960), 120.0); + } + #[test] fn new_sources_take_the_first_free_file_name() { let mut s = Session::default(); From 331b1820dbde29775d10bf396383cac304829ba4 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 02:29:44 +0000 Subject: [PATCH 19/46] Default range start to the selection start in range_param Found while testing crates/engine/src/cmd.rs:326-336 (range_param), used by crates/engine/src/cmd/event.rs:148 (insert_time) and :172 (cut_time) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd.rs | 8 ++++++-- crates/engine/src/cmd/event.rs | 28 ++++++++++++++++++++++++++++ crates/engine/src/cmd/event_more.rs | 16 +++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 9b9d7954..cbba05c1 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -324,11 +324,15 @@ fn position_param_raw(e: &Engine, cmd: &str, p: &Value, key: &str) -> Result Result { - let st = position_param(e, cmd, p, "start")?; + let mut st = if p.get("start").is_some_and(Value::is_null) { None } else { position_param(e, cmd, p, "start")? }; let en = position_param(e, cmd, p, "end")?; let len = position_param(e, cmd, p, "length")?; + if st.is_none() && (en.is_some() || len.is_some()) { + st = Some(e.session().edit.selection.start); + } match (st, en, len) { (Some(a), Some(b), _) => Ok(Range::new(a, b)), (Some(a), None, Some(l)) => Ok(Range::new(a, a.saturating_add(l))), diff --git a/crates/engine/src/cmd/event.rs b/crates/engine/src/cmd/event.rs index efe6233a..a1f4ef4e 100644 --- a/crates/engine/src/cmd/event.rs +++ b/crates/engine/src/cmd/event.rs @@ -427,6 +427,34 @@ mod tests { use crate::demo::demo_engine; use serde_json::json; + /// `start` is optional for insert/cut time: it defaults to the selection start, then `end`/`length` apply. + #[test] + fn insert_and_cut_time_without_start_use_selection_start() { + use soundcraft_time::Range; + let mut e = demo_engine(); + let a = e.session().edit.selection.start; + let run = |e: &mut crate::Engine, sel: Range, id: &str, params: serde_json::Value| { + e.session_mut().edit.selection = sel; + e.execute(id, ¶ms).unwrap() + }; + // Point selection. + assert_eq!(run(&mut e, Range::point(a), "event.insert_time", json!({"length": 48000}))["inserted"], 48000); + assert_eq!(run(&mut e, Range::point(a), "event.cut_time", json!({"end": a + 5000}))["removed"], 5000); + assert_eq!(run(&mut e, Range::point(a), "event.cut_time", json!({"length": 700}))["removed"], 700); + // A non-empty selection must not override the given `end`/`length`. + let sel = Range::new(a, a + 100); + assert_eq!(run(&mut e, sel, "event.insert_time", json!({"length": 48000}))["inserted"], 48000); + assert_eq!(run(&mut e, sel, "event.insert_time", json!({"end": a + 2000}))["inserted"], 2000); + assert_eq!(run(&mut e, sel, "event.cut_time", json!({"end": a + 5000}))["removed"], 5000); + // A null `start` takes the same path. + assert_eq!(run(&mut e, sel, "event.cut_time", json!({"start": null, "end": a + 3000}))["removed"], 3000); + assert_eq!(run(&mut e, sel, "event.insert_time", json!({"start": null, "length": 900}))["inserted"], 900); + // An explicit `start` still wins over the selection. + let r = run(&mut e, sel, "event.cut_time", json!({"start": a + 1000, "end": a + 3000})); + assert_eq!(r["removed"], 2000); + assert_eq!(run(&mut e, sel, "event.insert_time", json!({"start": a + 1000, "length": 500}))["inserted"], 500); + } + /// The tempo-ruler dialog runs `event.tempo` with `bpm` and `at`; the change must land at that position. #[test] fn tempo_change_at_position_is_applied() { diff --git a/crates/engine/src/cmd/event_more.rs b/crates/engine/src/cmd/event_more.rs index 678cf3aa..6f5b73b3 100644 --- a/crates/engine/src/cmd/event_more.rs +++ b/crates/engine/src/cmd/event_more.rs @@ -274,7 +274,12 @@ fn tempo_curve(e: &mut Engine, p: &Value, curve: Curve, id: &str) -> Result Result { let id = "event.tempo_stretch"; - let (r, t0, t1) = selection_ticks(e, p, id)?; + // Here `length` is the new length of the selection, not part of the range. + let mut range_params = p.clone(); + if let Some(m) = range_params.as_object_mut() { + m.remove("length"); + } + let (r, t0, t1) = selection_ticks(e, &range_params, id)?; let factor = match position_param(e, id, p, "length")? { Some(l) if l > 0 => l as f64 / r.len() as f64, _ => f64_or(p, "factor", f64::NAN), @@ -901,6 +906,15 @@ mod tests { } } + /// For `event.tempo_stretch`, `length` is the new length of the selection, so the selection stays the range. + #[test] + fn tempo_stretch_length_keeps_selection_range() { + let mut e = Engine::default(); + e.session_mut().edit.selection = Range::new(0, 96_000); + e.execute("event.tempo_stretch", &json!({"length": 192_000})).unwrap(); + assert_eq!(e.session().tempo.tempo_at_tick(0), 60.0); + } + #[test] fn tempo_curves() { let mut e = Engine::default(); From b2a386bc7ab309b36250ce9b19c7aefca207d8f8 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 02:31:18 +0000 Subject: [PATCH 20/46] Fix integer overflow in AutomationLane::value_at for distant breakpoints Found while testing crates/model/src/automation.rs:161 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/model/src/automation.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/model/src/automation.rs b/crates/model/src/automation.rs index 26bbcae3..650d8add 100644 --- a/crates/model/src/automation.rs +++ b/crates/model/src/automation.rs @@ -158,7 +158,10 @@ impl AutomationLane { if matches!(self.param, AutoParam::Mute | AutoParam::SendMute(_)) { return a.value; } - a.value + (b.value - a.value) * ((at - a.at) as f32 / (b.at - a.at) as f32) + // Widen so far-apart breakpoints cannot overflow i64. + let span = i128::from(b.at) - i128::from(a.at); + let off = i128::from(at) - i128::from(a.at); + a.value + (b.value - a.value) * (off as f64 / span as f64) as f32 } (Some(a), _) => a.value, _ => default, @@ -255,6 +258,17 @@ impl AutomationLane { mod tests { use super::*; + #[test] + fn value_at_far_apart_points_does_not_overflow() { + let mut l = AutomationLane::new(AutoParam::Volume); + l.set_point(-1, 0.0); + l.set_point(i64::MAX, -10.0); + let v = l.value_at(5, 0.0); + assert!(v.is_finite() && (-10.0..=0.0).contains(&v)); + let w = l.value_at(i64::MAX - 1, 0.0); + assert!(w.is_finite() && (-10.0..=0.0).contains(&w)); + } + #[test] fn pan_label_max_does_not_overflow() { assert_eq!(AutoParam::Pan(255).label(), "pan 256"); From 13fe1df4b8d973b372cc42070571657713a04c84 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 02:38:12 +0000 Subject: [PATCH 21/46] Fix overflow in GridValue::step_samples at extreme positions Found while testing crates/time/src/grid.rs:125 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/time/src/grid.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/time/src/grid.rs b/crates/time/src/grid.rs index 13551b52..a78c600e 100644 --- a/crates/time/src/grid.rs +++ b/crates/time/src/grid.rs @@ -122,7 +122,7 @@ impl GridValue { GridValue::Note { value, dotted, triplet } => { let t0 = map.samples_to_ticks(at, sr); let dt = Self::note_ticks(value, dotted, triplet, map, t0); - (map.tick_to_samples(t0 + dt, sr) - map.tick_to_samples(t0, sr)).max(1) + (map.tick_to_samples(t0.saturating_add(dt), sr).saturating_sub(map.tick_to_samples(t0, sr))).max(1) } GridValue::Seconds(s) => sr.samples(s.clamp(0.000_01, 3600.0)).max(1), GridValue::Frames(f) => to_samples(rate.samples_per_frame(sr) * f.clamp(1, 1_000_000) as f64).max(1), @@ -320,4 +320,11 @@ mod tests { assert_eq!(GridValue::Samples(100).stepped(false), GridValue::Samples(10)); assert_eq!(GridValue::Samples(1).stepped(false), GridValue::Samples(1)); } + + #[test] + fn snap_at_extreme_position_does_not_overflow() { + let sr = SampleRate::new(8000).unwrap(); + let map = TempoMap::new(1000.0, 4, 4).unwrap(); + let _ = GridValue::default().snap(i64::MAX, sr, &map, FrameRate::Fps30); + } } From a97ce7556c5362718e8bcab5349477381ff3fb65 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 30 Oct 2026 22:59:18 -0400 Subject: [PATCH 22/46] Release 0.15.0 Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 36 ++++++++++++++++++------------------ Cargo.toml | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5385e0d..7875fdb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4280,7 +4280,7 @@ dependencies = [ [[package]] name = "soundcraft" -version = "0.14.0" +version = "0.15.0" dependencies = [ "chrono", "clap", @@ -4304,7 +4304,7 @@ dependencies = [ [[package]] name = "soundcraft-au-host" -version = "0.14.0" +version = "0.15.0" dependencies = [ "log", "serde", @@ -4314,7 +4314,7 @@ dependencies = [ [[package]] name = "soundcraft-audio-io" -version = "0.14.0" +version = "0.15.0" dependencies = [ "log", "proptest", @@ -4326,7 +4326,7 @@ dependencies = [ [[package]] name = "soundcraft-automation" -version = "0.14.0" +version = "0.15.0" dependencies = [ "clap", "log", @@ -4339,7 +4339,7 @@ dependencies = [ [[package]] name = "soundcraft-clap-host" -version = "0.14.0" +version = "0.15.0" dependencies = [ "clap-sys", "libloading 0.9.0", @@ -4352,7 +4352,7 @@ dependencies = [ [[package]] name = "soundcraft-cli" -version = "0.14.0" +version = "0.15.0" dependencies = [ "clap", "clap_complete", @@ -4369,7 +4369,7 @@ dependencies = [ [[package]] name = "soundcraft-dsp" -version = "0.14.0" +version = "0.15.0" dependencies = [ "log", "proptest", @@ -4380,7 +4380,7 @@ dependencies = [ [[package]] name = "soundcraft-engine" -version = "0.14.0" +version = "0.15.0" dependencies = [ "craft-docpath", "log", @@ -4403,7 +4403,7 @@ dependencies = [ [[package]] name = "soundcraft-midi" -version = "0.14.0" +version = "0.15.0" dependencies = [ "proptest", "serde", @@ -4413,7 +4413,7 @@ dependencies = [ [[package]] name = "soundcraft-mix" -version = "0.14.0" +version = "0.15.0" dependencies = [ "log", "rayon", @@ -4429,7 +4429,7 @@ dependencies = [ [[package]] name = "soundcraft-model" -version = "0.14.0" +version = "0.15.0" dependencies = [ "proptest", "serde", @@ -4442,7 +4442,7 @@ dependencies = [ [[package]] name = "soundcraft-playback" -version = "0.14.0" +version = "0.15.0" dependencies = [ "cpal", "log", @@ -4457,7 +4457,7 @@ dependencies = [ [[package]] name = "soundcraft-time" -version = "0.14.0" +version = "0.15.0" dependencies = [ "proptest", "serde", @@ -4467,7 +4467,7 @@ dependencies = [ [[package]] name = "soundcraft-ui-egui" -version = "0.14.0" +version = "0.15.0" dependencies = [ "craft-ui", "craft-update", @@ -4496,7 +4496,7 @@ dependencies = [ [[package]] name = "soundcraft-video" -version = "0.14.0" +version = "0.15.0" dependencies = [ "craft-media", "image", @@ -4508,7 +4508,7 @@ dependencies = [ [[package]] name = "soundcraft-vst3-host" -version = "0.14.0" +version = "0.15.0" dependencies = [ "libloading 0.9.0", "log", @@ -4524,7 +4524,7 @@ dependencies = [ [[package]] name = "soundcraft-web" -version = "0.14.0" +version = "0.15.0" dependencies = [ "eframe", "egui", @@ -6140,7 +6140,7 @@ checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" [[package]] name = "xtask" -version = "0.14.0" +version = "0.15.0" dependencies = [ "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index fcdb0331..11f6121b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"] default-members = ["crates/*", "apps/*", "xtask"] [workspace.package] -version = "0.14.0" +version = "0.15.0" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.90" From 5288e42bc9c6fbdca2641b13d8fff6b58d25d190 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 31 Oct 2026 04:17:26 +0000 Subject: [PATCH 23/46] docs: tidy agent, contributor and release docs --- AGENTS.md | 13 ++++--------- ATTRIBUTION.md | 16 ++++++++-------- assets/app-icon/README.md | 2 +- contributors/people.toml | 7 ++----- crates/au-host/Cargo.toml | 2 +- crates/au-host/src/lib.rs | 2 +- crates/clap-host/Cargo.toml | 2 +- crates/clap-host/src/lib.rs | 2 +- crates/ui-egui/build.rs | 7 +++---- crates/ui-egui/src/credits.rs | 2 +- crates/vst3-host/Cargo.toml | 2 +- crates/vst3-host/src/lib.rs | 2 +- docs/contributors.md | 25 ++++--------------------- docs/release-playbook.md | 9 --------- docs/releasing.md | 5 ++--- docs/roadmap.md | 3 +-- docs/target-app-parity.md | 2 +- 17 files changed, 33 insertions(+), 70 deletions(-) delete mode 100644 docs/release-playbook.md diff --git a/AGENTS.md b/AGENTS.md index b48565c8..065e8313 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,11 +2,9 @@ SoundCraft is a clean-room, open-source, pure-Rust digital audio workstation targeting Avid Pro Tools parity — and superiority (speed, openness, agent control). It runs natively on macOS, Windows, Linux and FreeBSD, and on the web via WASM. Siblings with the same conventions: `../photocraft` (Photoshop), `../vectorcraft` (Illustrator), `../filmcraft` (Premiere), `../lightcraft` (Lightroom), `../pdfcraft` (Acrobat), `../effectcraft` (After Effects), `../designcraft` (InDesign). -Standards and learnings shared across the crafting apps live in `../../craftrules` (checked out next to the craft-apps folder, or `storytold/craftrules`). Read its `AGENTS.md` at the start of a session, follow its standards, and contribute reusable learnings back there. Never code: repos don't share code. - ## Start every session here 1. Read `plan/STATUS.md` (current milestone, next task) and `plan/execution-plan.md`. `plan/` is gitignored (local only). Behaviour reference: `plan/protools/` (observed menu tree `menus-clean.txt` and screenshots; never committed). -2. Read `ROADMAP.md` (committed) for stage, status and the parity numbers; pick work from `docs/gaps.md`. The progress docs follow craftrules `standards/progress-docs.md`: `docs/target-app-parity.md` (assessment), `docs/gaps.md`, `docs/roadmap.md`, `docs/ui-parity.md`, `docs/file-format-parity.md`, `docs/hardware-parity.md`, `docs/plugin-parity.md`, `docs/localization-parity.md`; `docs/parity-checklist.md` is generated. Update their timestamps and revision history when you change them. +2. Read `ROADMAP.md` (committed) for stage, status and the parity numbers; pick work from `docs/gaps.md`. The progress docs are `docs/target-app-parity.md` (assessment), `docs/gaps.md`, `docs/roadmap.md`, `docs/ui-parity.md`, `docs/file-format-parity.md`, `docs/hardware-parity.md`, `docs/plugin-parity.md`, `docs/localization-parity.md`; `docs/parity-checklist.md` is generated. Update their timestamps and revision history when you change them. 3. Work autonomously; don't stop to ask unless a decision is genuinely the user's. ## ⚠️ Assets: the absolute rule @@ -22,7 +20,7 @@ Standards and learnings shared across the crafting apps live in `../../craftrule Pro Tools is installed on the dev machine and may be *observed* black-box: run it, use its UI with synthetic sessions, take screenshots by window id (`screencapture -l `), stored only under `plan/protools/screenshots/`. Never read, disassemble or copy anything inside the Pro Tools bundle; never copy Avid icons, artwork, plugin names, presets, or wording beyond feature names. Never copy GPL/AGPL/LGPL code (Ardour, Audacity, LMMS, Freeverb sources…). Our plugins have our own names. ## Never crash -People trust SoundCraft with their recordings; a crash loses takes. **This outranks feature work.** Standard: [`craftrules/standards/never-crash.md`](https://github.com/storytold/craftrules/blob/main/standards/never-crash.md). +People trust SoundCraft with their recordings; a crash loses takes. **This outranks feature work.** - No panics in non-test code: no `unwrap()`, `expect()`, `panic!`, `unreachable!`, `todo!`, `unimplemented!`; no `unsafe` (`unsafe_code = "forbid"`). - The one named exception is `soundcraft-clap-host` (`crates/clap-host`), the isolated unsafe helper crate for CLAP plugin FFI: `unsafe_code = "deny"` crate-wide, allowed only in `src/ffi.rs` with a `// SAFETY:` comment on every block, safe `Result` API. - The same exception, same rules, for `soundcraft-vst3-host` (`crates/vst3-host`), the isolated unsafe helper crate for VST3 plugin FFI (COM vtables via the `vst3` bindings, module loading, host-side COM objects). @@ -67,7 +65,7 @@ Parity is measured, not guessed: `crates/engine/catalog/menus.txt` lists the inc `cargo xtask ci` = fmt check, `clippy --workspace --all-targets -D warnings`, tests, assets, layers, wasm check. Commit after each arc of work that builds; one topic per commit. ## Release -Push to the `release` branch to build signed installers for macOS (universal DMG), Windows (x64/x86 MSI + zip), Linux (AppImage, deb, rpm, tar.gz, Flatpak; riscv64 tar.gz), FreeBSD and Web (wasm zip). Version: `cargo xtask version [set X.Y.Z]`. See `docs/release-playbook.md` and craftrules `release/playbook.md`. +Push to the `release` branch to build signed installers for macOS (universal DMG), Windows (x64/x86 MSI + zip), Linux (AppImage, deb, rpm, tar.gz, Flatpak; riscv64 tar.gz), FreeBSD and Web (wasm zip). Version: `cargo xtask version [set X.Y.Z]`. See `docs/releasing.md`. ## Roadmap `ROADMAP.md` (committed) is the one-page summary (stage, numbers, dimensions, languages, progress log); milestones live in `docs/roadmap.md`. Update both whenever a milestone lands, and close or shrink the matching `docs/gaps.md` entry. @@ -81,14 +79,11 @@ Push to the `release` branch to build signed installers for macOS (universal DMG username has a `[people.]` entry in `contributors/people.toml`. If not, ask them once whether they want to be credited by more than their username: a real name, a display name, and/or their public GitHub profile name (`sync_github_name = true`). If yes, add **only their own** entry - (copy the template at the top of the file, or run - `python3 ../../craftrules/scripts/contributors.py --add-me . --real-name "…" --sync-github-name`) + (copy the template at the top of the file) and include it in their PR, committed as them. If no, change nothing: they are credited as `@username` anyway. - Never add, edit, guess or copy anyone else's entry or name (not from git config, commit authors or GitHub profiles). Never hand-edit `contributors.json`. -- Maintainers refresh the stats with `python3 ../../craftrules/scripts/contributors.py .` (it also - re-verifies who wrote each `people.toml` entry; `--check` only verifies). ## CI workflows - Workflows in `.github/workflows/` call the shared workflows in [`storytold/craft-common-actions`](https://github.com/storytold/craft-common-actions) at `@main`, with their inputs and secrets. No other jobs: if no shared workflow does what's needed, it doesn't go here. diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 00927097..dc168fa4 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -39,14 +39,14 @@ here. The subset uses default_fonts; the parent face uses monochrome_emoji_fonts | Path | Author | Source | License | |---|---|---|---| -| `docs/brand/artcraft-logo.svg` | ArtCraft Team | craftrules `assets/brand/` | ArtCraft brand terms (`docs/brand/LICENSE-brand.txt`) | -| `docs/brand/artcraft-logo.png` | ArtCraft Team | craftrules `assets/brand/` | ArtCraft brand terms | -| `docs/brand/artcraft-logo-white.svg` | ArtCraft Team | craftrules `assets/brand/` | ArtCraft brand terms | -| `docs/brand/artcraft-logo-white.png` | ArtCraft Team | craftrules `assets/brand/` | ArtCraft brand terms | -| `docs/brand/artcraft-mark.svg` | ArtCraft Team | craftrules `assets/brand/` | ArtCraft brand terms | -| `docs/brand/artcraft-mark.png` | ArtCraft Team | craftrules `assets/brand/` | ArtCraft brand terms | -| `docs/brand/artcraft-mark-black.svg` | ArtCraft Team | craftrules `assets/brand/` | ArtCraft brand terms | -| `docs/brand/artcraft-mark-black.png` | ArtCraft Team | craftrules `assets/brand/` | ArtCraft brand terms | +| `docs/brand/artcraft-logo.svg` | ArtCraft Team | ArtCraft brand assets | ArtCraft brand terms (`docs/brand/LICENSE-brand.txt`) | +| `docs/brand/artcraft-logo.png` | ArtCraft Team | ArtCraft brand assets | ArtCraft brand terms | +| `docs/brand/artcraft-logo-white.svg` | ArtCraft Team | ArtCraft brand assets | ArtCraft brand terms | +| `docs/brand/artcraft-logo-white.png` | ArtCraft Team | ArtCraft brand assets | ArtCraft brand terms | +| `docs/brand/artcraft-mark.svg` | ArtCraft Team | ArtCraft brand assets | ArtCraft brand terms | +| `docs/brand/artcraft-mark.png` | ArtCraft Team | ArtCraft brand assets | ArtCraft brand terms | +| `docs/brand/artcraft-mark-black.svg` | ArtCraft Team | ArtCraft brand assets | ArtCraft brand terms | +| `docs/brand/artcraft-mark-black.png` | ArtCraft Team | ArtCraft brand assets | ArtCraft brand terms | | `assets/app-icon/icon.svg` | SoundCraft contributors | original (hand-placed SVG paths; placeholder app icon) | MIT OR Apache-2.0 | | `packaging/macos/dmg/` (all files) | @XusBadia | original (macOS DMG window background and layout, from the app icon; see `packaging/macos/dmg/README.md`) | MIT OR Apache-2.0 | | `assets/app-icon/soundcraft-1024.png` | SoundCraft contributors | original, rendered from `icon.svg` | MIT OR Apache-2.0 | diff --git a/assets/app-icon/README.md b/assets/app-icon/README.md index 12cea9c2..196473c9 100644 --- a/assets/app-icon/README.md +++ b/assets/app-icon/README.md @@ -1,7 +1,7 @@ # SoundCraft app icon (placeholder) **A nightingale singing**, as an engraving-style head-and-shoulders portrait in the Crafting Apps' -owl-template framing (craftrules `standards/icon-design.md`): a full-bleed colour field, the bird +owl-template framing: a full-bleed colour field, the bird in three-quarter view with its bill open and its eye on the viewer, its breast and wing running off the bottom and right edges, three song arcs leaving the bill. diff --git a/contributors/people.toml b/contributors/people.toml index 1f6e43e8..e6fab691 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -1,13 +1,10 @@ -# Contributor names for the About window (craftrules standards/contributors.md). +# Contributor names for the About window. # # Everyone who contributes is credited by GitHub username automatically. Anything more is up to # you: add YOUR OWN entry below, in your own PR (commit it yourself). Never add someone else; a # maintainer may add a person only when that person asked, recording where in consent_source. # -# Easiest: python3 ../../craftrules/scripts/contributors.py --add-me . \ -# [--real-name "Ada Lovelace"] [--display-name "Ada"] [--sync-github-name] -# -# Or copy this block, replacing your-github-username (every field is optional): +# Copy this block, replacing your-github-username (every field is optional): # # [people.your-github-username] # real_name = "Your Name" # shown when the viewer picks "Real name" diff --git a/crates/au-host/Cargo.toml b/crates/au-host/Cargo.toml index 122c4919..4e190104 100644 --- a/crates/au-host/Cargo.toml +++ b/crates/au-host/Cargo.toml @@ -13,7 +13,7 @@ serde.workspace = true thiserror.workspace = true log.workspace = true -# An isolated unsafe helper crate (craftrules never-crash), like soundcraft-vst3-host: this crate +# An isolated unsafe helper crate, like soundcraft-vst3-host: this crate # opts out of the workspace `unsafe_code = "forbid"` for itself only. It denies unsafe everywhere # and allows it solely on the FFI module (`src/ffi.rs`). The rest mirrors `[workspace.lints]`. [lints.rust] diff --git a/crates/au-host/src/lib.rs b/crates/au-host/src/lib.rs index 7aa3b2eb..cbb569fb 100644 --- a/crates/au-host/src/lib.rs +++ b/crates/au-host/src/lib.rs @@ -9,7 +9,7 @@ //! values are the Audio Unit's own (plain) values, ranges and units, so no mapping is needed. //! Boolean parameters become toggles, indexed ones starting at 0 become choices. //! -//! Like `soundcraft-vst3-host`, this is an isolated `unsafe` crate (craftrules never-crash): +//! Like `soundcraft-vst3-host`, this is an isolated `unsafe` crate: //! `unsafe` is denied crate-wide and allowed only in the private `ffi` module (hand-written //! AudioToolbox / CoreFoundation declarations). The public API is safe, returns //! `Result`/`Option` and never panics. Limits of in-process hosting: an Audio Unit that itself diff --git a/crates/clap-host/Cargo.toml b/crates/clap-host/Cargo.toml index 27eaf561..fa719ac7 100644 --- a/crates/clap-host/Cargo.toml +++ b/crates/clap-host/Cargo.toml @@ -25,7 +25,7 @@ harness = false clap-sys = "0.5" libloading = "0.9" -# The isolated unsafe helper crate (craftrules never-crash): this crate opts out of the workspace +# The isolated unsafe helper crate: this crate opts out of the workspace # `unsafe_code = "forbid"` for itself only. It denies unsafe everywhere and allows it solely on the # FFI module (`src/ffi.rs`). The rest mirrors `[workspace.lints]`. [lints.rust] diff --git a/crates/clap-host/src/lib.rs b/crates/clap-host/src/lib.rs index a5e042a3..7142a9ee 100644 --- a/crates/clap-host/src/lib.rs +++ b/crates/clap-host/src/lib.rs @@ -5,7 +5,7 @@ //! plugins exactly like the built-in ones. Plugin ids are `clap:`; parameter ids //! are the CLAP param ids as decimal strings, with their human names in [`PluginInfo::params`]. //! -//! This is SoundCraft's single isolated `unsafe` crate (craftrules never-crash): `unsafe` is +//! This is SoundCraft's single isolated `unsafe` crate: `unsafe` is //! denied crate-wide and allowed only in the private `ffi` module. The public API is safe, returns //! `Result`/`Option` and never panics. Limits of in-process hosting: a plugin that itself crashes //! (segfault) takes the process down with it; we cannot sandbox native code. diff --git a/crates/ui-egui/build.rs b/crates/ui-egui/build.rs index f40007fb..3116b01d 100644 --- a/crates/ui-egui/build.rs +++ b/crates/ui-egui/build.rs @@ -1,8 +1,7 @@ -//! Bake the contributor credits into the binary as static Rust tables (craftrules -//! standards/contributors.md). Nothing is read at run time. +//! Bake the contributor credits into the binary as static Rust tables. Nothing is read at run time. //! -//! - contributors/contributors.json: commit stats per GitHub username, generated by craftrules -//! scripts/contributors.py, which also marks whose people.toml entry it verified. +//! - contributors/contributors.json: commit stats per GitHub username, with a mark for whose people.toml +//! entry is verified. //! - contributors/people.toml: the names people chose for themselves. A name is used only when the //! JSON says the entry was verified (`people_entry`). //! diff --git a/crates/ui-egui/src/credits.rs b/crates/ui-egui/src/credits.rs index c22c4720..42804e02 100644 --- a/crates/ui-egui/src/credits.rs +++ b/crates/ui-egui/src/credits.rs @@ -1,6 +1,6 @@ //! The About window's credits: every contributor (GitHub login always; display and real names only //! with recorded consent) and the AI models that helped. The tables are baked into the binary by -//! build.rs from contributors/contributors.json (craftrules standards/contributors.md); nothing is +//! build.rs from contributors/contributors.json; nothing is //! read at run time. use std::cmp::Ordering; diff --git a/crates/vst3-host/Cargo.toml b/crates/vst3-host/Cargo.toml index 7a956118..284e7d54 100644 --- a/crates/vst3-host/Cargo.toml +++ b/crates/vst3-host/Cargo.toml @@ -47,7 +47,7 @@ harness = false name = "module_exit_shutdown" harness = false -# An isolated unsafe helper crate (craftrules never-crash), like soundcraft-clap-host: this crate +# An isolated unsafe helper crate, like soundcraft-clap-host: this crate # opts out of the workspace `unsafe_code = "forbid"` for itself only. It denies unsafe everywhere # and allows it solely on the FFI module (`src/ffi.rs`). The rest mirrors `[workspace.lints]`. [lints.rust] diff --git a/crates/vst3-host/src/lib.rs b/crates/vst3-host/src/lib.rs index 9c76446c..a0324f88 100644 --- a/crates/vst3-host/src/lib.rs +++ b/crates/vst3-host/src/lib.rs @@ -8,7 +8,7 @@ //! [`PluginInfo::params`]. Values are plain (display) values; the host converts to and from the //! VST3 normalized 0..1 values. Stepped parameters become toggles or choices. //! -//! Like `soundcraft-clap-host`, this is an isolated `unsafe` crate (craftrules never-crash): +//! Like `soundcraft-clap-host`, this is an isolated `unsafe` crate: //! `unsafe` is denied crate-wide and allowed only in the private `ffi` module. The public API is //! safe, returns `Result`/`Option` and never panics. Limits of in-process hosting: a plugin that //! itself crashes (segfault) takes the process down with it; we cannot sandbox native code. diff --git a/docs/contributors.md b/docs/contributors.md index bf35050d..33312ac4 100644 --- a/docs/contributors.md +++ b/docs/contributors.md @@ -1,16 +1,14 @@ # Contributors in the About window **About ▸ Contributors** credits everyone who contributed to SoundCraft, and **About ▸ Models** credits -the AI models named in `Co-Authored-By` trailers. This follows the shared craftrules standard -[`standards/contributors.md`](https://github.com/storytold/craftrules/blob/main/standards/contributors.md); -this page is the local copy of the decision. +the AI models named in `Co-Authored-By` trailers. ## Decision - Two files, both **compiled into the binary** by the UI crate's `build.rs` (nothing is read from disk or the network at run time; the web build has them too): - [`contributors/contributors.json`](../contributors/contributors.json): commit stats per GitHub - username. **Generated** by `craftrules/scripts/contributors.py`; never hand-edit. + username. Never hand-edit. - [`contributors/people.toml`](../contributors/people.toml): the names people chose for themselves. **Each contributor adds only their own entry**, in their own PR. - Each contributor gets one line: GitHub username (always), display name (opt-in, or their synced @@ -36,20 +34,5 @@ display_name = "Nickname" sync_github_name = true # use the name on your public GitHub profile as display name ``` -or, with craftrules checked out next to `craft-apps/`: - -```sh -python3 ../../craftrules/scripts/contributors.py --add-me . --real-name "Your Name" --sync-github-name -``` - -Names show after the next refresh: the script checks that each entry was committed by its own -user (or by a maintainer with a `consent_source`). Delete your entry to remove your names. - -## Refreshing (maintainers) - -```sh -python3 ../../craftrules/scripts/contributors.py . # regenerate + verify; needs git, Python 3.11+, gh -python3 ../../craftrules/scripts/contributors.py --check . # verify people.toml only -``` - -Commit the updated `contributors/contributors.json`. Git author names and emails are never recorded. +Names show for entries committed by their own user (or by a maintainer with a `consent_source`). +Delete your entry to remove your names. Git author names and emails are never recorded. diff --git a/docs/release-playbook.md b/docs/release-playbook.md deleted file mode 100644 index aafba970..00000000 --- a/docs/release-playbook.md +++ /dev/null @@ -1,9 +0,0 @@ -# Release playbook - -The release playbook shared by every crafting app lives in craftrules: -[`../craftrules/release/playbook.md`](../../craftrules/release/playbook.md) -(`storytold/craftrules`). It is the canonical copy; don't duplicate it here. - -SoundCraft's implementation (`.github/workflows/release.yml`, `packaging/`, -`cargo xtask version`) was copied from DesignCraft/PhotoCraft and renamed. SoundCraft-specific -details are in [releasing.md](releasing.md). diff --git a/docs/releasing.md b/docs/releasing.md index b877757c..0fdc3502 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -5,7 +5,7 @@ signed installers for macOS, Windows, Linux, FreeBSD and the web, then creates o **draft** GitHub Release named `SoundCraft v`. Nobody sees a draft until a maintainer publishes it. -This is SoundCraft's implementation of the shared [release playbook](release-playbook.md). +This file describes how SoundCraft is released. User-facing names say **SoundCraft**. Files, binaries and ids stay lowercase (`soundcraft---.`, `ai.storyteller.soundcraft`). @@ -208,8 +208,7 @@ are written with `umask 077` and deleted in `always()`/`finally` steps. | `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET` | service principal for Azure Trusted Signing | | `AZURE_SIGNING_ENDPOINT`, `AZURE_SIGNING_ACCOUNT`, `AZURE_CERT_PROFILE` | Trusted Signing endpoint, account and profile | -`GITHUB_TOKEN` creates the release. Only the final job gets `contents: write`. Provisioning the -environment, ruleset and secrets for a new repo: craftrules `release/signing-setup.md`. +`GITHUB_TOKEN` creates the release. Only the final job gets `contents: write`. ## Icons diff --git a/docs/roadmap.md b/docs/roadmap.md index 5219a8e5..2e7eeeeb 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -18,8 +18,7 @@ Hours are Opus 5.5 agent-hours. ## Alpha gate The core workflows a Pro Tools professional does every day, checked end to end on macOS (the -main platform). Any **no** keeps SoundCraft **pre-alpha**, and those rows are the alpha checklist -(craftrules `standards/progress-docs.md`, Stages). +main platform). Any **no** keeps SoundCraft **pre-alpha**, and those rows are the alpha checklist. | Workflow | Works end to end? | Evidence | Hours to pass | |---|---|---|---:| diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index db69e3b3..2bc915dd 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -96,7 +96,7 @@ every command is reachable from the CLI, the JSON control channel and MCP. ## Mainstream practitioner and essentials user -Both use the method in craftrules `standards/progress-docs.md`. Each multiplies a weighted depth +Both use one method. Each multiplies a weighted depth average by written-down discounts. Depths come from the [Feature areas](#feature-areas) table and the evidence there; issue numbers are `storytold/soundcraft` GitHub issues. From 1964662a71a9b2d48a54b7d163fdda18b5a8c512 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 31 Oct 2026 04:25:42 +0000 Subject: [PATCH 24/46] docs: tidy wording --- ROADMAP.md | 6 +++--- docs/gaps.md | 2 +- docs/target-app-parity.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 8ff79f11..c9b87dcd 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -156,8 +156,8 @@ mutated and truncated movies. Field reports from the first public week are track - **2026-10-12 (Mix in a separate window):** Window › Mix in Separate Window shows the Mix window in its own native window, so Edit and Mix can be on screen at once (e.g. one per monitor), as in Pro Tools. No readiness percentage change. - **2026-10-12 (audio device settings):** Setup › Playback Engine chooses the audio system, output and input device, sample rate and buffer size, kept per machine with the preferences; 16/32-bit integer devices are converted; ASIO is available behind the opt-in `asio` build feature (verified with an SSL 2+ at 128 samples). Channel routing, one duplex clock and latency compensation remain (G-01). No readiness percentage change. - **2026-10-10 (UI docking):** Tracks and Groups, Clips, MIDI Editor, Memory Locations, and Undo History use movable panels. Edit and Mix retain separate arrangements; Clips and MIDI Editor belong to Edit. Transport, plug-in, and specialist utility windows retain their existing hosts. Panel moves and reset are available as UI commands, and saved UI preferences retain arrangements. Common toolbar and track record-enable buttons share interaction, accessible labels and keyboard focus through `craft-ui`, retaining blue tool selection and red record-arm states. No readiness percentage change. -- **2026-10-10** — Stage re-normalized to **pre-alpha** by the core-workflow gate (interface recording, MIDI recording and session interchange fail). Full re-measure against Pro Tools Ultimate 2026.4.1 and the standard - progress-docs set (this page, target-app parity, gaps, roadmap, UI/format/hardware/plugin/ +- **2026-10-10** — Stage re-normalized to **pre-alpha** by the core-workflow gate (interface recording, MIDI recording and session interchange fail). Full re-measure against Pro Tools Ultimate 2026.4.1 and the progress docs + set (this page, target-app parity, gaps, roadmap, UI/format/hardware/plugin/ localization parity). v0.4.0 released. Community fixes: Cut All Automation, snap to neighbours, tempo stretch, I/O Setup, clip export names, menu-only dialogs, playback stop on new session. - **2026-10-09** — Light theme and live system appearance, clip-gain fader and nudge, missing-media @@ -204,6 +204,6 @@ mutated and truncated movies. Field reports from the first public week are track | 2026-10-10 | minor | Readiness-by-audience table with hours: full 950–1,450 h, mainstream 380–600 h, essentials 110–200 h | | 2026-10-10 | minor | Added mainstream practitioner ~36 % and essentials user ~57 % to the headline numbers | | 2026-10-10 | minor | Stage alpha → pre-alpha: the core-workflow gate fails on interface recording, MIDI recording and session interchange; alpha distance added | -| 2026-10-10 | major | Rewritten to the progress-docs standard: stage alpha (re-normalized the same day), two numbers (breadth ~70 %, ready ~40 %), dimension/feature/language tables, hours re-calibrated; area table moved to docs/target-app-parity.md, milestones to docs/roadmap.md | +| 2026-10-10 | major | Progress docs restructured: stage alpha (re-normalized the same day), two numbers (breadth ~70 %, ready ~40 %), dimension/feature/language tables, hours re-calibrated; area table moved to docs/target-app-parity.md, milestones to docs/roadmap.md | | 2026-10-07 | major | Menu parity 94 %, ~65 % estimated feature parity, alpha list | | 2026-10-06 | minor | Alpha and parity estimates | diff --git a/docs/gaps.md b/docs/gaps.md index 17b2fe8a..a762162c 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -77,7 +77,7 @@ When you close a gap, delete its entry (or shrink it) in the same PR, and bump t - **Missing:** opening or saving `.ptx`/`.ptf`, AAF and OMF import and export (#40), Media Composer–compatible sessions. Our session format is `.scraft` JSON. -- **Impact:** the standard's main-format bar for beta. A Pro Tools user cannot bring a project in +- **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. - **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 diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 2bc915dd..2992d93e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -125,7 +125,7 @@ immersive delivery, video, notation, and languages other than English. | 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 | | **Result** | 50.6 × 0.90 × 0.92 × 0.85 = **35.6 % ≈ 36 %** | | -This comes out *below* the full number (~40 %), which the standard says is unusual. The +This comes out *below* the full number (~40 %), which is unusual. The mainstream engineer's weekly core is interface recording and MIDI overdubs, exactly the alpha-gate failures. The full number gets partial credit from areas this user doesn't weight: editing breadth, five platforms built, agent control. From 4c31f2884b96992d2840072910f59d2fe445b22f Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 31 Oct 2026 04:42:39 +0000 Subject: [PATCH 25/46] updates: show check results with craft-update's CheckResultDialog --- Cargo.lock | 28 +++++++-------- Cargo.toml | 8 ++--- crates/ui-egui/src/updates_ui.rs | 61 +++++++++++++++----------------- 3 files changed, 46 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7875fdb1..401b3c60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,7 +272,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.59.0", + "windows-sys 0.61.2", "wl-clipboard-rs", "x11rb", ] @@ -1058,17 +1058,17 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=92d392cff132eaf53e13afff77f38b5c11b73aa0#92d392cff132eaf53e13afff77f38b5c11b73aa0" +source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=92d392cff132eaf53e13afff77f38b5c11b73aa0#92d392cff132eaf53e13afff77f38b5c11b73aa0" +source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=92d392cff132eaf53e13afff77f38b5c11b73aa0#92d392cff132eaf53e13afff77f38b5c11b73aa0" +source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" dependencies = [ "fixed_decimal", "icu_decimal", @@ -1091,7 +1091,7 @@ dependencies = [ [[package]] name = "craft-media" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=92d392cff132eaf53e13afff77f38b5c11b73aa0#92d392cff132eaf53e13afff77f38b5c11b73aa0" +source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" dependencies = [ "thiserror 2.0.21", ] @@ -1099,7 +1099,7 @@ dependencies = [ [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=92d392cff132eaf53e13afff77f38b5c11b73aa0#92d392cff132eaf53e13afff77f38b5c11b73aa0" +source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" dependencies = [ "craft-fonts-build", "craft-i18n", @@ -1120,7 +1120,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=04aa1703b32d299e54f78fcde4182f2b393a9116#04aa1703b32d299e54f78fcde4182f2b393a9116" +source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" dependencies = [ "chrono", "dunce", @@ -1534,7 +1534,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3245,7 +3245,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3881,7 +3881,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3938,7 +3938,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -4840,10 +4840,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.3", "once_cell", "rustix 1.1.5", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -5736,7 +5736,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 11f6121b..73b3e0b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,15 +50,15 @@ zip = { version = "9", default-features = false } cpal = "0.18" # Which file paths stored in a session may be opened. -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" } # Video containers and bitstreams, shared with the other craft apps. -craft-media = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" } +craft-media = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7" } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { version = "=0.1.0", git = "https://github.com/storytold/craft-libs", rev = "04aa1703b32d299e54f78fcde4182f2b393a9116", features = ["egui"] } +craft-update = { version = "=0.1.0", git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["egui"] } # ui -craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0", features = ["serde"] } +craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["serde"] } egui = { version = "0.37" } eframe = { version = "0.37", default-features = false } # Monotonic clock on native and the browser (the `web_time::Instant` panics-free equivalent). diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 98efc506..8fee933a 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -2,6 +2,8 @@ use crate::SoundApp; +#[cfg(not(target_arch = "wasm32"))] +use craft_update::dialog::{CheckResultDialog, CheckResultResponse}; #[cfg(not(target_arch = "wasm32"))] use craft_update::updater::{Action, Status, Updater}; @@ -13,8 +15,10 @@ pub(crate) struct Runtime { startup_check: bool, #[cfg(not(target_arch = "wasm32"))] check_requested: bool, - pub(crate) manual_window_open: bool, - pub(crate) status_message: Option, + /// The check-result dialog (native) or the web build's notice is showing. + manual_window_open: bool, + #[cfg(not(target_arch = "wasm32"))] + result_dialog: CheckResultDialog, } impl Default for Runtime { @@ -27,7 +31,8 @@ impl Default for Runtime { #[cfg(not(target_arch = "wasm32"))] check_requested: false, manual_window_open: false, - status_message: None, + #[cfg(not(target_arch = "wasm32"))] + result_dialog: CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")), } } } @@ -48,7 +53,6 @@ pub(crate) fn check(app: &mut SoundApp) { #[cfg(target_arch = "wasm32")] { app.updates_rt.manual_window_open = true; - app.updates_rt.status_message = Some("Update check is not supported in the web browser.".into()); } } @@ -58,6 +62,7 @@ pub(crate) fn tick(app: &mut SoundApp, ctx: &egui::Context) { let rt = &mut app.updates_rt; if std::mem::take(&mut rt.check_requested) { rt.updater.check_now(ctx); + rt.manual_window_open = true; } else if rt.startup_check { rt.updater.check_at_start(ctx); } @@ -77,46 +82,36 @@ pub(crate) fn show(app: &mut SoundApp, ctx: &egui::Context) { Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close), Action::None => {} } - // The window answers Help ▸ Check for Updates, so it follows the updater's status. + // Help ▸ Check for Updates shows its outcome in the shared result dialog until the user closes it. let rt = &mut app.updates_rt; - (rt.manual_window_open, rt.status_message) = match rt.updater.status() { - Status::Idle => (false, None), - Status::Checking => (true, None), - Status::UpToDate => (true, Some(format!("SoundCraft {} is currently the newest version available.", env!("CARGO_PKG_VERSION")))), - Status::Failed(e) => (true, Some(format!("Could not check for updates:\n{e}"))), - }; + if rt.manual_window_open { + match rt.result_dialog.show(ctx, rt.updater.status()) { + CheckResultResponse::Close => rt.manual_window_open = false, + CheckResultResponse::CheckAgain => rt.updater.check_now(ctx), + CheckResultResponse::None => {} + } + // A found update goes to the startup prompt, which takes over from the dialog. + if matches!(rt.updater.status(), Status::Idle) { + rt.manual_window_open = false; + } + } + // Closing the dialog dismisses the outcome it showed. + if !rt.manual_window_open { + rt.updater.dismiss_status(); + } } + #[cfg(target_arch = "wasm32")] if app.updates_rt.manual_window_open { let mut open = true; - let mut close = false; egui::Window::new("Check for Updates") .open(&mut open) .resizable(false) .collapsible(false) .anchor(egui::Align2::CENTER_CENTER, egui::vec2(0.0, 0.0)) .show(ctx, |ui| { - if let Some(msg) = &app.updates_rt.status_message { - ui.label(msg); - } else { - ui.label("Checking for updates…"); - } - ui.add_space(8.0); - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - if ui.button("Close").clicked() { - close = true; - } - }); + ui.label("Update check is not supported in the web browser."); }); - if !open || close { - app.updates_rt.manual_window_open = false; - app.updates_rt.status_message = None; - } - } - - // Closing the window dismisses the outcome it showed. - #[cfg(not(target_arch = "wasm32"))] - if !app.updates_rt.manual_window_open { - app.updates_rt.updater.dismiss_status(); + app.updates_rt.manual_window_open = open; } } From 948460a95308abaf082d8c700392fd7998fee457 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 06:53:02 +0100 Subject: [PATCH 26/46] Fix overflow in TempoMap bar math with a meter near i64::MAX Found while testing crates/time/src/tempo.rs:287 (bar_beat_at_tick); same pattern in bar_start_tick Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/time/src/tempo.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/crates/time/src/tempo.rs b/crates/time/src/tempo.rs index 46c05064..23bb2be0 100644 --- a/crates/time/src/tempo.rs +++ b/crates/time/src/tempo.rs @@ -251,10 +251,10 @@ impl TempoMap { for (i, m) in self.meters.iter().enumerate() { let next_tick = self.meters.get(i + 1).map(|n| n.tick); let tpb = m.ticks_per_bar(); - let bars_in_seg = next_tick.map(|nt| ((nt - cur_tick) + tpb - 1) / tpb); + let bars_in_seg = next_tick.map(|nt| ceil_div(nt.saturating_sub(cur_tick), tpb)); match bars_in_seg { - Some(n) if bar >= cur_bar + n => { - cur_bar += n; + Some(n) if bar >= cur_bar.saturating_add(n) => { + cur_bar = cur_bar.saturating_add(n); cur_tick = next_tick.unwrap_or(cur_tick); } _ => return cur_tick.saturating_add((bar - cur_bar).saturating_mul(tpb)), @@ -284,7 +284,7 @@ impl TempoMap { if let Some(n) = self.meters.get(i + 1) && tick >= n.tick { - bar += ((n.tick - seg_tick) + tpb - 1) / tpb; + bar = bar.saturating_add(ceil_div(n.tick.saturating_sub(seg_tick), tpb)); seg_tick = n.tick; continue; } @@ -323,6 +323,11 @@ impl TempoMap { } } +/// Ceiling division for a non-negative `num` and positive `den`, without overflow. +fn ceil_div(num: i64, den: i64) -> i64 { + num / den + i64::from(num % den != 0) +} + #[cfg(test)] mod tests { use super::*; @@ -337,6 +342,16 @@ mod tests { assert_eq!(m.bar_beat_at(24_000, sr), BarBeat { bar: 1, beat: 2, tick: 0 }); } + #[test] + fn meter_near_max_tick_does_not_overflow() { + let mut m = TempoMap::default(); + m.set_meter(i64::MAX, 7, 8).unwrap(); + let bb = m.bar_beat_at_tick(i64::MAX); + assert!(bb.bar > 1); + assert!(m.bar_start_tick(bb.bar) > 0); + assert!(m.bar_start_tick(i64::MAX) > 0); + } + #[test] fn minimum_bar_saturates_instead_of_overflowing() { let m = TempoMap::default(); From b9fee48a7510e7303e0107611be0900d2fa50553 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 06:07:06 +0000 Subject: [PATCH 27/46] Fix remove_dc mean when a channel has non-finite samples Found while testing crates/dsp/src/offline.rs:125-134 (remove_dc) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/dsp/src/offline.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/dsp/src/offline.rs b/crates/dsp/src/offline.rs index bc915375..f8d23784 100644 --- a/crates/dsp/src/offline.rs +++ b/crates/dsp/src/offline.rs @@ -127,8 +127,11 @@ pub fn remove_dc(ch: &mut [Vec]) { if c.is_empty() { continue; } - let mean = c.iter().filter(|v| v.is_finite()).map(|&v| f64::from(v)).sum::() / c.len() as f64; - let m = mean as f32; + let (sum, n) = c.iter().filter(|v| v.is_finite()).fold((0.0f64, 0usize), |(s, n), &v| (s + f64::from(v), n + 1)); + if n == 0 { + continue; + } + let m = (sum / n as f64) as f32; c.iter_mut().for_each(|s| *s -= m); } } @@ -889,4 +892,14 @@ mod tests { assert_eq!(ch[0][50], 1.0); fade(&mut ch, 1000, 1000, FadeShape::SCurve); } + + #[test] + fn remove_dc_ignores_non_finite_samples_in_the_mean() { + let mut ch = vec![vec![f32::NAN, 1.0, 1.0, 1.0]]; + remove_dc(&mut ch); + assert!(ch[0][1..].iter().all(|x| x.abs() < 1e-6), "left over dc {:?}", ch[0]); + let mut all_bad = vec![vec![f32::NAN, f32::INFINITY]]; + remove_dc(&mut all_bad); + assert!(all_bad[0][0].is_nan() && all_bad[0][1].is_infinite()); + } } From 53bb43db4639d734d4b363fd0e6e5d0813eb6a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Mittelst=C3=A4dt?= <62167861+TheGalitube@users.noreply.github.com> Date: Sat, 31 Oct 2026 06:46:05 +0000 Subject: [PATCH 28/46] Keep RMS finite for large samples Found while testing crates/audio-io/src/peaks.rs:34 Co-Authored-By: GPT-6-Luna --- crates/audio-io/src/peaks.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/audio-io/src/peaks.rs b/crates/audio-io/src/peaks.rs index 9553665c..6cd8f321 100644 --- a/crates/audio-io/src/peaks.rs +++ b/crates/audio-io/src/peaks.rs @@ -24,14 +24,14 @@ pub struct Peaks { struct Block { min: f32, max: f32, - squares: f32, + squares: f64, } impl Block { const EMPTY: Block = Block { min: f32::INFINITY, max: f32::NEG_INFINITY, squares: 0.0 }; fn point(s: f32) -> Block { - Block { min: s, max: s, squares: if s.is_finite() { s * s } else { 0.0 } } + Block { min: s, max: s, squares: if s.is_finite() { f64::from(s) * f64::from(s) } else { 0.0 } } } fn of(samples: &[f32]) -> Block { @@ -146,7 +146,7 @@ impl Peaks { .map(|w| { w.map(|(a, b)| { let (s, e) = (a.floor() as usize, (b.ceil() as usize).saturating_add(1).min(self.len).min(samples.len())); - (self.sum(samples, s, e).squares / e.saturating_sub(s).max(1) as f32).sqrt() + (self.sum(samples, s, e).squares / e.saturating_sub(s).max(1) as f64).sqrt() as f32 }) }) .collect() @@ -215,6 +215,13 @@ mod tests { assert!(p.rms_spans(&x, 0.0, 1.0, 0.0, 1)[0].is_some_and(f32::is_finite)); } + #[test] + fn finite_large_samples_keep_finite_rms() { + let samples = vec![1e20_f32; BLOCK]; + let peaks = Peaks::build(&samples); + assert_eq!(peaks.rms_spans(&samples, 0.0, BLOCK as f64, 0.0, 1), vec![Some(1e20)]); + } + #[test] fn rms_spans_match_the_samples() { let x = signal(20_000); From 73e3478ae367d7f0c4716f29696cf7789b944dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Mittelst=C3=A4dt?= <62167861+TheGalitube@users.noreply.github.com> Date: Sat, 31 Oct 2026 07:06:09 +0000 Subject: [PATCH 29/46] Accept unsigned AIFF channel counts Found while testing crates/audio-io/src/aiff.rs:84 Co-Authored-By: GPT-6-Luna --- crates/audio-io/src/aiff.rs | 8 +++--- crates/audio-io/tests/hunter_aiff_channels.rs | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 crates/audio-io/tests/hunter_aiff_channels.rs diff --git a/crates/audio-io/src/aiff.rs b/crates/audio-io/src/aiff.rs index 77ed6f80..3c851d72 100644 --- a/crates/audio-io/src/aiff.rs +++ b/crates/audio-io/src/aiff.rs @@ -63,7 +63,7 @@ pub(crate) fn parse(b: &[u8]) -> Result { return Err(AudioError::Malformed("not an AIFF/AIFF-C file".into())); } let is_aifc = tag(b, 8).is_some_and(|t| &t == b"AIFC"); - let mut comm: Option<(i16, u32, i16, f64, [u8; 4])> = None; + let mut comm: Option<(u16, u32, i16, f64, [u8; 4])> = None; let mut ssnd: Option<(usize, usize)> = None; let mut pos: usize = 12; @@ -81,7 +81,7 @@ pub(crate) fn parse(b: &[u8]) -> Result { match &id { b"COMM" => { let short = || AudioError::Malformed("COMM chunk too short".into()); - let channels = be_u16(c, 0).ok_or_else(short)? as i16; + let channels = be_u16(c, 0).ok_or_else(short)?; let frames = be_u32(c, 2).ok_or_else(short)?; let bits = be_u16(c, 6).ok_or_else(short)? as i16; let rate = extended_to_f64(c.get(8..18).ok_or_else(short)?).ok_or_else(|| AudioError::Malformed("invalid sample rate".into()))?; @@ -106,7 +106,7 @@ pub(crate) fn parse(b: &[u8]) -> Result { } let (channels, frames, bits, rate, compression) = comm.ok_or_else(|| AudioError::Malformed("AIFF has no COMM chunk".into()))?; - if channels <= 0 { + if channels == 0 { return Err(AudioError::Malformed("AIFF declares zero or negative channels".into())); } if !(1.0..=MAX_SAMPLE_RATE).contains(&rate) { @@ -137,7 +137,7 @@ pub(crate) fn parse(b: &[u8]) -> Result { let block = kind.bytes().saturating_mul(channels as usize).max(1); let frames = u64::from(frames).min((data_len / block) as u64); Ok(AiffParse::Native(AiffLayout { - info: AudioInfo { format: FileFormat::Aiff, sample_format, sample_rate, channels: channels as u16, frames, bwf: None }, + info: AudioInfo { format: FileFormat::Aiff, sample_format, sample_rate, channels, frames, bwf: None }, kind, data_start, data_len, diff --git a/crates/audio-io/tests/hunter_aiff_channels.rs b/crates/audio-io/tests/hunter_aiff_channels.rs new file mode 100644 index 00000000..2fa95f2e --- /dev/null +++ b/crates/audio-io/tests/hunter_aiff_channels.rs @@ -0,0 +1,26 @@ +use soundcraft_audio_io::probe; + +#[test] +fn aiff_accepts_full_unsigned_channel_count() { + let mut comm = Vec::new(); + comm.extend_from_slice(&32_768u16.to_be_bytes()); + comm.extend_from_slice(&0u32.to_be_bytes()); + comm.extend_from_slice(&16u16.to_be_bytes()); + // 44,100 Hz as an 80-bit extended float. + comm.extend_from_slice(&[0x40, 0x0e, 0xac, 0x44, 0, 0, 0, 0, 0, 0]); + + let mut file = b"FORM".to_vec(); + file.extend_from_slice(&0u32.to_be_bytes()); + file.extend_from_slice(b"AIFF"); + file.extend_from_slice(b"COMM"); + file.extend_from_slice(&(comm.len() as u32).to_be_bytes()); + file.extend_from_slice(&comm); + file.extend_from_slice(b"SSND"); + file.extend_from_slice(&8u32.to_be_bytes()); + file.extend_from_slice(&[0; 8]); + let form_size = (file.len() - 8) as u32; + file[4..8].copy_from_slice(&form_size.to_be_bytes()); + + let info = probe(&file, Some("aiff")).expect("valid AIFF"); + assert_eq!(info.channels, 32_768); +} From f28a10a5dd64ff59330a6198b480babeb5ac2867 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 11:13:22 +0100 Subject: [PATCH 30/46] Saturate H.264 POC type 0 bottom field order count Found while testing crates/video/src/h264/slice.rs:477 (PocState::compute, pic_order_cnt_type 0) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/video/src/h264/slice.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/video/src/h264/slice.rs b/crates/video/src/h264/slice.rs index 02bcb0ba..61c2eccd 100644 --- a/crates/video/src/h264/slice.rs +++ b/crates/video/src/h264/slice.rs @@ -474,7 +474,7 @@ impl PocState { prev_msb }; let top = msb + lsb; - let bottom = top + sh.delta_pic_order_cnt_bottom; + let bottom = top.saturating_add(sh.delta_pic_order_cnt_bottom); Poc { top, bottom, msb, frame_num_offset: 0 } } 1 => { @@ -638,4 +638,17 @@ mod tests { fn huge_slice_qp_delta_is_invalid() { assert!(matches!(parse_override(0, 0, 0, i32::MAX), Err(crate::h264::Error::Invalid(_)))); } + + #[test] + fn poc0_huge_bottom_delta_does_not_overflow() { + let (mut sps, _) = sps_pps(); + sps.pic_order_cnt_type = 0; + sps.log2_max_poc_lsb = 4; + let mut sh = parse_override(0, 0, 0, 0).unwrap(); + sh.pic_order_cnt_lsb = 1; + sh.delta_pic_order_cnt_bottom = i32::MAX; + let poc = PocState::default().compute(&sh, &sps); + assert_eq!(poc.top, 1); + assert_eq!(poc.bottom, i32::MAX); + } } From 2d88f46f02a28c30af2f4d3fd151cd0e7bb7e892 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 10:16:46 +0000 Subject: [PATCH 31/46] Keep plugin parameter id case in AutoParam::parse Found while testing crates/model/src/automation.rs:86-103 (AutoParam::parse) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/model/src/automation.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/model/src/automation.rs b/crates/model/src/automation.rs index 26bbcae3..8ee9e7fb 100644 --- a/crates/model/src/automation.rs +++ b/crates/model/src/automation.rs @@ -80,7 +80,8 @@ impl AutoParam { } /// Parse ids like `volume`, `pan`, `pan2`, `mute`, `send_a_level`, `plugin:a:threshold`. pub fn parse(s: &str) -> Option { - let s = s.trim().to_ascii_lowercase(); + let orig = s.trim(); + let s = orig.to_ascii_lowercase(); match s.as_str() { "volume" | "vol" => return Some(AutoParam::Volume), "pan" | "pan1" => return Some(AutoParam::Pan(0)), @@ -100,6 +101,8 @@ impl AutoParam { } if let Some(rest) = s.strip_prefix("plugin:") { let (slot, param) = rest.split_once(':')?; + // ASCII lowercasing keeps byte offsets, so take the param from the original. + let param = orig.get(orig.len() - param.len()..)?; return Some(AutoParam::Plugin { slot: letter_slot(slot)?, param: param.to_string() }); } None @@ -255,6 +258,15 @@ impl AutomationLane { mod tests { use super::*; + #[test] + fn parse_keeps_plugin_param_case() { + let p = AutoParam::Plugin { slot: 0, param: "Cutoff".into() }; + assert_eq!(AutoParam::parse("plugin:a:Cutoff"), Some(p)); + assert_eq!(AutoParam::parse("Plugin:B:Mix"), Some(AutoParam::Plugin { slot: 1, param: "Mix".into() })); + assert_eq!(AutoParam::parse("Volume"), Some(AutoParam::Volume)); + assert_eq!(AutoParam::parse("SEND_B_LEVEL"), Some(AutoParam::SendLevel(1))); + } + #[test] fn pan_label_max_does_not_overflow() { assert_eq!(AutoParam::Pan(255).label(), "pan 256"); From a13a4f5bd22b64dff645dfff09e4d231b7d7947a Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:30:11 +0100 Subject: [PATCH 32/46] Fix H.264 DPB integer overflow on huge pic num differences Found while testing crates/video/src/h264/dpb.rs:265 (Dpb::apply_mmcos, MMCO 1 and 3); same pattern at :280 and :203 (build_ref_lists, `m.value as i32 + 1`) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/video/src/h264/dpb.rs | 73 ++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/crates/video/src/h264/dpb.rs b/crates/video/src/h264/dpb.rs index 5afc169b..81044955 100644 --- a/crates/video/src/h264/dpb.rs +++ b/crates/video/src/h264/dpb.rs @@ -198,6 +198,7 @@ impl Dpb { let mut ref_idx = 0usize; for m in &sh.ref_pic_list_mod[l] { ensure!(ref_idx < n, "too many ref_pic_list_modification entries"); + ensure!(m.idc >= 2 || i64::from(m.value) < i64::from(max_pic_num), "abs_diff_pic_num_minus1 out of range"); list.push(None); // temporarily one longer let (target, is_long): (Option<&DpbEntry>, bool) = match m.idc { 0 | 1 => { @@ -262,9 +263,9 @@ impl Dpb { for m in mmcos { match m.op { 1 => { - let pn = curr_pic_num - (m.difference_of_pic_nums_minus1 as i32 + 1); + let pn = i64::from(curr_pic_num) - (i64::from(m.difference_of_pic_nums_minus1) + 1); for e in &mut self.entries { - if e.mark == RefMark::Short && Self::frame_num_wrap(e, cur_frame_num, max_frame_num) == pn { + if e.mark == RefMark::Short && i64::from(Self::frame_num_wrap(e, cur_frame_num, max_frame_num)) == pn { e.mark = RefMark::Unused; } } @@ -277,14 +278,14 @@ impl Dpb { } } 3 => { - let pn = curr_pic_num - (m.difference_of_pic_nums_minus1 as i32 + 1); + let pn = i64::from(curr_pic_num) - (i64::from(m.difference_of_pic_nums_minus1) + 1); for e in &mut self.entries { if e.mark == RefMark::Long && e.long_term_frame_idx == m.long_term_frame_idx { e.mark = RefMark::Unused; } } for e in &mut self.entries { - if e.mark == RefMark::Short && Self::frame_num_wrap(e, cur_frame_num, max_frame_num) == pn { + if e.mark == RefMark::Short && i64::from(Self::frame_num_wrap(e, cur_frame_num, max_frame_num)) == pn { e.mark = RefMark::Long; e.long_term_frame_idx = m.long_term_frame_idx; } @@ -418,3 +419,67 @@ impl Default for Dpb { Self::new() } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::h264::slice::RefPicListMod; + + fn mmco(op: u32, diff: u32) -> Mmco { + Mmco { op, difference_of_pic_nums_minus1: diff, long_term_pic_num: 0, long_term_frame_idx: 0, max_long_term_frame_idx_plus1: 0 } + } + + #[test] + fn mmco_huge_difference_does_not_panic() { + for op in [1, 3] { + for diff in [0x7FFF_FFFF, 0x8000_0000, u32::MAX] { + let mut dpb = Dpb::new(); + dpb.apply_mmcos(&[mmco(op, diff)], 5, 16, &mut None); + } + } + } + + #[test] + fn ref_list_mod_huge_value_does_not_panic() { + for idc in [0, 1] { + for value in [0x7FFF_FFFF, 0x8000_0000, u32::MAX] { + let sh = SliceHeader { + nal_ref_idc: 1, + nal_unit_type: 1, + idr: false, + first_mb_in_slice: 0, + slice_type_raw: 0, + slice_type: SliceType::P, + pps_id: 0, + colour_plane_id: 0, + frame_num: 5, + field_pic: false, + bottom_field: false, + idr_pic_id: 0, + pic_order_cnt_lsb: 0, + delta_pic_order_cnt_bottom: 0, + delta_pic_order_cnt: [0; 2], + redundant_pic_cnt: 0, + direct_spatial_mv_pred: false, + num_ref_idx_active: [1, 0], + ref_pic_list_mod: [vec![RefPicListMod { idc, value }], Vec::new()], + pred_weight_table: None, + no_output_of_prior_pics: false, + long_term_reference: false, + adaptive_ref_pic_marking: false, + mmcos: Vec::new(), + cabac_init_idc: 0, + slice_qp_delta: 0, + sp_for_switch: false, + slice_qs_delta: 0, + disable_deblocking_filter_idc: 0, + slice_alpha_c0_offset_div2: 0, + slice_beta_offset_div2: 0, + slice_group_change_cycle: 0, + header_bits: 0, + }; + let _ = Dpb::new().build_ref_lists(&sh, 0, 16); + } + } + } +} From ad3147388f69c4c49096b1c7a33d03befff3c440 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 31 Oct 2026 10:40:57 -0400 Subject: [PATCH 33/46] Saturate the POC type 0 MSB and top field sum too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MSB accumulates across reference pictures, so a hostile stream can still overflow prev_msb ± max_lsb and msb + lsb. Co-Authored-By: Claude Opus 5.5 --- crates/video/src/h264/slice.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/video/src/h264/slice.rs b/crates/video/src/h264/slice.rs index 61c2eccd..5fb387aa 100644 --- a/crates/video/src/h264/slice.rs +++ b/crates/video/src/h264/slice.rs @@ -467,13 +467,13 @@ impl PocState { let max_lsb = 1i32 << sps.log2_max_poc_lsb; let lsb = sh.pic_order_cnt_lsb as i32; let msb = if lsb < prev_lsb && prev_lsb - lsb >= max_lsb / 2 { - prev_msb + max_lsb + prev_msb.saturating_add(max_lsb) } else if lsb > prev_lsb && lsb - prev_lsb > max_lsb / 2 { - prev_msb - max_lsb + prev_msb.saturating_sub(max_lsb) } else { prev_msb }; - let top = msb + lsb; + let top = msb.saturating_add(lsb); let bottom = top.saturating_add(sh.delta_pic_order_cnt_bottom); Poc { top, bottom, msb, frame_num_offset: 0 } } From 6ef3300aba87ad89c3903e94d99e83dc3a6716b5 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 31 Oct 2026 10:41:20 -0400 Subject: [PATCH 34/46] Assert that out-of-range pic num differences are refused Co-Authored-By: Claude Opus 5.5 --- crates/video/src/h264/dpb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/video/src/h264/dpb.rs b/crates/video/src/h264/dpb.rs index 81044955..34688e2f 100644 --- a/crates/video/src/h264/dpb.rs +++ b/crates/video/src/h264/dpb.rs @@ -478,7 +478,7 @@ mod tests { slice_group_change_cycle: 0, header_bits: 0, }; - let _ = Dpb::new().build_ref_lists(&sh, 0, 16); + assert!(Dpb::new().build_ref_lists(&sh, 0, 16).is_err()); } } } From 13b2488e95115ee345da6713c53260603330b0b4 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 31 Oct 2026 10:42:37 -0400 Subject: [PATCH 35/46] Set an empty-range constant tempo at the range start With start now optional, {end} alone resolves the start from the selection; the empty-range fallback still went through event.tempo, which put the tempo at tick 0. CodeRabbit flagged this. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/event.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/event.rs b/crates/engine/src/cmd/event.rs index a1f4ef4e..d9271210 100644 --- a/crates/engine/src/cmd/event.rs +++ b/crates/engine/src/cmd/event.rs @@ -115,11 +115,13 @@ fn tempo_constant(e: &mut Engine, p: &Value) -> Result { let r = range_param(e, id, p)?; let s = e.session(); let (t0, t1) = (s.tempo.samples_to_ticks(r.start, s.sample_rate), s.tempo.samples_to_ticks(r.end, s.sample_rate)); - if t1 <= t0 { - return tempo(e, p); - } let bpm = f64_or(p, "bpm", f64::NAN); let s = e.session_mut(); + if t1 <= t0 { + // An empty range sets the tempo at its start, which may come from the selection. + s.tempo.set_tempo(t0, bpm).map_err(|err| bad(id, err.to_string()))?; + return Ok(json!({"tick": t0, "bpm": bpm})); + } // Read before the edit: the end is a musical position, and the new tempo moves it in samples. let after = s.tempo.tempo_at_tick(t1); let had_end = s.tempo.tempos().iter().any(|x| x.tick == t1); @@ -427,6 +429,18 @@ mod tests { use crate::demo::demo_engine; use serde_json::json; + #[test] + fn tempo_constant_with_an_empty_range_sets_the_tempo_at_its_start() { + use soundcraft_time::Range; + let mut e = demo_engine(); + e.session_mut().edit.selection = Range::point(96_000); + let r = e.execute("event.tempo_constant", &json!({"bpm": 90.0, "end": 96_000})).unwrap(); + let s = e.session(); + let tick = s.tempo.samples_to_ticks(96_000, s.sample_rate); + assert_eq!(r["tick"], tick); + assert_eq!(s.tempo.tempo_at_tick(tick), 90.0); + } + /// `start` is optional for insert/cut time: it defaults to the selection start, then `end`/`length` apply. #[test] fn insert_and_cut_time_without_start_use_selection_start() { From 6e2da18e9e1cf5ae8b0c615ae37e62565a3970c5 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 31 Oct 2026 10:46:57 -0400 Subject: [PATCH 36/46] Drop the old selection's end and loop on transport.play {from} While playing, locate kept the earlier end and loop range, so playing from past a looped selection jumped back into the loop. CodeRabbit flagged this. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/app/playback.rs | 5 +++-- crates/ui-egui/src/tests.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/app/playback.rs b/crates/ui-egui/src/app/playback.rs index 818e45e8..ccb9e742 100644 --- a/crates/ui-egui/src/app/playback.rs +++ b/crates/ui-egui/src/app/playback.rs @@ -345,11 +345,12 @@ impl SoundApp { } TransportRequest::PlayFrom(at) => { if self.is_playing() { + // Playing on from `at` drops the end and loop of the earlier selection. if let Some(p) = &self.player { - p.locate(at); + p.play(at, None, None); } if let Some(sim) = &mut self.sim { - sim.0 = at; + *sim = (at, None, None); } self.last_write_at = i64::MIN; self.engine.transport.position = at; diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index e6ca84e9..6d61ca95 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -77,6 +77,21 @@ fn play_from_starts_at_from_regardless_of_the_selection() { assert_eq!(app.engine.transport.position, 96_000 + 12_000); } +#[test] +fn play_from_while_looping_drops_the_selection_loop() { + let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); + app.run("options.loop_playback", json!({"value": true})).unwrap(); + app.run("edit.select", json!({"tracks": ["Kick"], "start": 96_000, "end": 144_000})).unwrap(); + app.run("transport.play", json!({})).unwrap(); + app.handle_transport(0.25); + assert!(app.is_playing()); + app.run("transport.play", json!({"from": 480_000})).unwrap(); + app.handle_transport(0.25); + app.handle_transport(0.25); + assert!(app.is_playing()); + assert_eq!(app.engine.transport.position, 480_000 + 24_000); +} + #[test] fn record_with_nothing_armed_says_what_to_do() { let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()); From ef2f70eb35a36118b3448a751788311e66be3745 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:54:06 +0100 Subject: [PATCH 37/46] Return app errors from Remote::call unchanged instead of reconnecting (#1128) Found while testing crates/automation/src/lib.rs:~160 (Remote::call, matching on e.contains("closed") / "Broken pipe" / "reset") Co-authored-by: Claude Haiku 5.5 --- crates/automation/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/automation/src/lib.rs b/crates/automation/src/lib.rs index 6955db33..88406158 100644 --- a/crates/automation/src/lib.rs +++ b/crates/automation/src/lib.rs @@ -317,4 +317,19 @@ mod tests { assert!(r.call("session.inspect", json!({})).is_ok()); assert_eq!(seen.load(std::sync::atomic::Ordering::SeqCst), 2); } + + #[test] + fn remote_returns_an_app_error_unchanged() { + let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); + let addr = ControlTarget { host: None, port: listener.local_addr().unwrap().port() }; + std::thread::spawn(move || { + let Ok((mut sock, _)) = listener.accept() else { return }; + let mut line = String::new(); + let _ = BufReader::new(sock.try_clone().unwrap()).read_line(&mut line); + let _ = writeln!(sock, "{}", json!({"id": 1, "ok": false, "error": "transport.locate: nothing to reset"})); + }); + let mut r = Remote::new(&addr); + let err = r.call("engine.execute", json!({"command": "transport.locate"})).unwrap_err(); + assert_eq!(err, "transport.locate: nothing to reset"); + } } From 97e2603683f157b8a02ab2bc4484975771a773b1 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:41:28 +0000 Subject: [PATCH 38/46] fix: release a held sustain at the end of a trimmed MIDI clip on export Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/io/midi.rs | 21 ++++++++++++++++++++- crates/engine/tests/it/midi_offset.rs | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/io/midi.rs b/crates/engine/src/io/midi.rs index 44f7be31..a9c715e7 100644 --- a/crates/engine/src/io/midi.rs +++ b/crates/engine/src/io/midi.rs @@ -74,10 +74,29 @@ pub fn export_midi(e: &Engine, only: Option<&[TrackId]>) -> Result> { n.length = n.length.min(clip_end - n.start).max(1); seq.notes.push(n); } + let mut kept: Vec = Vec::new(); for ev in sequence.ctrls.iter().filter(|ev| ev.tick.saturating_add(base) < clip_end) { let mut ev = *ev; ev.tick = ev.tick.saturating_add(base); - seq.ctrls.push(ev); + kept.push(ev); + } + // A sustain still held at the clip end is released there. + let mut release: Vec = Vec::new(); + for ev in &kept { + if ev.kind != soundcraft_midi::CtrlKind::Cc(64) { + continue; + } + match release.iter_mut().find(|r| r.channel == ev.channel) { + Some(r) if ev.tick >= r.tick => *r = *ev, + Some(_) => {} + None => release.push(*ev), + } + } + seq.ctrls.append(&mut kept); + for mut r in release.into_iter().filter(|r| r.value >= 64) { + r.tick = clip_end; + r.value = 0; + seq.ctrls.push(r); } } } diff --git a/crates/engine/tests/it/midi_offset.rs b/crates/engine/tests/it/midi_offset.rs index 8e6fb7ae..f0f4b2d6 100644 --- a/crates/engine/tests/it/midi_offset.rs +++ b/crates/engine/tests/it/midi_offset.rs @@ -50,3 +50,27 @@ fn export_midi_leaves_out_what_a_trimmed_clip_no_longer_plays() { let late = notes.iter().find(|n| n.pitch == 62).unwrap(); assert_eq!(late.start + late.length, 960, "a note running past the clip end is cut at it"); } + +#[test] +fn export_midi_releases_a_sustain_held_past_the_trim() { + use soundcraft_midi::{CtrlEvent, CtrlKind}; + let mut e = Engine::default(); + let r = e.execute("track.new", &json!({"kind": "instrument", "name": "Sus", "instrument": "subtractive_synth"})).unwrap(); + let track = r["tracks"][0].as_u64().unwrap(); + e.execute("midi.new_clip", &json!({"track": track, "start": 0, "length": 96_000})).unwrap(); + let id = e.session().tracks[0].clips()[0].id; + { + let clip = e.session_mut().find_clip_mut(id).unwrap(); + if let soundcraft_model::ClipContent::Midi { sequence } = &mut clip.content { + let cc = |tick, channel, value| CtrlEvent { tick, channel, kind: CtrlKind::Cc(64), value }; + sequence.ctrls = vec![cc(100, 0, 127), cc(200, 1, 127), cc(300, 1, 0), cc(2000, 0, 0)]; + } + clip.trim_end_to(24_000); + } + let bytes = soundcraft_engine::io::export_midi(&e, None).unwrap(); + let smf = soundcraft_midi::read_smf(&bytes).unwrap(); + let ctrls = &smf.tracks[0].sequence.ctrls; + let sus: Vec<_> = ctrls.iter().filter(|c| c.kind == CtrlKind::Cc(64)).collect(); + assert!(sus.iter().any(|c| c.channel == 0 && c.tick == 960 && c.value == 0), "{sus:?}"); + assert!(!sus.iter().any(|c| c.channel == 1 && c.tick == 960), "released channel gets no extra event: {sus:?}"); +} From 85ffa1f53ee6d04c4e99b66afd142bd4345d2009 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 31 Oct 2026 18:52:51 -0400 Subject: [PATCH 39/46] packaging(flatpak): add OCI image build and GHCR publishing helper (#1233) --- packaging/linux/flatpak-bundle.sh | 16 ++++++-- packaging/linux/flatpak-oci.sh | 64 +++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 4 deletions(-) create mode 100755 packaging/linux/flatpak-oci.sh diff --git a/packaging/linux/flatpak-bundle.sh b/packaging/linux/flatpak-bundle.sh index 78becd59..92288276 100755 --- a/packaging/linux/flatpak-bundle.sh +++ b/packaging/linux/flatpak-bundle.sh @@ -20,10 +20,12 @@ APP_ID=ai.storyteller.soundcraft FLATHUB=https://dl.flathub.org/repo/flathub.flatpakrepo TEST=1 +OCI=0 TARBALL="" -while [[ $# -gt 0 ]]; do +while [ $# -gt 0 ]; do case "$1" in --no-test) TEST=0; shift ;; + --oci) OCI=1; shift ;; -h | --help) sed -n '2,14p' "$0"; exit 0 ;; -*) echo "unknown argument: $1" >&2; exit 2 ;; *) TARBALL="$1"; shift ;; @@ -38,7 +40,7 @@ case "$ARCH" in esac BASENAME="soundcraft-$VERSION-linux-$ARCH" TARBALL="${TARBALL:-$DIST/$BASENAME.tar.gz}" -[[ -f "$TARBALL" ]] || { echo "error: $TARBALL not found (run packaging/linux/package.sh --formats tar first)" >&2; exit 1; } +[ -f "$TARBALL" ] || { echo "error: $TARBALL not found (run packaging/linux/package.sh --formats tar first)" >&2; exit 1; } for tool in flatpak flatpak-builder; do command -v "$tool" >/dev/null || { echo "error: $tool not found (apt install flatpak flatpak-builder librsvg2-common)" >&2; exit 1; } done @@ -49,7 +51,7 @@ WORK="$CARGO_TARGET_DIR/flatpak-bundle" rm -rf "$WORK" mkdir -p "$WORK/stage" tar -xzf "$TARBALL" -C "$WORK/stage" --strip-components=1 -[[ -x "$WORK/stage/bin/soundcraft" ]] || { echo "error: $TARBALL has no bin/soundcraft" >&2; exit 1; } +[ -x "$WORK/stage/bin/soundcraft" ] || { echo "error: $TARBALL has no bin/soundcraft" >&2; exit 1; } cp "$HERE/flatpak/$APP_ID.bundle.yml" "$WORK/$APP_ID.yml" flatpak remote-add --user --if-not-exists flathub "$FLATHUB" @@ -61,8 +63,14 @@ OUT="$DIST/$BASENAME.flatpak" # --runtime-repo lets `flatpak install` fetch the freedesktop runtime from Flathub if missing. flatpak build-bundle --runtime-repo="$FLATHUB" "$WORK/repo" "$OUT" "$APP_ID" stable echo "wrote $OUT" +if [[ "$OCI" = 1 ]]; then + OUT_OCI="$DIST/$BASENAME-oci" + rm -rf "$OUT_OCI" + flatpak build-bundle --oci "$WORK/repo" "$OUT_OCI" "$APP_ID" stable + echo "wrote OCI layout to $OUT_OCI" +fi -if [[ "$TEST" = 1 ]]; then +if [ "$TEST" = 1 ]; then flatpak install --user -y --noninteractive --reinstall "$OUT" flatpak info --user "$APP_ID" flatpak run --command=soundcraft-cli "$APP_ID" --version diff --git a/packaging/linux/flatpak-oci.sh b/packaging/linux/flatpak-oci.sh new file mode 100755 index 00000000..45287706 --- /dev/null +++ b/packaging/linux/flatpak-oci.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# Build soundcraft as an OCI container layout and push it to GitHub Container Registry (GHCR) +# for consumption by Flatpak OCI clients (flatpak-oci-specs). +# +# Usage: +# packaging/linux/flatpak-oci.sh [--push] [TARBALL] +# +# Environment variables: +# REGISTRY Target registry image (default: ghcr.io/storytold/soundcraft) +# TAG Target image tag (default: $VERSION-$ARCH, also tags stable-$ARCH) +# GITHUB_TOKEN Token for GHCR authentication when --push is used +set -euo pipefail +# shellcheck source=../env.sh +. "$(dirname "${BASH_SOURCE[0]}")/../env.sh" +HERE="$ROOT/packaging/linux" + +PUSH=0 +TARBALL="" +while [[ $# -gt 0 ]]; do + case "$1" in + --push) PUSH=1; shift ;; + -h | --help) sed -n '2,12p' "$0"; exit 0 ;; + -*) echo "unknown argument: $1" >&2; exit 2 ;; + *) TARBALL="$1"; shift ;; + esac +done + +ARCH="$(uname -m)" +case "$ARCH" in + x86_64) ;; + aarch64 | arm64) ARCH=aarch64 ;; + *) echo "unsupported architecture $ARCH" >&2; exit 2 ;; +esac + +BASENAME="soundcraft-$VERSION-linux-$ARCH" +OUT_OCI="$DIST/$BASENAME-oci" + +echo "==> Building Flatpak OCI layout for $BASENAME" +"$HERE/flatpak-bundle.sh" --oci --no-test "${TARBALL:-}" + +[[ -d "$OUT_OCI" ]] || { echo "error: $OUT_OCI layout not generated" >&2; exit 1; } + +REGISTRY="${REGISTRY:-ghcr.io/storytold/soundcraft}" +TAG="${TAG:-$VERSION-$ARCH}" + +echo "==> OCI layout ready at $OUT_OCI (Target: $REGISTRY:$TAG)" + +if [[ "$PUSH" = 1 ]]; then + command -v skopeo >/dev/null || { echo "error: skopeo is required to push OCI images (apt install skopeo)" >&2; exit 1; } + + AUTH_ARGS=() + if [[ -n "${GITHUB_TOKEN:-}" ]]; then + AUTH_ARGS=(--dest-creds "${GITHUB_ACTOR:-storytold}:$GITHUB_TOKEN") + fi + + echo "==> Pushing to $REGISTRY:$TAG" + skopeo copy --format oci "${AUTH_ARGS[@]}" "oci:$OUT_OCI" "docker://$REGISTRY:$TAG" + + # Also update architecture-specific stable tag + echo "==> Pushing to $REGISTRY:stable-$ARCH" + skopeo copy --format oci "${AUTH_ARGS[@]}" "oci:$OUT_OCI" "docker://$REGISTRY:stable-$ARCH" + + echo "==> Push complete" +fi From b32065a109a93fbc539810f4e7b3965734623340 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sun, 1 Nov 2026 00:34:16 +0100 Subject: [PATCH 40/46] Keep score export notes when bars are shorter than a sixteenth Found while testing crates/engine/src/score.rs:~150 (measure_grid, `if ub <= ua { break; }`), used by layout() Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/score.rs | 48 +++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/score.rs b/crates/engine/src/score.rs index 0188f923..884e8d80 100644 --- a/crates/engine/src/score.rs +++ b/crates/engine/src/score.rs @@ -146,12 +146,20 @@ fn measure_grid(s: &Session, end_unit: i64) -> Vec<(i64, i64, u32, u32)> { let a = s.tempo.bar_start_tick(bar); let b = s.tempo.bar_start_tick(bar + 1); let m = s.tempo.meter_at_tick(a); - let (ua, ub) = (a / UNIT, b / UNIT); - if ub <= ua { + if b <= a { break; } - v.push((ua, ub - ua, m.numerator, m.denominator)); + let (ua, ub) = (a / UNIT, b / UNIT); bar += 1; + if ub <= ua { + // A bar shorter than a sixteenth that does not reach the next unit: the following + // bar carries this span, so the grid stays contiguous. + continue; + } + // Bars shorter than a sixteenth are written as one measure of the units they cover, so + // the time signature matches the measure's content. + let (num, den) = if m.ticks_per_bar() < UNIT { (u32::try_from(ub - ua).unwrap_or(1), 16) } else { (m.numerator, m.denominator) }; + v.push((ua, ub - ua, num, den)); if ub >= end_unit.max(1) || v.len() >= MAX_MEASURES { break; } @@ -644,6 +652,40 @@ mod tests { assert!(s.starts_with(" usize { + parts.iter().flat_map(|p| &p.measures).flat_map(|m| &m.items).filter(|i| !i.tie_stop).map(|i| i.pitches.len()).sum() + } + + #[test] + fn bars_shorter_than_a_sixteenth_keep_every_note() { + let base = crate::demo::demo_engine(); + let baseline = note_starts(&layout(base.session(), &[])); + assert!(baseline > 0, "demo has notes"); + for (n, d) in [(1, 32), (1, 64), (2, 64), (3, 64)] { + for mid in [false, true] { + let mut e = crate::demo::demo_engine(); + let tick = if mid { e.session().tempo.bar_start_tick(5) } else { 0 }; + e.session_mut().tempo.set_meter(tick, n, d).expect("valid meter"); + let parts = layout(e.session(), &[]); + assert!(parts.iter().all(|p| !p.measures.is_empty()), "{n}/{d} mid={mid}: empty part"); + assert_eq!(note_starts(&parts), baseline, "{n}/{d} mid={mid}: notes lost"); + for p in &parts { + for m in &p.measures { + let units: u32 = m.items.iter().map(|i| i.units).sum(); + // The written meter matches the measure's content (divisions are sixteenths). + assert_eq!(units * m.denominator, 16 * m.numerator, "{n}/{d} mid={mid}: meter/content mismatch"); + } + } + let setup = ScoreSetup::from_session(e.session()); + let x = musicxml(&parts, &setup).expect("musicxml fits"); + assert!(x.contains(""), "{n}/{d} mid={mid}: musicxml has no notes"); + let s = svg(&parts, &setup).expect("svg fits"); + assert!(s.contains(" Date: Sat, 31 Oct 2026 23:43:12 -0400 Subject: [PATCH 41/46] ci: grant packages write permission to release workflow --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52b76762..983c62d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,7 @@ jobs: # The shared workflow creates the draft release, which needs write access to contents. permissions: contents: write + packages: write # Intentionally tracked at @main (not SHA-pinned) so org-wide CI improvements, security fixes, and build optimizations propagate without PR churn across all craftapp repos. uses: storytold/craft-common-actions/.github/workflows/release.yml@main with: From cf4029688805303f7815fcf44ea8f4dc66c18bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Mittelst=C3=A4dt?= <62167861+TheGalitube@users.noreply.github.com> Date: Sun, 1 Nov 2026 08:56:59 +0000 Subject: [PATCH 42/46] fix: reject unsigned AIFF channel counts Co-Authored-By: GPT-5.6-Luna Co-Authored-By: GPT-5.6-Terra --- crates/audio-io/src/aiff.rs | 8 +++--- crates/audio-io/tests/hunter_aiff_channels.rs | 26 ------------------- crates/audio-io/tests/it/malformed.rs | 9 +++++++ 3 files changed, 13 insertions(+), 30 deletions(-) delete mode 100644 crates/audio-io/tests/hunter_aiff_channels.rs diff --git a/crates/audio-io/src/aiff.rs b/crates/audio-io/src/aiff.rs index 3c851d72..77ed6f80 100644 --- a/crates/audio-io/src/aiff.rs +++ b/crates/audio-io/src/aiff.rs @@ -63,7 +63,7 @@ pub(crate) fn parse(b: &[u8]) -> Result { return Err(AudioError::Malformed("not an AIFF/AIFF-C file".into())); } let is_aifc = tag(b, 8).is_some_and(|t| &t == b"AIFC"); - let mut comm: Option<(u16, u32, i16, f64, [u8; 4])> = None; + let mut comm: Option<(i16, u32, i16, f64, [u8; 4])> = None; let mut ssnd: Option<(usize, usize)> = None; let mut pos: usize = 12; @@ -81,7 +81,7 @@ pub(crate) fn parse(b: &[u8]) -> Result { match &id { b"COMM" => { let short = || AudioError::Malformed("COMM chunk too short".into()); - let channels = be_u16(c, 0).ok_or_else(short)?; + let channels = be_u16(c, 0).ok_or_else(short)? as i16; let frames = be_u32(c, 2).ok_or_else(short)?; let bits = be_u16(c, 6).ok_or_else(short)? as i16; let rate = extended_to_f64(c.get(8..18).ok_or_else(short)?).ok_or_else(|| AudioError::Malformed("invalid sample rate".into()))?; @@ -106,7 +106,7 @@ pub(crate) fn parse(b: &[u8]) -> Result { } let (channels, frames, bits, rate, compression) = comm.ok_or_else(|| AudioError::Malformed("AIFF has no COMM chunk".into()))?; - if channels == 0 { + if channels <= 0 { return Err(AudioError::Malformed("AIFF declares zero or negative channels".into())); } if !(1.0..=MAX_SAMPLE_RATE).contains(&rate) { @@ -137,7 +137,7 @@ pub(crate) fn parse(b: &[u8]) -> Result { let block = kind.bytes().saturating_mul(channels as usize).max(1); let frames = u64::from(frames).min((data_len / block) as u64); Ok(AiffParse::Native(AiffLayout { - info: AudioInfo { format: FileFormat::Aiff, sample_format, sample_rate, channels, frames, bwf: None }, + info: AudioInfo { format: FileFormat::Aiff, sample_format, sample_rate, channels: channels as u16, frames, bwf: None }, kind, data_start, data_len, diff --git a/crates/audio-io/tests/hunter_aiff_channels.rs b/crates/audio-io/tests/hunter_aiff_channels.rs deleted file mode 100644 index 2fa95f2e..00000000 --- a/crates/audio-io/tests/hunter_aiff_channels.rs +++ /dev/null @@ -1,26 +0,0 @@ -use soundcraft_audio_io::probe; - -#[test] -fn aiff_accepts_full_unsigned_channel_count() { - let mut comm = Vec::new(); - comm.extend_from_slice(&32_768u16.to_be_bytes()); - comm.extend_from_slice(&0u32.to_be_bytes()); - comm.extend_from_slice(&16u16.to_be_bytes()); - // 44,100 Hz as an 80-bit extended float. - comm.extend_from_slice(&[0x40, 0x0e, 0xac, 0x44, 0, 0, 0, 0, 0, 0]); - - let mut file = b"FORM".to_vec(); - file.extend_from_slice(&0u32.to_be_bytes()); - file.extend_from_slice(b"AIFF"); - file.extend_from_slice(b"COMM"); - file.extend_from_slice(&(comm.len() as u32).to_be_bytes()); - file.extend_from_slice(&comm); - file.extend_from_slice(b"SSND"); - file.extend_from_slice(&8u32.to_be_bytes()); - file.extend_from_slice(&[0; 8]); - let form_size = (file.len() - 8) as u32; - file[4..8].copy_from_slice(&form_size.to_be_bytes()); - - let info = probe(&file, Some("aiff")).expect("valid AIFF"); - assert_eq!(info.channels, 32_768); -} diff --git a/crates/audio-io/tests/it/malformed.rs b/crates/audio-io/tests/it/malformed.rs index 0351725d..c618c8f0 100644 --- a/crates/audio-io/tests/it/malformed.rs +++ b/crates/audio-io/tests/it/malformed.rs @@ -110,6 +110,15 @@ fn zero_channels_is_malformed() { assert!(matches!(decode(&aiff, None), Err(AudioError::Malformed(_)))); } +#[test] +fn aiff_negative_channel_count_is_malformed() { + let mut aiff = small(FileFormat::Aiff, BitDepth::Int16, 1); + let comm = aiff.windows(4).position(|w| w == b"COMM").unwrap(); + aiff[comm + 8] = 0x80; + aiff[comm + 9] = 0; + assert!(probe(&aiff, None).is_err()); +} + #[test] fn zero_sample_rate_is_malformed() { let wav = riff(&[(b"fmt ", fmt(1, 2, 0, 16)), (b"data", vec![0; 16])]); From d588e7466782e198abcf75a0ec688a7f395c5e1e Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 1 Nov 2026 12:30:07 -0500 Subject: [PATCH 43/46] docs: sync Craft App Suite list with ArtCraft Launcher --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1024eba0..1056d6b4 100644 --- a/README.md +++ b/README.md @@ -340,7 +340,15 @@ stand on its own. | | **PdfCraft** | Reading, organizing and protecting PDFs | [GitHub](https://github.com/storytold/pdfcraft) | [Website](https://getartcraft.com/apps/pdfcraft) | | | **EffectCraft** | Motion graphics and visual effects | [GitHub](https://github.com/storytold/effectcraft) | [Website](https://getartcraft.com/apps/effectcraft) | | | **DesignCraft** | Page layout and publishing | [GitHub](https://github.com/storytold/designcraft) | [Website](https://getartcraft.com/apps/designcraft) | -| | **SoundCraft** | **Recording, editing and mixing audio · you are here** | [GitHub](https://github.com/storytold/soundcraft) | [Website](https://getartcraft.com/apps/soundcraft) | +| | **FigCraft** | Interface design and prototyping | [GitHub](https://github.com/storytold/figcraft) | [Website](https://getartcraft.com/apps/figcraft) | +| | **WordCraft** | Word processing and documents | [GitHub](https://github.com/storytold/wordcraft) | [Website](https://getartcraft.com/apps/wordcraft) | +| | **SoundCraft** | Audio recording and editing | [GitHub](https://github.com/storytold/soundcraft) | [Website](https://getartcraft.com/apps/soundcraft) | +| | **DeckCraft** | Presentations and slide decks | [GitHub](https://github.com/storytold/deckcraft) | [Website](https://getartcraft.com/apps/deckcraft) | +| | **CADCraft** | Computer-aided design | [GitHub](https://github.com/storytold/cadcraft) | [Website](https://getartcraft.com/apps/cadcraft) | +| | **GridCraft** | Spreadsheets and data | [GitHub](https://github.com/storytold/gridcraft) | [Website](https://getartcraft.com/apps/gridcraft) | +| | **TextureCraft** | 3D texture painting | [GitHub](https://github.com/storytold/texturecraft) | [Website](https://getartcraft.com/apps/texturecraft) | +| | **Craft Anything** | See how any software works, then build your own | [GitHub](https://github.com/storytold/craft-anything) | [Website](https://getartcraft.com/apps/craft-anything) | +| | **SolidCraft** | Parametric 3D CAD by Tangency Labs (community app) | [GitHub](https://github.com/tangency-labs/solidcraft) | | And [**ArtCraft**](https://getartcraft.com/) itself, our AI image and video studio for artists who want real control. From db51dd17398852ba70919c5a560d1c8ed9e3e6c6 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 1 Nov 2026 13:57:15 -0500 Subject: [PATCH 44/46] Release 0.16.0 Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 36 ++++++++++++++++++------------------ Cargo.toml | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 401b3c60..a265b063 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4280,7 +4280,7 @@ dependencies = [ [[package]] name = "soundcraft" -version = "0.15.0" +version = "0.16.0" dependencies = [ "chrono", "clap", @@ -4304,7 +4304,7 @@ dependencies = [ [[package]] name = "soundcraft-au-host" -version = "0.15.0" +version = "0.16.0" dependencies = [ "log", "serde", @@ -4314,7 +4314,7 @@ dependencies = [ [[package]] name = "soundcraft-audio-io" -version = "0.15.0" +version = "0.16.0" dependencies = [ "log", "proptest", @@ -4326,7 +4326,7 @@ dependencies = [ [[package]] name = "soundcraft-automation" -version = "0.15.0" +version = "0.16.0" dependencies = [ "clap", "log", @@ -4339,7 +4339,7 @@ dependencies = [ [[package]] name = "soundcraft-clap-host" -version = "0.15.0" +version = "0.16.0" dependencies = [ "clap-sys", "libloading 0.9.0", @@ -4352,7 +4352,7 @@ dependencies = [ [[package]] name = "soundcraft-cli" -version = "0.15.0" +version = "0.16.0" dependencies = [ "clap", "clap_complete", @@ -4369,7 +4369,7 @@ dependencies = [ [[package]] name = "soundcraft-dsp" -version = "0.15.0" +version = "0.16.0" dependencies = [ "log", "proptest", @@ -4380,7 +4380,7 @@ dependencies = [ [[package]] name = "soundcraft-engine" -version = "0.15.0" +version = "0.16.0" dependencies = [ "craft-docpath", "log", @@ -4403,7 +4403,7 @@ dependencies = [ [[package]] name = "soundcraft-midi" -version = "0.15.0" +version = "0.16.0" dependencies = [ "proptest", "serde", @@ -4413,7 +4413,7 @@ dependencies = [ [[package]] name = "soundcraft-mix" -version = "0.15.0" +version = "0.16.0" dependencies = [ "log", "rayon", @@ -4429,7 +4429,7 @@ dependencies = [ [[package]] name = "soundcraft-model" -version = "0.15.0" +version = "0.16.0" dependencies = [ "proptest", "serde", @@ -4442,7 +4442,7 @@ dependencies = [ [[package]] name = "soundcraft-playback" -version = "0.15.0" +version = "0.16.0" dependencies = [ "cpal", "log", @@ -4457,7 +4457,7 @@ dependencies = [ [[package]] name = "soundcraft-time" -version = "0.15.0" +version = "0.16.0" dependencies = [ "proptest", "serde", @@ -4467,7 +4467,7 @@ dependencies = [ [[package]] name = "soundcraft-ui-egui" -version = "0.15.0" +version = "0.16.0" dependencies = [ "craft-ui", "craft-update", @@ -4496,7 +4496,7 @@ dependencies = [ [[package]] name = "soundcraft-video" -version = "0.15.0" +version = "0.16.0" dependencies = [ "craft-media", "image", @@ -4508,7 +4508,7 @@ dependencies = [ [[package]] name = "soundcraft-vst3-host" -version = "0.15.0" +version = "0.16.0" dependencies = [ "libloading 0.9.0", "log", @@ -4524,7 +4524,7 @@ dependencies = [ [[package]] name = "soundcraft-web" -version = "0.15.0" +version = "0.16.0" dependencies = [ "eframe", "egui", @@ -6140,7 +6140,7 @@ checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" [[package]] name = "xtask" -version = "0.15.0" +version = "0.16.0" dependencies = [ "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index 73b3e0b7..5bb43523 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"] default-members = ["crates/*", "apps/*", "xtask"] [workspace.package] -version = "0.15.0" +version = "0.16.0" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.90" From c426b889bb4fbd882e7d3a497d6bf81c2d698697 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 1 Nov 2026 23:05:08 -0500 Subject: [PATCH 45/46] Test MIDI export of a clip trimmed at both ends Co-Authored-By: Claude Opus 5.5 --- crates/engine/tests/it/midi_offset.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crates/engine/tests/it/midi_offset.rs b/crates/engine/tests/it/midi_offset.rs index f0f4b2d6..9953d08d 100644 --- a/crates/engine/tests/it/midi_offset.rs +++ b/crates/engine/tests/it/midi_offset.rs @@ -74,3 +74,25 @@ fn export_midi_releases_a_sustain_held_past_the_trim() { assert!(sus.iter().any(|c| c.channel == 0 && c.tick == 960 && c.value == 0), "{sus:?}"); assert!(!sus.iter().any(|c| c.channel == 1 && c.tick == 960), "released channel gets no extra event: {sus:?}"); } + +#[test] +fn export_midi_keeps_the_notes_of_a_clip_trimmed_at_both_ends_in_place() { + let mut e = Engine::default(); + let r = e.execute("track.new", &json!({"kind": "instrument", "name": "Both", "instrument": "subtractive_synth"})).unwrap(); + let track = r["tracks"][0].as_u64().unwrap(); + let r = e.execute("midi.new_clip", &json!({"track": track, "start": 0, "length": 96_000})).unwrap(); + let clip = r["clip"].as_u64().unwrap(); + for (pitch, start) in [(60, 0), (62, 1000), (64, 2000)] { + e.execute("midi.note_add", &json!({"clip": clip, "pitch": pitch, "start_ticks": start, "length_ticks": 960, "velocity": 100})).unwrap(); + } + // 24000 samples is 960 ticks and 72000 samples is 2880 ticks at 120 bpm. + e.execute("edit.trim_start_to_insertion", &json!({"tracks": [track], "at": 24_000})).unwrap(); + e.execute("edit.trim_end_to_insertion", &json!({"tracks": [track], "at": 72_000})).unwrap(); + + let bytes = soundcraft_engine::io::export_midi(&e, None).unwrap(); + let smf = soundcraft_midi::read_smf(&bytes).unwrap(); + let mut notes: Vec<_> = smf.tracks[0].sequence.notes.iter().map(|n| (n.pitch, n.start, n.length)).collect(); + notes.sort_unstable(); + // The note cut by the start trim is gone; the others keep their place and the last stops at the end. + assert_eq!(notes, vec![(62, 1000, 960), (64, 2000, 880)]); +} From 5e8898976ef941fd3c56afb1bcbb902328ad35df Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 1 Nov 2026 23:06:02 -0500 Subject: [PATCH 46/46] Test a grid of 1/16, 1/32 and 1/64 bars in a row Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/score.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/engine/src/score.rs b/crates/engine/src/score.rs index 884e8d80..70849156 100644 --- a/crates/engine/src/score.rs +++ b/crates/engine/src/score.rs @@ -686,6 +686,24 @@ mod tests { } } + #[test] + fn bars_of_a_sixteenth_a_32nd_and_a_64th_in_a_row_keep_a_contiguous_grid() { + let base = crate::demo::demo_engine(); + let baseline = note_starts(&layout(base.session(), &[])); + let mut e = crate::demo::demo_engine(); + // Bars 5 to 8 are 1/16, 1/32, 1/64 and 3/64 long, then 4/4 resumes. + for (bar, (n, d)) in (5..).zip([(1, 16), (1, 32), (1, 64), (3, 64), (4, 4)]) { + let tick = e.session().tempo.bar_start_tick(bar); + e.session_mut().tempo.set_meter(tick, n, d).expect("valid meter"); + } + let grid = measure_grid(e.session(), i64::MAX); + assert_eq!(grid.first().map(|m| m.0), Some(0)); + for w in grid.windows(2) { + assert_eq!(w[0].0 + w[0].1, w[1].0, "measures leave no gap or overlap: {w:?}"); + } + assert_eq!(note_starts(&layout(e.session(), &[])), baseline, "notes lost"); + } + #[test] fn output_is_bounded_by_byte_budget() { // A part with many notes must not produce an unbounded document.