A jumpcut reaches as far as you tell it to
Browse files at this commit88fbed0f96af61ae29980a214cef7c9f78625e21Parent: 564ba30- feat
- a jumpcut reaches as far as you tell it to
4 changed files +434 -103
- crates/app/src/main.rs +146 -40
- crates/engine/src/playback.rs +20 -11
- crates/engine/src/project.rs +144 -43
- crates/engine/tests/silence.rs +124 -9
crates/app/src/main.rsmodified+146 -40
| @@ -357,10 +357,49 @@ fn speed_at(permille: i32) -> Speed { | ||
| 357 | 357 | Speed::from_permille(permille.clamp(0, i32::from(u16::MAX)) as u16) |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | -/// The silence card's rows, in the order it lists them: the four settings a | |
| 361 | -/// scan is told and the rate the speed-up plays at. What `silence_field` | |
| 362 | -/// indexes and what [`Player::nudge_silence`] moves. | |
| 363 | -const SILENCE_ROWS: usize = 5; | |
| 360 | +/// The silence card's rows, in the order it lists them: how wide the apply | |
| 361 | +/// reaches, the four settings a scan is told, and the rate the speed-up plays | |
| 362 | +/// at. What `silence_field` indexes and what [`Player::nudge_silence`] moves. | |
| 363 | +const SILENCE_ROWS: usize = 6; | |
| 364 | + | |
| 365 | +/// How wide a jumpcut reaches. A ripple used to be the whole timeline's | |
| 366 | +/// business and nothing else; it is a *choice* now, because a podcast track's | |
| 367 | +/// silences are not the music track's business -- and the choice has to be on | |
| 368 | +/// screen, because "everything after this moved" is not a thing to discover | |
| 369 | +/// afterwards. | |
| 370 | +#[derive(Clone, Copy, PartialEq, Eq, Debug)] | |
| 371 | +enum Scope { | |
| 372 | + /// The lanes of the take the scanned clip belongs to: its picture and its | |
| 373 | + /// sound stay one take, and nothing else moves. The default, because a clip | |
| 374 | + /// picked on screen is what a person means by "this". | |
| 375 | + Take, | |
| 376 | + /// That clip's lane, alone. Refused by the engine, by name, while the take | |
| 377 | + /// has a half elsewhere -- detaching is how a person says they mean it. | |
| 378 | + Track, | |
| 379 | + /// Every lane, which is what a ripple always was and what the timeline-wide | |
| 380 | + /// jumpcut still is. | |
| 381 | + Everything, | |
| 382 | +} | |
| 383 | + | |
| 384 | +/// The order the card cycles them in. | |
| 385 | +const SCOPES: [Scope; 3] = [Scope::Take, Scope::Track, Scope::Everything]; | |
| 386 | + | |
| 387 | +impl Scope { | |
| 388 | + /// What the row says, given the lanes it works out to: the *names* of the | |
| 389 | + /// tracks, because "this take" means nothing until it says which two. | |
| 390 | + fn label(self, lanes: &[Lane]) -> String { | |
| 391 | + let named = lanes | |
| 392 | + .iter() | |
| 393 | + .map(|l| l.label()) | |
| 394 | + .collect::<Vec<_>>() | |
| 395 | + .join("+"); | |
| 396 | + match self { | |
| 397 | + Scope::Take => format!("this take ({named})"), | |
| 398 | + Scope::Track => format!("this track ({named})"), | |
| 399 | + Scope::Everything => "every track".to_string(), | |
| 400 | + } | |
| 401 | + } | |
| 402 | +} | |
| 364 | 403 | |
| 365 | 404 | /// One press of a nudge key on each kind of row: a dB on the threshold, a |
| 366 | 405 | /// twentieth of a second on the three durations, and the speed card's own step |
| @@ -606,6 +645,10 @@ struct Player { | ||
| 606 | 645 | /// second run offers what the first one settled on. |
| 607 | 646 | silence: engine::silence::Settings, |
| 608 | 647 | silence_factor: Speed, |
| 648 | + /// How wide the apply reaches ([`Scope`]). Kept across closes for the same | |
| 649 | + /// reason, and never *widened* on anyone's behalf: the whole point of it is | |
| 650 | + /// that a track nobody named does not move. | |
| 651 | + silence_scope: Scope, | |
| 609 | 652 | /// Which of the card's [`SILENCE_ROWS`] the arrow keys move. The card's own |
| 610 | 653 | /// focus, since nothing in it takes gpui's (ledger:182). |
| 611 | 654 | silence_field: usize, |
| @@ -1259,27 +1302,65 @@ impl Player { | ||
| 1259 | 1302 | .clamp(SILENCE_SECS_RANGE.0, SILENCE_SECS_RANGE.1) |
| 1260 | 1303 | }; |
| 1261 | 1304 | match self.silence_field { |
| 1305 | + // Round either way, like the fit policy's cycle: three choices are | |
| 1306 | + // a ring, not a range. | |
| 1262 | 1307 | 0 => { |
| 1308 | + let at = SCOPES.iter().position(|&s| s == self.silence_scope); | |
| 1309 | + let step = steps.rem_euclid(SCOPES.len() as i32) as usize; | |
| 1310 | + self.silence_scope = SCOPES[(at.unwrap_or(0) + step) % SCOPES.len()]; | |
| 1311 | + } | |
| 1312 | + 1 => { | |
| 1263 | 1313 | self.silence.threshold_db = (self.silence.threshold_db |
| 1264 | 1314 | + steps as f32 * SILENCE_DB_STEP) |
| 1265 | 1315 | .clamp(SILENCE_DB_RANGE.0, SILENCE_DB_RANGE.1) |
| 1266 | 1316 | } |
| 1267 | - 1 => self.silence.min_silence = secs(self.silence.min_silence), | |
| 1268 | - 2 => self.silence.padding = secs(self.silence.padding), | |
| 1269 | - 3 => self.silence.min_keep = secs(self.silence.min_keep), | |
| 1317 | + 2 => self.silence.min_silence = secs(self.silence.min_silence), | |
| 1318 | + 3 => self.silence.padding = secs(self.silence.padding), | |
| 1319 | + 4 => self.silence.min_keep = secs(self.silence.min_keep), | |
| 1270 | 1320 | _ => { |
| 1271 | 1321 | self.silence_factor = |
| 1272 | 1322 | silence_rate(i32::from(self.silence_factor.permille()) + steps * SPEED_STEP) |
| 1273 | 1323 | } |
| 1274 | 1324 | } |
| 1275 | - // The rate is not part of the scan, but re-running is cheap (the levels | |
| 1276 | - // are cached) and one path is one place for the marks to come from. | |
| 1325 | + // Neither the scope nor the rate is part of the scan, but re-running is | |
| 1326 | + // cheap (the levels are cached) and one path is one place for the marks | |
| 1327 | + // to come from. | |
| 1277 | 1328 | self.scan_silences(); |
| 1278 | 1329 | } |
| 1279 | 1330 | |
| 1280 | - /// What an apply acts on: the previewed set, or nothing at all with a | |
| 1281 | - /// notice saying so in the numbers that found nothing. | |
| 1282 | - fn previewed(&mut self) -> Option<Vec<(u32, u32)>> { | |
| 1331 | + /// Which lanes an apply reaches, as the card's scope row says it: the | |
| 1332 | + /// lanes of the take the scanned clip belongs to, that clip's lane alone, | |
| 1333 | + /// or every lane there is. | |
| 1334 | + /// | |
| 1335 | + /// The take's lanes are the ones carrying its group id -- a link is one | |
| 1336 | + /// span on however many lanes, so "the take" is exactly the set of lanes | |
| 1337 | + /// that would otherwise be pulled apart. Nothing widens behind the user's | |
| 1338 | + /// back: [`Project::cut_regions`] refuses a scope that would split a take, | |
| 1339 | + /// and this row is how the user says the take instead. | |
| 1340 | + fn silence_lanes(&self) -> Vec<Lane> { | |
| 1341 | + let (Some((lane, idx)), Some(session)) = (self.silence_open, self.session.as_ref()) else { | |
| 1342 | + return Vec::new(); | |
| 1343 | + }; | |
| 1344 | + match self.silence_scope { | |
| 1345 | + Scope::Track => vec![lane], | |
| 1346 | + Scope::Everything => session.lanes(), | |
| 1347 | + Scope::Take => match session.lane_clips(lane).get(idx).and_then(|c| c.link) { | |
| 1348 | + None => vec![lane], | |
| 1349 | + Some(id) => session | |
| 1350 | + .lanes() | |
| 1351 | + .into_iter() | |
| 1352 | + .filter(|&l| { | |
| 1353 | + l == lane || session.lane_clips(l).iter().any(|c| c.link == Some(id)) | |
| 1354 | + }) | |
| 1355 | + .collect(), | |
| 1356 | + }, | |
| 1357 | + } | |
| 1358 | + } | |
| 1359 | + | |
| 1360 | + /// What an apply acts on: the previewed set and the lanes it reaches, or | |
| 1361 | + /// nothing at all with a notice saying so in the numbers that found | |
| 1362 | + /// nothing. | |
| 1363 | + fn previewed(&mut self) -> Option<(Vec<(u32, u32)>, Vec<Lane>)> { | |
| 1283 | 1364 | if self.silence_marks.is_empty() { |
| 1284 | 1365 | self.notice = Some( |
| 1285 | 1366 | format!( |
| @@ -1290,60 +1371,81 @@ impl Player { | ||
| 1290 | 1371 | ); |
| 1291 | 1372 | return None; |
| 1292 | 1373 | } |
| 1293 | - Some(self.silence_marks.clone()) | |
| 1374 | + Some((self.silence_marks.clone(), self.silence_lanes())) | |
| 1294 | 1375 | } |
| 1295 | 1376 | |
| 1296 | - /// Cuts every previewed silence out of every lane, rippling each hole | |
| 1297 | - /// closed -- one edit and **one** undo press however many there were | |
| 1298 | - /// ([`engine::PlaybackSession::cut_regions`]). The linked picture slides | |
| 1299 | - /// with its sound, because a ripple is uniform across the lanes. | |
| 1377 | + /// What an apply says afterwards: which tracks it reached, and -- when that | |
| 1378 | + /// was not all of them -- that the rest were left where they were. The | |
| 1379 | + /// scope is a choice, so the confirmation has to name the choice. | |
| 1380 | + fn silence_reach(&self, lanes: &[Lane]) -> String { | |
| 1381 | + let named = lanes | |
| 1382 | + .iter() | |
| 1383 | + .map(|l| l.label()) | |
| 1384 | + .collect::<Vec<_>>() | |
| 1385 | + .join("+"); | |
| 1386 | + match self.silence_scope { | |
| 1387 | + Scope::Everything => "on every track".to_string(), | |
| 1388 | + _ => format!("on {named} — other tracks untouched"), | |
| 1389 | + } | |
| 1390 | + } | |
| 1391 | + | |
| 1392 | + /// Cuts every previewed silence out of the lanes the scope names, rippling | |
| 1393 | + /// each hole closed -- one edit and **one** undo press however many there | |
| 1394 | + /// were ([`engine::PlaybackSession::cut_regions`]). Tracks outside the | |
| 1395 | + /// scope do not move; a scope that would take half a take with it comes | |
| 1396 | + /// back refused in the engine's own words, naming both halves. | |
| 1300 | 1397 | fn cut_silences(&mut self, cx: &mut Context<Self>) { |
| 1301 | - let Some(regions) = self.previewed() else { | |
| 1398 | + let Some((regions, lanes)) = self.previewed() else { | |
| 1302 | 1399 | cx.notify(); |
| 1303 | 1400 | return; |
| 1304 | 1401 | }; |
| 1305 | 1402 | let saved = f64::from(regions.iter().map(|&(_, len)| len).sum::<u32>()) / self.fps; |
| 1306 | - let count = regions.len(); | |
| 1307 | - let cut = self | |
| 1308 | - .session | |
| 1309 | - .as_mut() | |
| 1310 | - .is_some_and(|session| session.cut_regions(®ions)); | |
| 1311 | - if cut { | |
| 1312 | - self.close_silence(); | |
| 1313 | - self.reset_after_reseek(); | |
| 1314 | - self.notice = Some( | |
| 1315 | - format!( | |
| 1316 | - "{count} SILENCES CUT — {saved:.1}s shorter, {} takes it back", | |
| 1317 | - self.keymap.display(ActionId::Undo) | |
| 1318 | - ) | |
| 1319 | - .into(), | |
| 1320 | - ); | |
| 1403 | + let (count, reach) = (regions.len(), self.silence_reach(&lanes)); | |
| 1404 | + let Some(session) = self.session.as_mut() else { | |
| 1405 | + cx.notify(); | |
| 1406 | + return; | |
| 1407 | + }; | |
| 1408 | + match session.cut_regions(®ions, &lanes) { | |
| 1409 | + Ok(()) => { | |
| 1410 | + self.close_silence(); | |
| 1411 | + self.reset_after_reseek(); | |
| 1412 | + self.notice = Some( | |
| 1413 | + format!( | |
| 1414 | + "{count} SILENCES CUT {reach} — {saved:.1}s shorter, {} takes it back", | |
| 1415 | + self.keymap.display(ActionId::Undo) | |
| 1416 | + ) | |
| 1417 | + .into(), | |
| 1418 | + ); | |
| 1419 | + } | |
| 1420 | + Err(e) => self.notice = Some(e.to_string().into()), | |
| 1321 | 1421 | } |
| 1322 | 1422 | cx.notify(); |
| 1323 | 1423 | } |
| 1324 | 1424 | |
| 1325 | 1425 | /// Plays them fast instead of cutting them, closing the room each one no |
| 1326 | - /// longer needs. One undo press like the cut; the refusal (a clip on | |
| 1327 | - /// another lane lapping over a silence) comes back in the engine's own | |
| 1328 | - /// words and names the lane and frame, and the card stays up so the numbers | |
| 1329 | - /// that produced it are still on screen. | |
| 1426 | + /// longer needs. One undo press like the cut, and the same scope; the | |
| 1427 | + /// refusals (a clip lapping over a silence, a scope that would split a | |
| 1428 | + /// take) come back in the engine's own words and name the lane and frame, | |
| 1429 | + /// and the card stays up so the numbers that produced it are still on | |
| 1430 | + /// screen. | |
| 1330 | 1431 | fn speed_silences(&mut self, cx: &mut Context<Self>) { |
| 1331 | - let Some(regions) = self.previewed() else { | |
| 1432 | + let Some((regions, lanes)) = self.previewed() else { | |
| 1332 | 1433 | cx.notify(); |
| 1333 | 1434 | return; |
| 1334 | 1435 | }; |
| 1335 | 1436 | let (count, rate) = (regions.len(), self.silence_factor); |
| 1437 | + let reach = self.silence_reach(&lanes); | |
| 1336 | 1438 | let Some(session) = self.session.as_mut() else { |
| 1337 | 1439 | cx.notify(); |
| 1338 | 1440 | return; |
| 1339 | 1441 | }; |
| 1340 | - match session.speed_regions(®ions, rate) { | |
| 1442 | + match session.speed_regions(®ions, rate, &lanes) { | |
| 1341 | 1443 | Ok(()) => { |
| 1342 | 1444 | self.close_silence(); |
| 1343 | 1445 | self.reset_after_reseek(); |
| 1344 | 1446 | self.notice = Some( |
| 1345 | 1447 | format!( |
| 1346 | - "{count} SILENCES AT {rate} — {} takes it back", | |
| 1448 | + "{count} SILENCES AT {rate} {reach} — {} takes it back", | |
| 1347 | 1449 | self.keymap.display(ActionId::Undo) |
| 1348 | 1450 | ) |
| 1349 | 1451 | .into(), |
| @@ -4447,6 +4549,7 @@ impl Player { | ||
| 4447 | 4549 | let (lane, idx) = self.silence_open?; |
| 4448 | 4550 | let cfg = self.silence; |
| 4449 | 4551 | let rows = [ |
| 4552 | + ("Apply to", self.silence_scope.label(&self.silence_lanes())), | |
| 4450 | 4553 | ("Silence is under", format!("{:.0} dBFS", cfg.threshold_db)), |
| 4451 | 4554 | ( |
| 4452 | 4555 | "Forgive quiet shorter than", |
| @@ -8621,6 +8724,9 @@ fn main() { | ||
| 8621 | 8724 | // scan that leaves a little too much is one nobody undoes. |
| 8622 | 8725 | silence: engine::silence::Settings::default(), |
| 8623 | 8726 | silence_factor: Speed::MAX, |
| 8727 | + // The take, not the timeline: the narrower answer is the | |
| 8728 | + // one a person can widen on purpose. | |
| 8729 | + silence_scope: Scope::Take, | |
| 8624 | 8730 | silence_field: 0, |
| 8625 | 8731 | silence_marks: Vec::new(), |
| 8626 | 8732 | silence_levels: None, |
crates/engine/src/playback.rsmodified+20 -11
| @@ -1004,23 +1004,32 @@ impl PlaybackSession { | ||
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | /// Cuts every one of `regions` -- `(start, len)` in timeline frames -- out |
| 1007 | - /// of every lane and closes each hole, as **one** edit | |
| 1007 | + /// of the lanes in `scope` and closes each hole, as **one** edit | |
| 1008 | 1008 | /// ([`Project::cut_regions`]): the jumpcut a silence scan |
| 1009 | 1009 | /// ([`crate::silence`]) asks for, one undo press however many silences it |
| 1010 | - /// found. Reseeks like every other edit, so what plays is the cut timeline | |
| 1011 | - /// from the playhead on. `false`, and no undo step, for an empty list. | |
| 1012 | - pub fn cut_regions(&mut self, regions: &[(u32, u32)]) -> bool { | |
| 1013 | - self.edit(|p| p.cut_regions(regions)) | |
| 1010 | + /// found. A lane outside `scope` does not move. Reseeks like every other | |
| 1011 | + /// edit, so what plays is the cut timeline from the playhead on. The `Err` | |
| 1012 | + /// names what is in the way and nothing changes. | |
| 1013 | + pub fn cut_regions(&mut self, regions: &[(u32, u32)], scope: &[Lane]) -> crate::Result<()> { | |
| 1014 | + // Spelled out rather than through `edit`, whose closure hands back a | |
| 1015 | + // bool and would drop the refusal's own words. | |
| 1016 | + self.project.cut_regions(regions, scope)?; | |
| 1017 | + let now = self.now(); | |
| 1018 | + self.seek(now); | |
| 1019 | + Ok(()) | |
| 1014 | 1020 | } |
| 1015 | 1021 | |
| 1016 | 1022 | /// Plays every one of those regions at `speed` instead of cutting them, |
| 1017 | 1023 | /// closing the room each one no longer needs ([`Project::speed_regions`]) -- |
| 1018 | - /// one edit, one undo press. The `Err` names the lane and frame in the way | |
| 1019 | - /// and nothing changes. | |
| 1020 | - pub fn speed_regions(&mut self, regions: &[(u32, u32)], speed: Speed) -> crate::Result<()> { | |
| 1021 | - // Spelled out rather than through `edit`, whose closure hands back a | |
| 1022 | - // bool and would drop the refusal's own words. | |
| 1023 | - self.project.speed_regions(regions, speed)?; | |
| 1024 | + /// one edit, one undo press, and the same scope rule. The `Err` names the | |
| 1025 | + /// lane and frame in the way and nothing changes. | |
| 1026 | + pub fn speed_regions( | |
| 1027 | + &mut self, | |
| 1028 | + regions: &[(u32, u32)], | |
| 1029 | + speed: Speed, | |
| 1030 | + scope: &[Lane], | |
| 1031 | + ) -> crate::Result<()> { | |
| 1032 | + self.project.speed_regions(regions, speed, scope)?; | |
| 1024 | 1033 | let now = self.now(); |
| 1025 | 1034 | self.seek(now); |
| 1026 | 1035 | Ok(()) |
crates/engine/src/project.rsmodified+144 -43
| @@ -1306,17 +1306,24 @@ impl Project { | ||
| 1306 | 1306 | /// |
| 1307 | 1307 | /// Metadata only: no mapping changes, in any lane. |
| 1308 | 1308 | pub fn split(&mut self, timeline_frame: u32) -> bool { |
| 1309 | - self.write_split(timeline_frame, true) | |
| 1309 | + self.write_split(timeline_frame, true, &all_lanes(&self.lanes)) | |
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | - /// [`split`](Project::split), with the snapshot optional: a batch that has | |
| 1313 | - /// already taken one ([`speed_regions`](Project::speed_regions)) splits at | |
| 1314 | - /// two frames per region and must still be one undo press. | |
| 1315 | - fn write_split(&mut self, timeline_frame: u32, snapshot: bool) -> bool { | |
| 1312 | + /// [`split`](Project::split), with the snapshot optional and the lanes | |
| 1313 | + /// named: a batch that has already taken a snapshot | |
| 1314 | + /// ([`speed_regions`](Project::speed_regions)) splits at two frames per | |
| 1315 | + /// region and must still be one undo press, and a *scoped* batch must not | |
| 1316 | + /// cut a lane it was told to leave alone. | |
| 1317 | + fn write_split(&mut self, timeline_frame: u32, snapshot: bool, on: &[usize]) -> bool { | |
| 1316 | 1318 | let cut: Vec<Option<Clip>> = self |
| 1317 | 1319 | .lanes |
| 1318 | 1320 | .iter() |
| 1319 | - .map(|l| splittable(&l.clips, timeline_frame).map(|idx| l.clips[idx])) | |
| 1321 | + .enumerate() | |
| 1322 | + .map(|(i, l)| { | |
| 1323 | + on.contains(&i) | |
| 1324 | + .then(|| splittable(&l.clips, timeline_frame).map(|idx| l.clips[idx])) | |
| 1325 | + .flatten() | |
| 1326 | + }) | |
| 1320 | 1327 | .collect(); |
| 1321 | 1328 | if cut.iter().all(Option::is_none) { |
| 1322 | 1329 | return false; |
| @@ -1330,8 +1337,16 @@ impl Project { | ||
| 1330 | 1337 | let ends: Vec<Option<u32>> = cut.iter().map(|c| c.map(|c| c.end())).collect(); |
| 1331 | 1338 | let left = self.group_ids(&starts); |
| 1332 | 1339 | let right = self.group_ids(&ends); |
| 1333 | - for ((data, left), right) in self.lanes.iter_mut().zip(left).zip(right) { | |
| 1334 | - let Some(idx) = splittable(&data.clips, timeline_frame) else { | |
| 1340 | + for (((data, left), right), cut) in self | |
| 1341 | + .lanes | |
| 1342 | + .iter_mut() | |
| 1343 | + .zip(left) | |
| 1344 | + .zip(right) | |
| 1345 | + .zip(cut.iter().map(Option::is_some)) | |
| 1346 | + { | |
| 1347 | + // The lanes this call was not scoped to are not cut, whatever their | |
| 1348 | + // own clips would allow. | |
| 1349 | + let Some(idx) = splittable(&data.clips, timeline_frame).filter(|_| cut) else { | |
| 1335 | 1350 | continue; |
| 1336 | 1351 | }; |
| 1337 | 1352 | let mut tail = data.clips[idx]; |
| @@ -1870,13 +1885,21 @@ impl Project { | ||
| 1870 | 1885 | return false; |
| 1871 | 1886 | } |
| 1872 | 1887 | self.snapshot(); |
| 1873 | - ripple(&mut self.lanes, at, len); | |
| 1888 | + let on = all_lanes(&self.lanes); | |
| 1889 | + ripple(&mut self.lanes, &on, at, len); | |
| 1874 | 1890 | true |
| 1875 | 1891 | } |
| 1876 | 1892 | |
| 1877 | 1893 | /// Cut **every** one of `regions` -- `(start, len)` in timeline frames -- |
| 1878 | - /// out of every lane and close each hole, as one edit: the jumpcut a | |
| 1879 | - /// silence scan asks for ([`crate::silence`]). | |
| 1894 | + /// out of the lanes in `scope` and close each hole, as one edit: the | |
| 1895 | + /// jumpcut a silence scan asks for ([`crate::silence`]). | |
| 1896 | + /// | |
| 1897 | + /// A lane that is not in `scope` **does not move**, which is the whole | |
| 1898 | + /// point of the parameter: the silences of a podcast track come out | |
| 1899 | + /// without the music track under it sliding. `scope` is an arbitrary set of | |
| 1900 | + /// lanes and not a kind or a range, so a caller with its own idea of what | |
| 1901 | + /// is selected (a take, a track, everything) says it in lanes and nothing | |
| 1902 | + /// here has to learn about selection. | |
| 1880 | 1903 | /// |
| 1881 | 1904 | /// One [`snapshot`](Project::snapshot) for the lot, which is the whole |
| 1882 | 1905 | /// reason this exists rather than a caller's loop over |
| @@ -1886,19 +1909,74 @@ impl Project { | ||
| 1886 | 1909 | /// |
| 1887 | 1910 | /// The list is sorted and overlapping entries are merged before anything is |
| 1888 | 1911 | /// cut ([`tidy`]) -- two regions that overlap would otherwise cut each |
| 1889 | - /// other's frames -- and `false`, with no undo step, for a list with | |
| 1890 | - /// nothing in it. | |
| 1891 | - pub fn cut_regions(&mut self, regions: &[(u32, u32)]) -> bool { | |
| 1912 | + /// other's frames. Refused, with no undo step, for an empty list, for a | |
| 1913 | + /// scope naming no lane that is there, and -- by name -- when the scope | |
| 1914 | + /// would take one half of a take with it | |
| 1915 | + /// ([`scope_holds_takes_whole`](Project::scope_holds_takes_whole)). | |
| 1916 | + pub fn cut_regions(&mut self, regions: &[(u32, u32)], scope: &[Lane]) -> crate::Result<()> { | |
| 1892 | 1917 | let regions = tidy(regions); |
| 1893 | - if regions.is_empty() { | |
| 1894 | - return false; | |
| 1895 | - } | |
| 1918 | + let on = self.scoped(scope)?; | |
| 1919 | + let Some(&(first, _)) = regions.first() else { | |
| 1920 | + return Err("nothing to cut".into()); | |
| 1921 | + }; | |
| 1922 | + self.scope_holds_takes_whole(&on, first)?; | |
| 1896 | 1923 | self.snapshot(); |
| 1897 | 1924 | for &(at, len) in regions.iter().rev() { |
| 1898 | - ripple(&mut self.lanes, at, len); | |
| 1925 | + ripple(&mut self.lanes, &on, at, len); | |
| 1899 | 1926 | } |
| 1900 | 1927 | debug_assert!(links_are_consistent(&self.lanes).is_ok()); |
| 1901 | - true | |
| 1928 | + Ok(()) | |
| 1929 | + } | |
| 1930 | + | |
| 1931 | + /// The storage indices of `scope`, which is what every batch below walks. | |
| 1932 | + /// `Err` for a scope that names nothing there rather than a silent no-op: | |
| 1933 | + /// an edit asked for on a lane that is not there did not happen, and the | |
| 1934 | + /// caller has to hear so. | |
| 1935 | + fn scoped(&self, scope: &[Lane]) -> crate::Result<Vec<usize>> { | |
| 1936 | + let on: Vec<usize> = scope.iter().filter_map(|&l| self.index(l)).collect(); | |
| 1937 | + match on.is_empty() { | |
| 1938 | + true => Err("no track to work on".into()), | |
| 1939 | + false => Ok(on), | |
| 1940 | + } | |
| 1941 | + } | |
| 1942 | + | |
| 1943 | + /// The law a scoped ripple lives under: **a link is one span on however | |
| 1944 | + /// many lanes**, so a batch that moves one half of a take and not the other | |
| 1945 | + /// would leave a group whose halves disagree -- a project no save could | |
| 1946 | + /// load ([`links_are_consistent`]). | |
| 1947 | + /// | |
| 1948 | + /// Refused by name rather than widened silently. Widening would edit a | |
| 1949 | + /// track the user did not scope, which is exactly the surprise scoping | |
| 1950 | + /// exists to end; a front-end that wants the take is free to *say* the | |
| 1951 | + /// take's lanes, and to name them in what it tells the user afterwards. | |
| 1952 | + /// | |
| 1953 | + /// Only from `from` on: a take sitting entirely before the first cut does | |
| 1954 | + /// not move, so it is not this rule's business. | |
| 1955 | + fn scope_holds_takes_whole(&self, on: &[usize], from: u32) -> crate::Result<()> { | |
| 1956 | + let labels = handles(&self.lanes); | |
| 1957 | + for &i in on { | |
| 1958 | + for c in self.lanes[i].clips.iter().filter(|c| c.end() > from) { | |
| 1959 | + let Some(id) = c.link else { continue }; | |
| 1960 | + for (j, data) in self.lanes.iter().enumerate() { | |
| 1961 | + if on.contains(&j) { | |
| 1962 | + continue; | |
| 1963 | + } | |
| 1964 | + if let Some(half) = data.clips.iter().find(|o| o.link == Some(id)) { | |
| 1965 | + return Err(format!( | |
| 1966 | + "the {} clip at frame {} is one take with the {} clip at frame {}: \ | |
| 1967 | + moving one track of a take would pull it apart -- take the whole take, \ | |
| 1968 | + or detach them first", | |
| 1969 | + labels[i].label(), | |
| 1970 | + c.start, | |
| 1971 | + labels[j].label(), | |
| 1972 | + half.start | |
| 1973 | + ) | |
| 1974 | + .into()); | |
| 1975 | + } | |
| 1976 | + } | |
| 1977 | + } | |
| 1978 | + } | |
| 1979 | + Ok(()) | |
| 1902 | 1980 | } |
| 1903 | 1981 | |
| 1904 | 1982 | /// Play every one of `regions` at `speed` instead of cutting it: each is |
| @@ -1912,11 +1990,17 @@ impl Project { | ||
| 1912 | 1990 | /// twice over the same stretch leaves it at `speed`, not at `speed` |
| 1913 | 1991 | /// squared, so a second pass over an already-cut timeline changes nothing. |
| 1914 | 1992 | /// |
| 1993 | + /// Scoped exactly as [`cut_regions`](Project::cut_regions) is, and under | |
| 1994 | + /// the same take law: a lane outside `scope` is neither re-rated nor moved. | |
| 1995 | + /// | |
| 1915 | 1996 | /// Refused by name, with nothing changed and no undo step, when: |
| 1916 | 1997 | /// |
| 1917 | - /// * a clip on any lane covers only *part* of a region -- the lanes shrink | |
| 1918 | - /// by different amounts and the ripple would pull them apart, which is | |
| 1919 | - /// what cutting does not suffer and why delete mode has no such refusal; | |
| 1998 | + /// * the scope would take one half of a take with it | |
| 1999 | + /// ([`scope_holds_takes_whole`](Project::scope_holds_takes_whole)); | |
| 2000 | + /// * a clip on a scoped lane covers only *part* of a region -- the lanes | |
| 2001 | + /// shrink by different amounts and the ripple would pull them apart, | |
| 2002 | + /// which is what cutting does not suffer and why delete mode has no such | |
| 2003 | + /// refusal; | |
| 1920 | 2004 | /// * a rate cannot address a region's edge ([`Speed::split_at`]), so the |
| 1921 | 2005 | /// piece could not be split out exactly; |
| 1922 | 2006 | /// * two lanes' pieces would end up different lengths, which is a group |
| @@ -1924,19 +2008,26 @@ impl Project { | ||
| 1924 | 2008 | /// [`write_speed`](Project::write_speed) already makes, in its words); |
| 1925 | 2009 | /// * the region would grow rather than shrink, i.e. it already plays faster |
| 1926 | 2010 | /// than `speed`. |
| 1927 | - pub fn speed_regions(&mut self, regions: &[(u32, u32)], speed: Speed) -> crate::Result<()> { | |
| 2011 | + pub fn speed_regions( | |
| 2012 | + &mut self, | |
| 2013 | + regions: &[(u32, u32)], | |
| 2014 | + speed: Speed, | |
| 2015 | + scope: &[Lane], | |
| 2016 | + ) -> crate::Result<()> { | |
| 1928 | 2017 | let regions = tidy(regions); |
| 1929 | - if regions.is_empty() { | |
| 2018 | + let on = self.scoped(scope)?; | |
| 2019 | + let Some(&(first, _)) = regions.first() else { | |
| 1930 | 2020 | return Err("nothing to speed up".into()); |
| 1931 | - } | |
| 2021 | + }; | |
| 2022 | + self.scope_holds_takes_whole(&on, first)?; | |
| 1932 | 2023 | let labels = handles(&self.lanes); |
| 1933 | 2024 | // Before anything is touched, because this is the refusal a person can |
| 1934 | 2025 | // act on: a clip that laps over the edge of a silence has to be trimmed |
| 1935 | 2026 | // (or the silences cut instead), and saying so after a rollback would |
| 1936 | 2027 | // be saying it about a timeline that already looks different. |
| 1937 | 2028 | for &(at, len) in ®ions { |
| 1938 | - for (l, data) in self.lanes.iter().enumerate() { | |
| 1939 | - for c in &data.clips { | |
| 2029 | + for &l in &on { | |
| 2030 | + for c in &self.lanes[l].clips { | |
| 1940 | 2031 | if c.end() > at && c.start < at + len && !(c.start <= at && c.end() >= at + len) |
| 1941 | 2032 | { |
| 1942 | 2033 | return Err(format!( |
| @@ -1958,12 +2049,13 @@ impl Project { | ||
| 1958 | 2049 | // refusal still costs no step (`undo` pops the one just pushed). |
| 1959 | 2050 | self.snapshot(); |
| 1960 | 2051 | for &(at, len) in regions.iter().rev() { |
| 1961 | - self.write_split(at, false); | |
| 1962 | - self.write_split(at + len, false); | |
| 2052 | + self.write_split(at, false, &on); | |
| 2053 | + self.write_split(at + len, false, &on); | |
| 1963 | 2054 | let mut room: Option<(Lane, u32)> = None; |
| 1964 | 2055 | let mut refused = None; |
| 1965 | - for (l, data) in self.lanes.iter().enumerate() { | |
| 1966 | - for c in data.clips.iter().filter(|c| c.end() > at && c.start < at + len) { | |
| 2056 | + for &l in &on { | |
| 2057 | + let clips = &self.lanes[l].clips; | |
| 2058 | + for c in clips.iter().filter(|c| c.end() > at && c.start < at + len) { | |
| 1967 | 2059 | if (c.start, c.end()) != (at, at + len) { |
| 1968 | 2060 | // *Which* edge did not come off: a rate that cannot |
| 1969 | 2061 | // address the end of the silence is not a rate that |
| @@ -2015,15 +2107,15 @@ impl Project { | ||
| 2015 | 2107 | ) |
| 2016 | 2108 | .into()); |
| 2017 | 2109 | }; |
| 2018 | - for data in &mut self.lanes { | |
| 2019 | - for c in &mut data.clips { | |
| 2110 | + for &l in &on { | |
| 2111 | + for c in &mut self.lanes[l].clips { | |
| 2020 | 2112 | if c.start == at && c.end() == at + len { |
| 2021 | 2113 | c.speed = speed; |
| 2022 | 2114 | } else if c.start >= at + len { |
| 2023 | 2115 | c.start -= delta; |
| 2024 | 2116 | } |
| 2025 | 2117 | } |
| 2026 | - debug_assert!(sorted_disjoint(&data.clips)); | |
| 2118 | + debug_assert!(sorted_disjoint(&self.lanes[l].clips)); | |
| 2027 | 2119 | } |
| 2028 | 2120 | } |
| 2029 | 2121 | debug_assert!(links_are_consistent(&self.lanes).is_ok()); |
| @@ -2466,20 +2558,29 @@ fn clear(clips: &mut Vec<Clip>, start: u32, end: u32) { | ||
| 2466 | 2558 | *clips = out; |
| 2467 | 2559 | } |
| 2468 | 2560 | |
| 2469 | -/// Cuts `[at, at + len)` out of every lane and slides what is behind it back -- | |
| 2470 | -/// the body of [`Project::ripple_delete`], and of every cut a batch | |
| 2471 | -/// ([`Project::cut_regions`]) makes. No snapshot of its own: whose undo step | |
| 2472 | -/// this is belongs to the caller. | |
| 2473 | -fn ripple(lanes: &mut [LaneData], at: u32, len: u32) { | |
| 2474 | - for data in lanes { | |
| 2475 | - clear(&mut data.clips, at, at + len); | |
| 2476 | - for c in data.clips.iter_mut().filter(|c| c.start >= at) { | |
| 2561 | +/// Cuts `[at, at + len)` out of the lanes at indices `on` and slides what is | |
| 2562 | +/// behind it back -- the body of [`Project::ripple_delete`] (which passes every | |
| 2563 | +/// lane) and of every cut a batch ([`Project::cut_regions`]) makes on the lanes | |
| 2564 | +/// it was scoped to. No snapshot of its own: whose undo step this is belongs to | |
| 2565 | +/// the caller. | |
| 2566 | +fn ripple(lanes: &mut [LaneData], on: &[usize], at: u32, len: u32) { | |
| 2567 | + for &i in on { | |
| 2568 | + let clips = &mut lanes[i].clips; | |
| 2569 | + clear(clips, at, at + len); | |
| 2570 | + for c in clips.iter_mut().filter(|c| c.start >= at) { | |
| 2477 | 2571 | c.start -= len; |
| 2478 | 2572 | } |
| 2479 | - debug_assert!(sorted_disjoint(&data.clips)); | |
| 2573 | + debug_assert!(sorted_disjoint(clips)); | |
| 2480 | 2574 | } |
| 2481 | 2575 | } |
| 2482 | 2576 | |
| 2577 | +/// Every lane, as the index list the two above take: what "the whole timeline" | |
| 2578 | +/// is spelled as, and the scope [`Project::ripple_delete`] and | |
| 2579 | +/// [`Project::split`] have always had. | |
| 2580 | +fn all_lanes(lanes: &[LaneData]) -> Vec<usize> { | |
| 2581 | + (0..lanes.len()).collect() | |
| 2582 | +} | |
| 2583 | + | |
| 2483 | 2584 | /// A caller's region list as a batch may use it: sorted by start, empty entries |
| 2484 | 2585 | /// dropped, and touching or overlapping entries merged into one. |
| 2485 | 2586 | /// |
crates/engine/tests/silence.rsmodified+124 -9
| @@ -58,7 +58,8 @@ fn a_batch_of_cuts_is_one_edit_and_moves_every_lane_alike() { | ||
| 58 | 58 | assert!(p.split(60)); |
| 59 | 59 | let before = p.lane(Lane::V1).to_vec(); |
| 60 | 60 | let regions = [(10, 5), (30, 5), (50, 5), (70, 5), (90, 5)]; |
| 61 | - assert!(p.cut_regions(®ions)); | |
| 61 | + p.cut_regions(®ions, &p.lanes().clone()) | |
| 62 | + .expect("every lane is in scope"); | |
| 62 | 63 | |
| 63 | 64 | let cut: u32 = regions.iter().map(|&(_, len)| len).sum(); |
| 64 | 65 | assert_eq!(p.timeline_frames(), was - cut); |
| @@ -85,7 +86,8 @@ fn speeding_silences_up_closes_the_room_they_no_longer_need() { | ||
| 85 | 86 | let mut p = fixture(); |
| 86 | 87 | let was = p.timeline_frames(); |
| 87 | 88 | let regions = [(30, 20), (80, 20)]; |
| 88 | - p.speed_regions(®ions, Speed::MAX).expect("no lane laps"); | |
| 89 | + p.speed_regions(®ions, Speed::MAX, &p.lanes().clone()) | |
| 90 | + .expect("no lane laps"); | |
| 89 | 91 | |
| 90 | 92 | // 20 source frames at 4x occupy 5, so each region gives back 15. |
| 91 | 93 | let shrunk = Speed::MAX.frames(20); |
| @@ -114,7 +116,8 @@ fn speeding_silences_up_closes_the_room_they_no_longer_need() { | ||
| 114 | 116 | // now leaves the timeline byte for byte as it was -- 4x set twice is 4x. |
| 115 | 117 | let settled = p.lane(Lane::V1).to_vec(); |
| 116 | 118 | let again: Vec<(u32, u32)> = fast.iter().map(|&at| (at, shrunk)).collect(); |
| 117 | - p.speed_regions(&again, Speed::MAX).expect("still no lap"); | |
| 119 | + p.speed_regions(&again, Speed::MAX, &p.lanes().clone()) | |
| 120 | + .expect("still no lap"); | |
| 118 | 121 | assert_eq!(p.lane(Lane::V1), settled, "a second pass compounded"); |
| 119 | 122 | |
| 120 | 123 | assert!(p.undo()); |
| @@ -148,7 +151,7 @@ fn speed_mode_refuses_a_clip_that_laps_over_a_silence() { | ||
| 148 | 151 | let before = spans(&p); |
| 149 | 152 | |
| 150 | 153 | let err = p |
| 151 | - .speed_regions(&[(30, 20)], Speed::MAX) | |
| 154 | + .speed_regions(&[(30, 20)], Speed::MAX, &p.lanes().clone()) | |
| 152 | 155 | .expect_err("a half-covered region must not be sped up") |
| 153 | 156 | .to_string(); |
| 154 | 157 | assert!(err.contains("V2"), "{err}"); |
| @@ -161,10 +164,117 @@ fn speed_mode_refuses_a_clip_that_laps_over_a_silence() { | ||
| 161 | 164 | |
| 162 | 165 | // The same regions cut instead: a ripple is uniform, so nothing laps. |
| 163 | 166 | assert!(p.place(lane, 40, broll)); |
| 164 | - assert!(p.cut_regions(&[(30, 20)])); | |
| 167 | + p.cut_regions(&[(30, 20)], &p.lanes().clone()) | |
| 168 | + .expect("a ripple is uniform"); | |
| 165 | 169 | loadable(&p); |
| 166 | 170 | } |
| 167 | 171 | |
| 172 | +/// A clip covering the whole fixture, for a second track to carry. | |
| 173 | +fn whole(source: usize, frames: u32) -> Clip { | |
| 174 | + Clip { | |
| 175 | + start: 0, | |
| 176 | + in_frame: 0, | |
| 177 | + out_frame: frames, | |
| 178 | + source, | |
| 179 | + link: None, | |
| 180 | + eq: None, | |
| 181 | + color: None, | |
| 182 | + fit: Default::default(), | |
| 183 | + speed: Speed::NORMAL, | |
| 184 | + } | |
| 185 | +} | |
| 186 | + | |
| 187 | +/// The scope is the point: cutting a take's silences must not drag the music | |
| 188 | +/// track under it back. The lanes that were named lose exactly what was cut; | |
| 189 | +/// the lane that was not is byte for byte what it was, and one press still | |
| 190 | +/// takes the whole batch back. | |
| 191 | +#[test] | |
| 192 | +fn a_scoped_cut_leaves_the_track_it_was_not_given_alone() { | |
| 193 | + let mut p = fixture(); | |
| 194 | + let frames = p.timeline_frames(); | |
| 195 | + let music = p.add_lane(LaneKind::Audio); | |
| 196 | + assert_eq!(music.label(), "A2"); | |
| 197 | + assert!(p.place(music, 0, whole(0, frames))); | |
| 198 | + let untouched = p.lane(music).to_vec(); | |
| 199 | + | |
| 200 | + // The take's own two lanes, and not the third. | |
| 201 | + let take = [Lane::V1, Lane::A1]; | |
| 202 | + let regions = [(10, 5), (30, 5)]; | |
| 203 | + p.cut_regions(®ions, &take) | |
| 204 | + .expect("the take is whole inside the scope"); | |
| 205 | + | |
| 206 | + assert_eq!(p.lane(music), untouched, "the music track moved"); | |
| 207 | + let cut: u32 = regions.iter().map(|&(_, len)| len).sum(); | |
| 208 | + for lane in take { | |
| 209 | + assert_eq!( | |
| 210 | + p.lane(lane).last().expect("clips").end(), | |
| 211 | + frames - cut, | |
| 212 | + "{} did not lose what was cut", | |
| 213 | + lane.label() | |
| 214 | + ); | |
| 215 | + } | |
| 216 | + // The timeline is as long as its longest lane, which is now the music. | |
| 217 | + assert_eq!(p.timeline_frames(), frames); | |
| 218 | + loadable(&p); | |
| 219 | + | |
| 220 | + assert!(p.undo()); | |
| 221 | + assert_eq!(p.lane(Lane::V1).last().expect("clips").end(), frames); | |
| 222 | + assert_eq!(p.lane(Lane::V1).len(), 1, "one press took the whole batch"); | |
| 223 | +} | |
| 224 | + | |
| 225 | +/// One track of a take is refused **by name**, in both modes: moving the sound | |
| 226 | +/// of a shot and not its picture leaves a group whose halves disagree about | |
| 227 | +/// their span -- a project no save could load. The refusal says which two clips | |
| 228 | +/// and what to do, and detaching them is exactly what makes the same call work. | |
| 229 | +#[test] | |
| 230 | +fn one_track_of_a_take_is_refused_by_name_until_it_is_detached() { | |
| 231 | + let mut p = fixture(); | |
| 232 | + let before = spans(&p); | |
| 233 | + let err = p | |
| 234 | + .cut_regions(&[(10, 5)], &[Lane::A1]) | |
| 235 | + .expect_err("half a take must not be cut alone") | |
| 236 | + .to_string(); | |
| 237 | + assert!(err.contains("A1") && err.contains("V1"), "{err}"); | |
| 238 | + assert!(err.contains("detach"), "{err}"); | |
| 239 | + // Speed mode lives under the same law and says the same thing. | |
| 240 | + let same = p | |
| 241 | + .speed_regions(&[(30, 20)], Speed::MAX, &[Lane::A1]) | |
| 242 | + .expect_err("half a take must not be re-rated alone") | |
| 243 | + .to_string(); | |
| 244 | + assert!(same.contains("A1") && same.contains("V1"), "{same}"); | |
| 245 | + assert_eq!(spans(&p), before, "a refusal changed the timeline"); | |
| 246 | + assert!(!p.undo(), "a refusal cost an undo step"); | |
| 247 | + | |
| 248 | + // Detached, the sound is its own to cut -- and the picture stays put. | |
| 249 | + assert!(p.ungroup(Lane::A1, 0)); | |
| 250 | + let picture = p.lane(Lane::V1).to_vec(); | |
| 251 | + p.cut_regions(&[(10, 5)], &[Lane::A1]) | |
| 252 | + .expect("a detached half is one track"); | |
| 253 | + assert_eq!(p.lane(Lane::V1), picture, "the picture followed anyway"); | |
| 254 | + assert_eq!(p.lane(Lane::A1).last().expect("clips").end(), 145); | |
| 255 | + loadable(&p); | |
| 256 | +} | |
| 257 | + | |
| 258 | +/// Scoping every lane is the ripple this always was: the same cuts through the | |
| 259 | +/// batch and through `ripple_delete` one at a time land on the same timeline. | |
| 260 | +#[test] | |
| 261 | +fn every_lane_in_scope_is_the_ripple_it_always_was() { | |
| 262 | + let regions = [(10, 5), (30, 5), (50, 5)]; | |
| 263 | + let mut batch = fixture(); | |
| 264 | + let all = batch.lanes(); | |
| 265 | + batch.cut_regions(®ions, &all).expect("every lane"); | |
| 266 | + | |
| 267 | + let mut one_at_a_time = fixture(); | |
| 268 | + for &(at, len) in regions.iter().rev() { | |
| 269 | + assert!(one_at_a_time.ripple_delete(at, len)); | |
| 270 | + } | |
| 271 | + assert_eq!(batch.lane(Lane::V1), one_at_a_time.lane(Lane::V1)); | |
| 272 | + assert_eq!(batch.lane(Lane::A1), one_at_a_time.lane(Lane::A1)); | |
| 273 | + // ...at one undo step against three. | |
| 274 | + assert!(batch.undo()); | |
| 275 | + assert!(!batch.undo()); | |
| 276 | +} | |
| 277 | + | |
| 168 | 278 | /// A rate that cannot address an edge of a silence is refused naming **that** |
| 169 | 279 | /// edge -- not the region's start, which at a slow rate is often the one frame |
| 170 | 280 | /// that *was* addressable. A cut at the wrong frame is a user sent to look in |
| @@ -175,16 +285,20 @@ fn speed_mode_refuses_a_clip_that_laps_over_a_silence() { | ||
| 175 | 285 | #[test] |
| 176 | 286 | fn an_unaddressable_edge_is_named_where_it_actually_is() { |
| 177 | 287 | let mut p = fixture(); |
| 178 | - p.set_speed(Lane::V1, 0, Speed::MIN).expect("nothing after it"); | |
| 288 | + p.set_speed(Lane::V1, 0, Speed::MIN) | |
| 289 | + .expect("nothing after it"); | |
| 179 | 290 | let before = spans(&p); |
| 180 | 291 | // Starts where the clip starts -- no split needed there -- and ends at a |
| 181 | 292 | // frame a quarter-speed clip cannot be cut at. |
| 182 | 293 | let err = p |
| 183 | - .speed_regions(&[(0, 5)], Speed::MAX) | |
| 294 | + .speed_regions(&[(0, 5)], Speed::MAX, &p.lanes().clone()) | |
| 184 | 295 | .expect_err("frame 5 is not a cut this rate can make") |
| 185 | 296 | .to_string(); |
| 186 | 297 | assert!(err.contains("frame 5"), "{err}"); |
| 187 | - assert!(!err.contains("frame 0:"), "it named the region's start: {err}"); | |
| 298 | + assert!( | |
| 299 | + !err.contains("frame 0:"), | |
| 300 | + "it named the region's start: {err}" | |
| 301 | + ); | |
| 188 | 302 | // Rolled back whole, and the refusal cost no undo step: the press below is |
| 189 | 303 | // the `set_speed` above. |
| 190 | 304 | assert_eq!(spans(&p), before); |
| @@ -233,7 +347,8 @@ fn scanning_a_clip_and_cutting_what_it_finds() { | ||
| 233 | 347 | assert!(!p.undo(), "the scan took an undo step"); |
| 234 | 348 | |
| 235 | 349 | let cut: u32 = regions.iter().map(|&(_, len)| len).sum(); |
| 236 | - assert!(p.cut_regions(®ions)); | |
| 350 | + p.cut_regions(®ions, &p.lanes().clone()) | |
| 351 | + .expect("every lane is in scope"); | |
| 237 | 352 | assert_eq!(p.timeline_frames(), was - cut); |
| 238 | 353 | let (video, audio_spans) = spans(&p); |
| 239 | 354 | assert_eq!(video, audio_spans); |