mirror of
https://github.com/storytold/soundcraft.git
synced 2026-11-20 17:14:57 +00:00
fix(track): Clear Trim Automation removes the trim lane (#233)
This commit is contained in:
1 parent
df0c4790b7
commit
93ddd419f5
2 files changed
+34
-1
No files matched your search
@@ -98,7 +98,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
Ok(json!({"track": t}))
|
||||
}),
|
||||
cmd!("track.clear_clip_indicators", "Clear All Clip Indicators", ["Track"], Some("Alt+C"), "{}", always, |_, _| Ok(json!({"cleared": true}))),
|
||||
cmd!("track.clear_trim_automation", "Clear Trim Automation", ["Track"], None, "{tracks?}", has_selection, |_, _| Ok(json!({}))),
|
||||
cmd!("track.clear_trim_automation", "Clear Trim Automation", ["Track"], None, "{tracks?}", has_selection, super::track_more::clear_trim),
|
||||
cmd!("track.create_click", "Create Click Track", ["Track"], None, "{}", always, create_click),
|
||||
cmd!("track.playlist_new", "New Playlist", [], None, "{track?, name?}", has_selection, |e, p| new_playlist(e, p, false)),
|
||||
cmd!("track.playlist_duplicate", "Duplicate Playlist", [], None, "{track?, name?}", has_selection, |e, p| new_playlist(e, p, true)),
|
||||
|
||||
@@ -447,6 +447,19 @@ fn coalesce_trim(e: &mut Engine, p: &Value) -> Result<Value> {
|
||||
Ok(json!({"tracks": n}))
|
||||
}
|
||||
|
||||
pub(super) fn clear_trim(e: &mut Engine, p: &Value) -> Result<Value> {
|
||||
let tracks = tracks_required(e, "track.clear_trim_automation", p)?;
|
||||
let s = e.session_mut();
|
||||
let mut n = 0;
|
||||
for t in &tracks {
|
||||
let Some(tr) = s.track_mut(*t) else { continue };
|
||||
let before = tr.automation.len();
|
||||
tr.automation.retain(|l| l.param != trim_param());
|
||||
n += before - tr.automation.len();
|
||||
}
|
||||
Ok(json!({"tracks": n}))
|
||||
}
|
||||
|
||||
fn coalesce_vca(e: &mut Engine, p: &Value) -> Result<Value> {
|
||||
let id = "track.coalesce_vca";
|
||||
let picked = tracks_param(e, id, p)?;
|
||||
@@ -649,6 +662,26 @@ mod tests {
|
||||
assert!(tr.lane(&trim_param()).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clear_trim_automation_removes_only_trim() {
|
||||
let mut e = Engine::default();
|
||||
e.execute("track.new", &json!({"count": 2})).unwrap();
|
||||
let ids: Vec<TrackId> = e.session().tracks.iter().map(|t| t.id).collect();
|
||||
let (a, b) = (ids[0], ids[1]);
|
||||
e.execute("automation.set_point", &json!({"track": a.0, "param": "volume", "at": 0, "value": -3.0})).unwrap();
|
||||
e.execute("track.trim_automation_write", &json!({"tracks": [a.0, b.0], "start": 0, "end": 4800, "db": -12.0})).unwrap();
|
||||
let has_trim = |e: &Engine, t: TrackId| e.session().track(t).unwrap().lane(&trim_param()).is_some_and(|l| !l.points.is_empty());
|
||||
e.execute("edit.select", &json!({"tracks": [a.0]})).unwrap();
|
||||
e.execute("track.clear_trim_automation", &json!({})).unwrap();
|
||||
assert!(!has_trim(&e, a), "the selected track loses its trim");
|
||||
assert!(has_trim(&e, b), "other tracks keep theirs");
|
||||
assert_eq!(e.session().track(a).unwrap().lane(&AutoParam::Volume).unwrap().points.len(), 1);
|
||||
e.execute("track.clear_trim_automation", &json!({"tracks": [b.0]})).unwrap();
|
||||
assert!(!has_trim(&e, b), "an explicit track is cleared too");
|
||||
assert!(e.undo());
|
||||
assert!(has_trim(&e, b), "undo brings the trim back");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn target_and_recent_playlists() {
|
||||
let mut e = crate::demo::demo_engine();
|
||||
|
||||
Reference in new issue
Block a user