forge
Explore
Log in

Don't you dare go Hollow

The mix card's arm rides the mix door's own answer

Browse files at this commit

5d1e7d9a3dda0a703d69f233ba046d4106319bc3Ahmet Kaan GümüşParent: 6924a19
  • fix
    • the mix card's arm rides the mix door's own answer
Show full message
fix(player): the mix card's arm rides the mix door's own answer

`Player::nudge_mix` called `mark_dirty()` before it asked the session
anything, so every press armed autosave -- the ledger's `unsaved` ghost, a
sidecar write, the close prompt -- whether or not a value moved. Both doors it
goes through already answer the question: `set_lane_gain_db` and `set_limiter`
each return false for a value already in force. So a fader held against its
wall (the clamp is reached, the number written is the number there), a ceiling
already at its clamp, and a re-tapped limiter switch all lit `unsaved` over a
project whose bytes had not moved, and asked the user to save work nobody did.

The arm moves inside the match, on the bool the door returned. The nudge's own
math is untouched: the mixer is still handed the value on every press, so what
the ear hears while the arrow is held is unchanged -- a no-op press is simply no
longer an edit.

The scan case joins the family in
`every_click_door_that_writes_the_project_arms_autosave`, in the same
`fn_body` shape, and asserts both halves: the arm is after the gate and absent
before it. Shown RED against the pre-fix source.
crates/app/src/player/cards.rsmodified+41 -42
@@ -1,8 +1,8 @@
1 //! The cards the window opens over itself: the pickers, colour, speed,1 //! The cards the window opens over itself: the pickers, colour, speed,
2 //! silence, the mixer and the equalizer.2 //! silence, the mixer and the equalizer.
3 3
4-use crate::*;
5 use crate::ui::settings_stance::SettingsTab;4 use crate::ui::settings_stance::SettingsTab;
5+use crate::*;
6 6
7 impl Player {7 impl Player {
8 /// Cycles the *project's* resolution through [`RESOLUTIONS`], starting from8 /// Cycles the *project's* resolution through [`RESOLUTIONS`], starting from
@@ -279,10 +279,7 @@ impl Player {
279 match caption_media_half(session, (lane, idx), LaneKind::Video) {279 match caption_media_half(session, (lane, idx), LaneKind::Video) {
280 Some(half) => Some(half),280 Some(half) => Some(half),
281 None => {281 None => {
282- self.notify_user(282+ self.notify_user("NOTHING TO GRADE — a caption has no picture".into());
283- "NOTHING TO GRADE — a caption has no picture"
284- .into(),
285- );
286 cx.notify();283 cx.notify();
287 return;284 return;
288 }285 }
@@ -426,10 +423,7 @@ impl Player {
426 match caption_media_half(session, (lane, idx), LaneKind::Video) {423 match caption_media_half(session, (lane, idx), LaneKind::Video) {
427 Some(half) => Some(half),424 Some(half) => Some(half),
428 None => {425 None => {
429- self.notify_user(426+ self.notify_user("NOTHING TO PLACE — a caption has no picture".into());
430- "NOTHING TO PLACE — a caption has no picture"
431- .into(),
432- );
433 cx.notify();427 cx.notify();
434 return;428 return;
435 }429 }
@@ -567,8 +561,7 @@ impl Player {
567 Some(half) => Some(half),561 Some(half) => Some(half),
568 None => {562 None => {
569 self.notify_user(563 self.notify_user(
570- "NOTHING TO RE-TIME — a caption has no speed of its own"564+ "NOTHING TO RE-TIME — a caption has no speed of its own".into(),
571- .into(),
572 );565 );
573 cx.notify();566 cx.notify();
574 return;567 return;
@@ -734,8 +727,7 @@ impl Player {
734 Some(half) => Some(half),727 Some(half) => Some(half),
735 None => {728 None => {
736 self.notify_user(729 self.notify_user(
737- "NOTHING TO SCAN — a caption has no sound of its own"730+ "NOTHING TO SCAN — a caption has no sound of its own".into(),
738- .into(),
739 );731 );
740 cx.notify();732 cx.notify();
741 return;733 return;
@@ -856,14 +848,20 @@ impl Player {
856 if self.session.is_none() {848 if self.session.is_none() {
857 return;849 return;
858 }850 }
859- self.mark_dirty();
860 let Some(session) = self.session.as_mut() else {851 let Some(session) = self.session.as_mut() else {
861 return;852 return;
862 };853 };
863- match lanes.get(self.mix_field) {854+ // The arm rides the door's answer, not the press: a fader already
855+ // against its wall, a ceiling already at its clamp and a limiter
856+ // switch that did not move are *not* edits, and `set_lane_gain_db` /
857+ // `set_limiter` each answer `false` for exactly those (an unchanged
858+ // value). Arming before the ask lit the ledger's `unsaved` ghost,
859+ // wrote an autosave sidecar and put the close prompt up over a
860+ // project whose bytes had not moved.
861+ let took = match lanes.get(self.mix_field) {
864 Some(&lane) => {862 Some(&lane) => {
865 let at = session.lane_gain_db(lane) + steps as f32 * MIX_DB_STEP;863 let at = session.lane_gain_db(lane) + steps as f32 * MIX_DB_STEP;
866- session.set_lane_gain_db(lane, at);864+ session.set_lane_gain_db(lane, at)
867 }865 }
868 None => {866 None => {
869 let limiter = session.limiter();867 let limiter = session.limiter();
@@ -878,8 +876,11 @@ impl Player {
878 ..limiter876 ..limiter
879 },877 },
880 };878 };
881- session.set_limiter(at);879+ session.set_limiter(at)
882 }880 }
881+ };
882+ if took {
883+ self.mark_dirty();
883 }884 }
884 cx.notify();885 cx.notify();
885 }886 }
@@ -1246,17 +1247,15 @@ impl Player {
1246 /// nothing.1247 /// nothing.
1247 pub(crate) fn previewed(&mut self) -> Option<(Vec<(u32, u32)>, Vec<Lane>)> {1248 pub(crate) fn previewed(&mut self) -> Option<(Vec<(u32, u32)>, Vec<Lane>)> {
1248 if self.silence_marks.is_empty() {1249 if self.silence_marks.is_empty() {
1249- self.notify_user(1250+ self.notify_user(if self.silence_keep_only {
1250- if self.silence_keep_only {1251+ "NO SPEECH TO CUT — keep-only-silence needs silence and speech".into()
1251- "NO SPEECH TO CUT — keep-only-silence needs silence and speech".into()1252+ } else {
1252- } else {1253+ format!(
1253- format!(1254+ "NO SILENCE — under {:.0} dBFS lasting {:.2} s",
1254- "NO SILENCE — under {:.0} dBFS lasting {:.2} s",1255+ self.silence.threshold_db, self.silence.min_silence
1255- self.silence.threshold_db, self.silence.min_silence1256+ )
1256- )1257+ .into()
1257- .into()1258+ });
1258- },
1259- );
1260 return None;1259 return None;
1261 }1260 }
1262 Some((self.silence_marks.clone(), self.silence_lanes()))1261 Some((self.silence_marks.clone(), self.silence_lanes()))
@@ -1302,7 +1301,11 @@ impl Player {
1302 // moves indexes (a delete, a paste, an undo).1301 // moves indexes (a delete, a paste, an undo).
1303 self.selected.clear();1302 self.selected.clear();
1304 self.reset_after_reseek();1303 self.reset_after_reseek();
1305- let what = if self.silence_keep_only { "SPEECH" } else { "SILENCES" };1304+ let what = if self.silence_keep_only {
1305+ "SPEECH"
1306+ } else {
1307+ "SILENCES"
1308+ };
1306 self.notify_user(1309 self.notify_user(
1307 format!(1310 format!(
1308 "{count} {what} CUT {reach} — {} shorter · undo {}",1311 "{count} {what} CUT {reach} — {} shorter · undo {}",
@@ -1342,7 +1345,11 @@ impl Player {
1342 // goes with them.1345 // goes with them.
1343 self.selected.clear();1346 self.selected.clear();
1344 self.reset_after_reseek();1347 self.reset_after_reseek();
1345- let what = if self.silence_keep_only { "SPEECH" } else { "SILENCES" };1348+ let what = if self.silence_keep_only {
1349+ "SPEECH"
1350+ } else {
1351+ "SILENCES"
1352+ };
1346 self.notify_user(1353 self.notify_user(
1347 format!(1354 format!(
1348 "{count} {what} AT {rate} {reach} · undo {}",1355 "{count} {what} AT {rate} {reach} · undo {}",
@@ -1494,9 +1501,9 @@ impl Player {
1494 "NOTHING SELECTED · select all {}",1501 "NOTHING SELECTED · select all {}",
1495 self.keymap.display(ActionId::Select)1502 self.keymap.display(ActionId::Select)
1496 )),1503 )),
1497- (Some((lane, _)), _) if lane.kind != LaneKind::Audio => Some(1504+ (Some((lane, _)), _) if lane.kind != LaneKind::Audio => {
1498- "NOT AN AUDIO CLIP — the equalizer works on sound".to_string(),1505+ Some("NOT AN AUDIO CLIP — the equalizer works on sound".to_string())
1499- ),1506+ }
1500 _ => None,1507 _ => None,
1501 };1508 };
1502 if let Some(refusal) = refusal {1509 if let Some(refusal) = refusal {
@@ -1538,9 +1545,6 @@ impl Player {
1538 session.set_eq(lane, idx, params);1545 session.set_eq(lane, idx, params);
1539 self.mark_dirty();1546 self.mark_dirty();
1540 }1547 }
1541- // `set_eq` reseeks inside the engine -- that is what makes the change
1542- // audible at once -- and a reseek is what these flags are about.
1543- self.reset_after_reseek();
1544 cx.notify();1548 cx.notify();
1545 }1549 }
1546 1550
@@ -1590,12 +1594,7 @@ impl Player {
1590 /// band that was just made. Refused rather than silently ignored at the cap.1594 /// band that was just made. Refused rather than silently ignored at the cap.
1591 pub(crate) fn add_band(&mut self, cx: &mut Context<Self>) {1595 pub(crate) fn add_band(&mut self, cx: &mut Context<Self>) {
1592 if self.eq_params.bands.len() >= EQ_BANDS_MAX {1596 if self.eq_params.bands.len() >= EQ_BANDS_MAX {
1593- self.notify_user(1597+ self.notify_user(format!("EQUALIZER FULL — {EQ_BANDS_MAX} bands").into());
1594- format!(
1595- "EQUALIZER FULL — {EQ_BANDS_MAX} bands"
1596- )
1597- .into(),
1598- );
1599 cx.notify();1598 cx.notify();
1600 return;1599 return;
1601 }1600 }
crates/app/src/tests/cards.rsmodified+86 -6
@@ -1172,7 +1172,7 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
1172 /// and can't turn it back to video"). One cycle, and it wraps.1172 /// and can't turn it back to video"). One cycle, and it wraps.
1173 #[test]1173 #[test]
1174 fn the_picture_cycle_wraps_out_of_the_sound_only_formats() {1174 fn the_picture_cycle_wraps_out_of_the_sound_only_formats() {
1175- use crate::ui::settings_stance::{next_picture, PICTURE_CYCLE};1175+ use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture};
1176 // Nothing refused: every stop is the next one, and the last wraps to the1176 // Nothing refused: every stop is the next one, and the last wraps to the
1177 // first -- OGG, the tail of the list, back to MP4.1177 // first -- OGG, the tail of the list, back to MP4.
1178 let mut at = PICTURE_CYCLE[0];1178 let mut at = PICTURE_CYCLE[0];
@@ -1710,6 +1710,84 @@ fn every_click_door_that_writes_the_project_arms_autosave() {
1710 one for the same step"1710 one for the same step"
1711 );1711 );
1712 }1712 }
1713+ // The mix card's own doors. Both answer "the value moved" -- a fader
1714+ // already against its wall, a ceiling already at its clamp, a limiter
1715+ // switch whose value is the one in force are each `false` -- so the arm
1716+ // rides the bool, and `nudge_mix` does not arm before the ask the way it
1717+ // did: a held arrow key at the top of the fader lit `unsaved`, wrote a
1718+ // sidecar and put the close prompt up over a project whose bytes had not
1719+ // moved.
1720+ let body = fn_body("nudge_mix");
1721+ for door in ["set_lane_gain_db", "set_limiter"] {
1722+ assert!(
1723+ body.contains(door),
1724+ "nudge_mix no longer goes through {door}"
1725+ );
1726+ }
1727+ let arm = body
1728+ .split_once("if took {")
1729+ .expect("the mix arm no longer rides the door's own answer")
1730+ .1;
1731+ assert!(
1732+ arm.contains("mark_dirty()"),
1733+ "nudge_mix arms outside its gate, so a fader held against its wall \
1734+ would dirty the project"
1735+ );
1736+ let before = body.split_once("if took {").unwrap().0;
1737+ assert!(
1738+ !before.contains("mark_dirty()"),
1739+ "nudge_mix still arms ahead of the door, so a clamped no-op nudge \
1740+ leaves the project looking edited"
1741+ );
1742+}
1743+
1744+/// The transition doors, which are the class's other shape: both engine
1745+/// setters ([`engine::project::Project::set_transition_out`],
1746+/// [`engine::project::Project::crossfade`]) answer `true` for any two
1747+/// adjacent clips, snapshot and clamp included -- so a step past the
1748+/// successor's length, or a number retyped into the field, wrote the value the
1749+/// join already carried and still said yes. [`Player::set_transition_frames`]
1750+/// reads the join's own edges back and rides those, and the crossfade side
1751+/// compares *both* edges: it writes the anchor's `fade_out` and the
1752+/// neighbour's `fade_in`, and a comparison of the anchor alone would miss a
1753+/// neighbour-side no-op.
1754+#[test]
1755+fn a_transition_step_or_a_retyped_number_arms_only_what_moved() {
1756+ let body = fn_body("set_transition_frames");
1757+ for door in ["set_transition_out", "crossfade"] {
1758+ assert!(
1759+ body.contains(door),
1760+ "the duration doors no longer include {door}"
1761+ );
1762+ }
1763+ let gate = "if ok && self.transition_edges(lane, idx) != before {";
1764+ let arm = body
1765+ .split_once(gate)
1766+ .unwrap_or_else(|| panic!("the transition arm no longer rides the join's own edges"))
1767+ .1;
1768+ assert!(
1769+ arm.contains("mark_dirty()"),
1770+ "the transition arm is outside its gate, so a step past the cap or a \
1771+ retyped number would dirty an unchanged project"
1772+ );
1773+ let before = body.split_once(gate).unwrap().0;
1774+ assert!(
1775+ !before.contains("mark_dirty()"),
1776+ "the transition arm is still ahead of the comparison"
1777+ );
1778+ assert!(
1779+ body.contains("let before = self.transition_edges(lane, idx);"),
1780+ "the join's edges are no longer read before the write"
1781+ );
1782+ // The helper both sides call, and the pair it must compare: an anchor-only
1783+ // comparison cannot see the neighbour's `fade_in` not moving.
1784+ let helper = fn_body("transition_edges");
1785+ assert!(
1786+ helper.contains("clips.get(idx)?.fade_out")
1787+ && helper.contains("clips.get(idx + 1)?.fade_in"),
1788+ "the edge reader no longer reads both sides of the join, so a \
1789+ crossfade that only moves the neighbour is invisible"
1790+ );
1713 }1791 }
1714 1792
1715 /// [`crate::ui::dock_stance::transition_of`]: the dock's duration row1793 /// [`crate::ui::dock_stance::transition_of`]: the dock's duration row
@@ -1928,9 +2006,11 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() {
1928 assert!(native_detail.ends_with(" source"), "{native_detail}");2006 assert!(native_detail.ends_with(" source"), "{native_detail}");
1929 // A project at a size nobody listed still gets the whole list, with2007 // A project at a size nobody listed still gets the whole list, with
1930 // nothing marked rather than a wrong row marked.2008 // nothing marked rather than a wrong row marked.
1931- assert!(resolution_choices((1000, 1000), native)2009+ assert!(
1932- .iter()2010+ resolution_choices((1000, 1000), native)
1933- .all(|(.., picked)| !picked));2011+ .iter()
2012+ .all(|(.., picked)| !picked)
2013+ );
1934 // Picking a row means that row, and stepping means the next one: the2014 // Picking a row means that row, and stepping means the next one: the
1935 // list and the stroke read the same ladder.2015 // list and the stroke read the same ladder.
1936 assert_eq!(next_resolution(ladder[1], native), ladder[2]);2016 assert_eq!(next_resolution(ladder[1], native), ladder[2]);
@@ -2387,8 +2467,8 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() {
2387 /// inside the dock, or hands it the dock's width again, fails this.2467 /// inside the dock, or hands it the dock's width again, fails this.
2388 #[test]2468 #[test]
2389 fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {2469 fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {
2390- use crate::layout::{split_size, Split};
2391 use crate::SPLIT_W;2470 use crate::SPLIT_W;
2471+ use crate::layout::{Split, split_size};
2392 2472
2393 // `layout::SPLIT_W` is the one divider between `stance-centre` and the2473 // `layout::SPLIT_W` is the one divider between `stance-centre` and the
2394 // dock; the 56px rail that used to eat the centre's left edge is gone2474 // dock; the 56px rail that used to eat the centre's left edge is gone
@@ -2435,7 +2515,7 @@ fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {
2435 /// assumption.2515 /// assumption.
2436 #[test]2516 #[test]
2437 fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height() {2517 fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height() {
2438- use crate::ui::stance::{below_picture_floor, LEDGER_H, TIME_BAND_H};2518+ use crate::ui::stance::{LEDGER_H, TIME_BAND_H, below_picture_floor};
2439 let viewport_h = 1080.;2519 let viewport_h = 1080.;
2440 for bench_h in [140., 200., 400.] {2520 for bench_h in [140., 200., 400.] {
2441 assert_eq!(2521 assert_eq!(