forge
Explore
Log in

Don't you dare go Hollow

Waveform styles, any soundtrack, keys search, group on the clip menu

Browse files at this commit

dfcec06d567bf4a7972504046b8979074fd557a5Ahmet Kaan GümüşParent: 735b90e
  • feat
    • waveform styles, any soundtrack, keys search, group on the clip menu
Show full message
✨ feat(audio): waveform styles, any soundtrack, keys search, group on the clip menu

Visualizer is no longer wav-only: h on a video clip with sound paints
that file's soundtrack. Style bits live on the clip (outline, smooth,
fast, colour) and toggle from CLIP. `?` type-to-filters the keys list.
Group / Ungroup / Regroup are clip-menu rows, not chords-only.
crates/app/src/main.rsmodified+6 -0
@@ -220,6 +220,11 @@ struct Player {
220 /// focused, and does nothing to the keymap once it is not.220 /// focused, and does nothing to the keymap once it is not.
221 pub(crate) dock_filter: String,221 pub(crate) dock_filter: String,
222 pub(crate) dock_filter_edit: bool,222 pub(crate) dock_filter_edit: bool,
223+ /// Type-to-filter on the KEYS tab. Owned the same way the Sources filter
224+ /// is, except KEYS captures letters the moment the tab is showing -- the
225+ /// list is a lookup, and a letter that still fired a spine action while
226+ /// it was up is why search felt missing.
227+ pub(crate) keys_filter: String,
223 /// Which of the four sort chips is showing (MOCK-SPEC "Dock" §3).228 /// Which of the four sort chips is showing (MOCK-SPEC "Dock" §3).
224 /// What is known about each source's audio, taken once and kept. Keyed on229 /// What is known about each source's audio, taken once and kept. Keyed on
225 /// the path *and stream* -- two streams of one file are two envelopes -- and230 /// the path *and stream* -- two streams of one file are two envelopes -- and
@@ -961,6 +966,7 @@ fn main() {
961 dock_src_active: ui::dock_stance::load(),966 dock_src_active: ui::dock_stance::load(),
962 dock_filter: String::new(),967 dock_filter: String::new(),
963 dock_filter_edit: false,968 dock_filter_edit: false,
969+ keys_filter: String::new(),
964 waves: HashMap::new(),970 waves: HashMap::new(),
965 thumbs: HashMap::new(),971 thumbs: HashMap::new(),
966 proxies: HashMap::new(),972 proxies: HashMap::new(),
crates/app/src/menus.rsmodified+57 -7
@@ -211,7 +211,7 @@ impl RowItem {
211 /// action a stroke already reaches -- the menu is a second way *to* the actions211 /// action a stroke already reaches -- the menu is a second way *to* the actions
212 /// and never a second version of them -- so both the label and the hint come212 /// and never a second version of them -- so both the label and the hint come
213 /// out of the keymap registry and the two can never disagree.213 /// out of the keymap registry and the two can never disagree.
214-pub(crate) const MENU_ITEMS: [ActionId; 17] = [214+pub(crate) const MENU_ITEMS: [ActionId; 20] = [
215 ActionId::Cut,215 ActionId::Cut,
216 // The cut machinery (DESIGN.md §6) on the very clip it is about: the216 // The cut machinery (DESIGN.md §6) on the very clip it is about: the
217 // trims and the loop-trim were strokes the spine rail listed and nothing217 // trims and the loop-trim were strokes the spine rail listed and nothing
@@ -242,18 +242,20 @@ pub(crate) const MENU_ITEMS: [ActionId; 17] = [
242 ActionId::Visualizer,242 ActionId::Visualizer,
243 ActionId::Speed,243 ActionId::Speed,
244 ActionId::Fit,244 ActionId::Fit,
245+ // The group trio used to live only on chords + ctrl-click. A right-click
246+ // that cannot group is a missing pointer door (the same class Fit and
247+ // Redo shipped as). Dimmed in place when the selection cannot.
248+ ActionId::Group,
249+ ActionId::Detach,
250+ ActionId::Regroup,
245 // Last, under the rule line the render draws before the first of them251 // Last, under the rule line the render draws before the first of them
246 // (DESIGN §9): the two that take the clip off the lane.252 // (DESIGN §9): the two that take the clip off the lane.
247 ActionId::Delete,253 ActionId::Delete,
248 ActionId::Lift,254 ActionId::Lift,
249 ];255 ];
250 256
251-// Not rows, and deliberately: the group trio (`Group`, `Detach`, `Regroup`)257+// Mute stays off this list: it is the mix's, which the transport already
252-// is the ctrl-click grammar plus its chords -- a group is made by picking the258+// carries a button for.
253-// halves and taking it apart the same way -- and the mute is the *mix's*,
254-// which the transport already carries a button for. A clip menu is what this
255-// clip can be told (DESIGN §9, "Never a junk drawer"); those are told to the
256-// selection and to the project.
257 259
258 /// What a right-click on the bench itself offers -- the ruler and the empty260 /// What a right-click on the bench itself offers -- the ruler and the empty
259 /// stretch under the lanes. The verbs of the *timeline*: walking its cuts at261 /// stretch under the lanes. The verbs of the *timeline*: walking its cuts at
@@ -319,6 +321,7 @@ pub(crate) fn destructive(action: ActionId) -> bool {
319 /// A list rather than a loop inside the render, so the card and321 /// A list rather than a loop inside the render, so the card and
320 /// `every_action_is_on_the_actions_card` read the *same* order: an action that322 /// `every_action_is_on_the_actions_card` read the *same* order: an action that
321 /// reaches no row fails a test instead of quietly becoming pointer-unreachable.323 /// reaches no row fails a test instead of quietly becoming pointer-unreachable.
324+#[derive(Clone, Copy, Debug)]
322 pub(crate) enum KeyRow {325 pub(crate) enum KeyRow {
323 Head(keymap::Category),326 Head(keymap::Category),
324 /// Click its label to do it, click its stroke to change that stroke.327 /// Click its label to do it, click its stroke to change that stroke.
@@ -353,6 +356,53 @@ pub(crate) fn keys_rows() -> Vec<KeyRow> {
353 rows356 rows
354 }357 }
355 358
359+/// The KEYS tab's type-to-filter: keep a heading only when one of its rows
360+/// still matches, match a row on its label or its chord.
361+pub(crate) fn keys_rows_matching(query: &str, keymap: &keymap::Keymap) -> Vec<KeyRow> {
362+ let q = query.trim().to_ascii_lowercase();
363+ if q.is_empty() {
364+ return keys_rows();
365+ }
366+ let rows = keys_rows();
367+ let mut out = Vec::new();
368+ let mut i = 0;
369+ while i < rows.len() {
370+ match rows[i] {
371+ KeyRow::Head(cat) => {
372+ let mut kids = Vec::new();
373+ i += 1;
374+ while i < rows.len() && !matches!(rows[i], KeyRow::Head(_)) {
375+ if key_row_hits(&rows[i], &q, keymap) {
376+ kids.push(rows[i]);
377+ }
378+ i += 1;
379+ }
380+ if !kids.is_empty() {
381+ out.push(KeyRow::Head(cat));
382+ out.extend(kids);
383+ }
384+ }
385+ _ => i += 1,
386+ }
387+ }
388+ out
389+}
390+
391+fn key_row_hits(row: &KeyRow, q: &str, keymap: &keymap::Keymap) -> bool {
392+ match *row {
393+ KeyRow::Head(c) => c.label().to_ascii_lowercase().contains(q),
394+ KeyRow::Act(a) => {
395+ a.label().to_ascii_lowercase().contains(q)
396+ || keymap.display(a).to_ascii_lowercase().contains(q)
397+ }
398+ KeyRow::Fixed(i) => {
399+ let f = &keymap::FIXED[i];
400+ f.label.to_ascii_lowercase().contains(q)
401+ || f.chord.to_ascii_lowercase().contains(q)
402+ }
403+ }
404+}
405+
356 /// The character a stroke types into the actions card's search box, if it types406 /// The character a stroke types into the actions card's search box, if it types
357 /// one. gpui reports a printable key as itself and the space bar by name407 /// one. gpui reports a printable key as itself and the space bar by name
358 /// (platform.rs:866), and everything else -- the arrows, the function keys --408 /// (platform.rs:866), and everything else -- the arrows, the function keys --
crates/app/src/oracle.rsmodified+2 -3
@@ -240,9 +240,8 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
240 ActionId::Visualizer if ctx.image => Enable::Hidden("this clip is a still"),240 ActionId::Visualizer if ctx.image => Enable::Hidden("this clip is a still"),
241 ActionId::Visualizer if ctx.no_sound => Enable::Hidden("this clip has no sound"),241 ActionId::Visualizer if ctx.no_sound => Enable::Hidden("this clip has no sound"),
242 ActionId::Visualizer => match ctx.clip {242 ActionId::Visualizer => match ctx.clip {
243- Some((_, lane)) if lane.kind == LaneKind::Audio => Enable::Yes,243+ Some(_) => Enable::Yes,
244- Some(_) => Enable::Hidden("this clip is picture"),244+ None => Enable::No("select a clip with sound"),
245- None => Enable::No("select an audio clip"),
246 },245 },
247 ActionId::Silence | ActionId::Mix if ctx.no_sound => {246 ActionId::Silence | ActionId::Mix if ctx.no_sound => {
248 Enable::Hidden("this clip has no sound")247 Enable::Hidden("this clip has no sound")
crates/app/src/player/cards.rsmodified+1 -0
@@ -1372,6 +1372,7 @@ impl Player {
1372 /// "the" card and closing all of them are the same act.1372 /// "the" card and closing all of them are the same act.
1373 pub(crate) fn close_card(&mut self) {1373 pub(crate) fn close_card(&mut self) {
1374 self.keys_open = false;1374 self.keys_open = false;
1375+ self.keys_filter.clear();
1375 self.settings_open = false;1376 self.settings_open = false;
1376 self.export_open = false;1377 self.export_open = false;
1377 // The two things typed *into* the export moment go with it: a field1378 // The two things typed *into* the export moment go with it: a field
crates/app/src/player/library.rsmodified+21 -12
@@ -140,7 +140,7 @@ impl Player {
140 return;140 return;
141 }141 }
142 let Some((lane, idx)) = self.selected.anchor() else {142 let Some((lane, idx)) = self.selected.anchor() else {
143- self.notify_user("NO VISUALIZER — select an audio clip".into());143+ self.notify_user("NO VISUALIZER — select a clip with sound".into());
144 cx.notify();144 cx.notify();
145 return;145 return;
146 };146 };
@@ -151,13 +151,8 @@ impl Player {
151 return;151 return;
152 }152 }
153 Some(session) => {153 Some(session) => {
154- if lane.kind != LaneKind::Audio {
155- self.notify_user("NO VISUALIZER — select an audio clip".into());
156- cx.notify();
157- return;
158- }
159 let Some(clip) = session.lane_clips(lane).get(idx).copied() else {154 let Some(clip) = session.lane_clips(lane).get(idx).copied() else {
160- self.notify_user("NO VISUALIZER — select an audio clip".into());155+ self.notify_user("NO VISUALIZER — select a clip with sound".into());
161 cx.notify();156 cx.notify();
162 return;157 return;
163 };158 };
@@ -166,11 +161,6 @@ impl Player {
166 cx.notify();161 cx.notify();
167 return;162 return;
168 };163 };
169- if !engine::is_audio(&src.path) {
170- self.notify_user("NO VISUALIZER — this clip is not a sound file".into());
171- cx.notify();
172- return;
173- }
174 session.place_visualizer(164 session.place_visualizer(
175 clip.start,165 clip.start,
176 &src.path,166 &src.path,
@@ -194,6 +184,25 @@ impl Player {
194 cx.notify();184 cx.notify();
195 }185 }
196 186
187+ pub(crate) fn toggle_viz_flag(&mut self, bit: u8, cx: &mut Context<Self>) {
188+ let Some((lane, idx)) = self.selected.anchor() else {
189+ return;
190+ };
191+ let Some(session) = &mut self.session else {
192+ return;
193+ };
194+ let Some(clip) = session.lane_clips(lane).get(idx).copied() else {
195+ return;
196+ };
197+ if clip.visualizer & 1 == 0 {
198+ return;
199+ }
200+ if session.set_visualizer(lane, idx, clip.visualizer ^ bit) {
201+ self.reset_after_reseek();
202+ }
203+ cx.notify();
204+ }
205+
197 /// Takes a library row's file out of the list, which is the one thing a row206 /// Takes a library row's file out of the list, which is the one thing a row
198 /// can lose. Refused in the engine's own words while clips still play from207 /// can lose. Refused in the engine's own words while clips still play from
199 /// it -- and those words name the lanes holding them, so the refusal says208 /// it -- and those words name the lanes holding them, so the refusal says
crates/app/src/tests/cards.rsmodified+13 -2
@@ -173,7 +173,7 @@ fn the_stances_key_guard_does_not_swallow_a_bare_export_before_the_oracle_is_ask
173 /// fails, which is the only way that stays true as the editor grows.173 /// fails, which is the only way that stays true as the editor grows.
174 #[test]174 #[test]
175 fn every_action_is_on_the_actions_card() {175 fn every_action_is_on_the_actions_card() {
176- use keymap::{ActionId, Category, Keymap};176+ use keymap::{ActionId, Category};
177 let rows = keys_rows();177 let rows = keys_rows();
178 let listed: Vec<ActionId> = rows178 let listed: Vec<ActionId> = rows
179 .iter()179 .iter()
@@ -214,7 +214,7 @@ fn every_action_is_on_the_actions_card() {
214 );214 );
215 // Both columns say something: the label does the action, the stroke215 // Both columns say something: the label does the action, the stroke
216 // beside it changes that stroke, and neither may read blank.216 // beside it changes that stroke, and neither may read blank.
217- let keymap = Keymap::defaults();217+ let keymap = keymap::Keymap::defaults();
218 for action in ActionId::ALL {218 for action in ActionId::ALL {
219 assert!(!action.label().is_empty(), "{action:?}");219 assert!(!action.label().is_empty(), "{action:?}");
220 assert_ne!(keymap.display(action), "unbound", "{action:?}");220 assert_ne!(keymap.display(action), "unbound", "{action:?}");
@@ -238,6 +238,16 @@ fn only_a_printable_stroke_types_into_the_search() {
238 }238 }
239 }239 }
240 240
241+#[test]
242+fn keys_search_keeps_matching_rows_and_drops_empty_heads() {
243+ let km = keymap::Keymap::defaults();
244+ let cut = keys_rows_matching("cut", &km);
245+ assert!(cut.iter().any(|r| matches!(r, KeyRow::Act(ActionId::Cut))));
246+ assert!(!cut.iter().any(|r| matches!(r, KeyRow::Act(ActionId::Play))));
247+ assert!(cut.iter().any(|r| matches!(r, KeyRow::Head(_))));
248+ assert!(keys_rows_matching("xyzzy-no-such", &km).is_empty());
249+}
250+
241 #[test]251 #[test]
242 fn the_keybindings_card_fits_the_smallest_window() {252 fn the_keybindings_card_fits_the_smallest_window() {
243 // The row list is capped and scrolls, so the card's height no longer253 // The row list is capped and scrolls, so the card's height no longer
@@ -1372,6 +1382,7 @@ fn a_duration_row_shows_only_for_a_transition_and_its_room_is_the_successors() {
1372 fade_in,1382 fade_in,
1373 fade_out,1383 fade_out,
1374 transition_out,1384 transition_out,
1385+ visualizer: 0,
1375 }1386 }
1376 }1387 }
1377 // A plain cut carries neither field, so the row has nothing to show.1388 // A plain cut carries neither field, so the row has nothing to show.
crates/app/src/tests/editing.rsmodified+8 -2
@@ -335,11 +335,13 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
335 menu_items(cap),335 menu_items(cap),
336 vec![336 vec![
337 ActionId::Paste,337 ActionId::Paste,
338+ ActionId::Group,
339+ ActionId::Detach,
338 // Below the rule line the render draws before it, like every340 // Below the rule line the render draws before it, like every
339 // other row that takes something away (DESIGN §9).341 // other row that takes something away (DESIGN §9).
340 ActionId::Delete,342 ActionId::Delete,
341 ],343 ],
342- "the caption's menu is its removal and the one global row left",344+ "the caption's menu is its removal, the group pair, and paste",
343 );345 );
344 // ...and the same reading with a clip under it is the clip menu, untouched:346 // ...and the same reading with a clip under it is the clip menu, untouched:
345 // the flag is off wherever a `Clip` was clicked.347 // the flag is off wherever a `Clip` was clicked.
@@ -628,6 +630,7 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
628 fade_in: 0,630 fade_in: 0,
629 fade_out: 0,631 fade_out: 0,
630 transition_out: 0,632 transition_out: 0,
633+ visualizer: 0,
631 start: 30,634 start: 30,
632 in_frame: 0,635 in_frame: 0,
633 out_frame: 60,636 out_frame: 60,
@@ -759,7 +762,7 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
759 // silence scan is, because it opens on the half it is grouped with.762 // silence scan is, because it opens on the half it is grouped with.
760 let picture = menu(v1, false, 60);763 let picture = menu(v1, false, 60);
761 assert!(!picture.contains(&ActionId::Equalizer), "{picture:?}");764 assert!(!picture.contains(&ActionId::Equalizer), "{picture:?}");
762- assert!(!picture.contains(&ActionId::Visualizer), "{picture:?}");765+ assert!(picture.contains(&ActionId::Visualizer), "{picture:?}");
763 assert!(picture.contains(&ActionId::Color));766 assert!(picture.contains(&ActionId::Color));
764 assert!(picture.contains(&ActionId::Fit));767 assert!(picture.contains(&ActionId::Fit));
765 assert!(picture.contains(&ActionId::Silence));768 assert!(picture.contains(&ActionId::Silence));
@@ -1062,6 +1065,7 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() {
1062 fade_in: 0,1065 fade_in: 0,
1063 fade_out: 0,1066 fade_out: 0,
1064 transition_out: 0,1067 transition_out: 0,
1068+ visualizer: 0,
1065 start: 30,1069 start: 30,
1066 in_frame: 0,1070 in_frame: 0,
1067 out_frame: 60,1071 out_frame: 60,
@@ -1793,6 +1797,7 @@ fn a_copied_clip_is_renumbered_or_dropped_when_a_row_leaves_the_library() {
1793 fade_in: 0,1797 fade_in: 0,
1794 fade_out: 0,1798 fade_out: 0,
1795 transition_out: 0,1799 transition_out: 0,
1800+ visualizer: 0,
1796 start: 0,1801 start: 0,
1797 in_frame: 0,1802 in_frame: 0,
1798 out_frame: 30,1803 out_frame: 30,
@@ -1945,6 +1950,7 @@ fn trim_to_playhead_needs_a_subject_cut_with_the_playhead_on_it() {
1945 fade_in: 0,1950 fade_in: 0,
1946 fade_out: 0,1951 fade_out: 0,
1947 transition_out: 0,1952 transition_out: 0,
1953+ visualizer: 0,
1948 start: 100,1954 start: 100,
1949 in_frame: 0,1955 in_frame: 0,
1950 out_frame: 60,1956 out_frame: 60,
crates/app/src/tests/layout.rsmodified+3 -18
@@ -746,6 +746,7 @@ fn a_drop_moves_the_clip_that_was_picked_up_not_its_old_index() {
746 fade_in: 0,746 fade_in: 0,
747 fade_out: 0,747 fade_out: 0,
748 transition_out: 0,748 transition_out: 0,
749+ visualizer: 0,
749 start,750 start,
750 in_frame: 0,751 in_frame: 0,
751 out_frame: 30,752 out_frame: 30,
@@ -2584,23 +2585,6 @@ fn every_action_has_a_darkroom_widget_home_or_explicit_owner() {
2584 accelerator for cycling that existing selection, not a new door -- legacy had no \2585 accelerator for cycling that existing selection, not a new door -- legacy had no \
2585 toolbar button for it either",2586 toolbar button for it either",
2586 ),2587 ),
2587- // The group trio: a group is *made* with the pointer already --
2588- // ctrl-click the halves and the grammar is the selection itself
2589- // (DESIGN §9) -- so a row per verb in the clip menu was three rows
2590- // saying what the click had already said. Chords and KEYS rows keep
2591- // them reachable.
2592- (
2593- ActionId::Group,
2594- "made by ctrl-clicking the halves: the selection is the grammar",
2595- ),
2596- (
2597- ActionId::Detach,
2598- "made by ctrl-clicking the halves: the selection is the grammar",
2599- ),
2600- (
2601- ActionId::Regroup,
2602- "made by ctrl-clicking the halves: the selection is the grammar",
2603- ),
2604 // The keyboard's own trim: `^[` and `^]` do with a stroke what the2588 // The keyboard's own trim: `^[` and `^]` do with a stroke what the
2605 // pointer does by dragging the clip edge to the spot it wants, and2589 // pointer does by dragging the clip edge to the spot it wants, and
2606 // that drag is the door -- a menu row for it would be a second name2590 // that drag is the door -- a menu row for it would be a second name
@@ -3271,7 +3255,7 @@ fn the_keys_list_is_dock_body_state_not_a_tab() {
3271 "the keys list draws no KEYS head in the dock body"3255 "the keys list draws no KEYS head in the dock body"
3272 );3256 );
3273 assert!(3257 assert!(
3274- dock.contains("fn keys_tab(") && dock.contains("keys_rows()"),3258+ dock.contains("fn keys_tab(") && dock.contains("keys_rows_matching("),
3275 "the KEYS tab draws something other than the action registry"3259 "the KEYS tab draws something other than the action registry"
3276 );3260 );
3277 assert!(3261 assert!(
@@ -3580,6 +3564,7 @@ fn the_cut_readout_counts_from_the_playhead() {
3580 fade_in: 0,3564 fade_in: 0,
3581 fade_out: 0,3565 fade_out: 0,
3582 transition_out: 0,3566 transition_out: 0,
3567+ visualizer: 0,
3583 start,3568 start,
3584 in_frame: 0,3569 in_frame: 0,
3585 out_frame: len,3570 out_frame: len,
crates/app/src/tests/mod.rsmodified+1 -1
@@ -25,7 +25,7 @@ use super::{
25 clipboard_after_remove, color_snap, containers, destructive, enable, enable_lane, envelope, eq_card_w,25 clipboard_after_remove, color_snap, containers, destructive, enable, enable_lane, envelope, eq_card_w,
26 eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path,26 eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path,
27 export_settings, format_refusal, fps_choices, fps_label, frac_along, frac_down,27 export_settings, format_refusal, fps_choices, fps_label, frac_along, frac_down,
28- frame_at, frame_rate_ladder, histogram, inserted_band, is_project, keymap, keys_rows, lanes_h,28+ frame_at, frame_rate_ladder, histogram, inserted_band, is_project, keymap, keys_rows, keys_rows_matching, lanes_h,
29 lane_items, marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play,29 lane_items, marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play,
30 notice_tone, panel_h, parse_budget, project_path, range_word, proxies_to_start, push_notice, px_below, retarget,30 notice_tone, panel_h, parse_budget, project_path, range_word, proxies_to_start, push_notice, px_below, retarget,
31 row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate, size_label,31 row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate, size_label,
crates/app/src/tests/view.rsmodified+1 -0
@@ -157,6 +157,7 @@ fn the_marks_are_every_lane_the_playhead_and_the_start() {
157 fade_in: 0,157 fade_in: 0,
158 fade_out: 0,158 fade_out: 0,
159 transition_out: 0,159 transition_out: 0,
160+ visualizer: 0,
160 start,161 start,
161 in_frame: 0,162 in_frame: 0,
162 out_frame: frames,163 out_frame: frames,
crates/app/src/timeline_math.rsmodified+1 -0
@@ -888,6 +888,7 @@ mod drop_landing_tests {
888 fade_in: 0,888 fade_in: 0,
889 fade_out: 0,889 fade_out: 0,
890 transition_out: 0,890 transition_out: 0,
891+ visualizer: 0,
891 start,892 start,
892 in_frame: 0,893 in_frame: 0,
893 out_frame: frames,894 out_frame: frames,
crates/app/src/ui/dock_stance.rsmodified+84 -2
@@ -1187,6 +1187,71 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
1187 /// these onto. Drag-while-playing and every other gesture on a row is1187 /// these onto. Drag-while-playing and every other gesture on a row is
1188 /// whatever that card already does; nothing about the gesture is reimplemented1188 /// whatever that card already does; nothing about the gesture is reimplemented
1189 /// here.1189 /// here.
1190+fn viz_style_verbs(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
1191+ let flags = player.selected.anchor().and_then(|(lane, idx)| {
1192+ let session = player.session.as_ref()?;
1193+ let clip = session.lane_clips(lane).get(idx)?;
1194+ (clip.visualizer & 1 != 0).then_some(clip.visualizer)
1195+ });
1196+ let Some(flags) = flags else {
1197+ return div().id("dock-viz-styles");
1198+ };
1199+ let bit = |id: &'static str, label_text: &'static str, bit: u8, on: bool| {
1200+ let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
1201+ div()
1202+ .id(id)
1203+ .flex_none()
1204+ .h(px(CONTROL_H))
1205+ .px(px(8.))
1206+ .flex()
1207+ .items_center()
1208+ .cursor_pointer()
1209+ .text_color(rgb(if on { INK1() } else { INK3() }))
1210+ .font(style.font)
1211+ .text_size(style.size)
1212+ .children(hitmap::control(id, label_text, true))
1213+ .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1214+ this.toggle_viz_flag(bit, cx);
1215+ }))
1216+ .child(if on {
1217+ format!("· {label_text}")
1218+ } else {
1219+ label_text.to_string()
1220+ })
1221+ .into_any_element()
1222+ };
1223+ div()
1224+ .id("dock-viz-styles")
1225+ .flex_none()
1226+ .flex()
1227+ .flex_col()
1228+ .gap(px(2.))
1229+ .child(bit(
1230+ "dock-viz-outline",
1231+ "Outline",
1232+ engine::decode::VIZ_OUTLINE,
1233+ flags & engine::decode::VIZ_OUTLINE != 0,
1234+ ))
1235+ .child(bit(
1236+ "dock-viz-smooth",
1237+ "Smooth",
1238+ engine::decode::VIZ_SMOOTH,
1239+ flags & engine::decode::VIZ_SMOOTH != 0,
1240+ ))
1241+ .child(bit(
1242+ "dock-viz-fast",
1243+ "Fast",
1244+ engine::decode::VIZ_FAST,
1245+ flags & engine::decode::VIZ_FAST != 0,
1246+ ))
1247+ .child(bit(
1248+ "dock-viz-tint",
1249+ "Colour",
1250+ engine::decode::VIZ_TINT,
1251+ flags & engine::decode::VIZ_TINT != 0,
1252+ ))
1253+}
1254+
1190 fn clip_tab(1255 fn clip_tab(
1191 player: &Player,1256 player: &Player,
1192 width: f32,1257 width: f32,
@@ -1301,7 +1366,8 @@ fn clip_tab(
1301 false,1366 false,
1302 player,1367 player,
1303 cx.listener(|this, _: &ClickEvent, _, cx| this.cycle_fit(cx)),1368 cx.listener(|this, _: &ClickEvent, _, cx| this.cycle_fit(cx)),
1304- )),1369+ ))
1370+ .child(viz_style_verbs(player, cx)),
1305 )1371 )
1306 .children(transition_row(player, cx))1372 .children(transition_row(player, cx))
1307 .child(1373 .child(
@@ -1416,7 +1482,23 @@ fn keys_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
1416 // The list no longer wears a tab, so it says its own name the way1482 // The list no longer wears a tab, so it says its own name the way
1417 // every other dock body section does -- MEDIA / IMPORT's head.1483 // every other dock body section does -- MEDIA / IMPORT's head.
1418 .child(section_head("KEYS"))1484 .child(section_head("KEYS"))
1419- .children(keys_rows().into_iter().map(|row| match row {1485+ .child({
1486+ let style = mono(type_scale::CHORD_METADATA_MAX_PX, FontWeight::MEDIUM);
1487+ let filter_text: SharedString = player.keys_filter.clone().into();
1488+ div()
1489+ .id("dock-keys-filter")
1490+ .flex_none()
1491+ .cursor_text()
1492+ .font(style.font)
1493+ .text_size(style.size)
1494+ .text_color(rgb(INK1()))
1495+ .children(hitmap::control("dock.keys-filter", "Filter keys", true))
1496+ .child(match player.keys_filter.is_empty() {
1497+ true => "⌕".to_string(),
1498+ false => format!("⌕ {filter_text}"),
1499+ })
1500+ })
1501+ .children(keys_rows_matching(&player.keys_filter, &player.keymap).into_iter().map(|row| match row {
1420 KeyRow::Head(category) => div()1502 KeyRow::Head(category) => div()
1421 .flex_none()1503 .flex_none()
1422 .pt(px(4.))1504 .pt(px(4.))
crates/app/src/ui/stance.rsmodified+20 -4
@@ -1012,10 +1012,26 @@ pub(crate) fn render(
1012 // the third): only when no card is up, so escape still shuts a1012 // the third): only when no card is up, so escape still shuts a
1013 // card first -- the KEYS tab is a dock tab now, not an overlay,1013 // card first -- the KEYS tab is a dock tab now, not an overlay,
1014 // and nothing about it owns the keyboard.1014 // and nothing about it owns the keyboard.
1015- if key == "escape" && this.keys_open && !this.card_open() {1015+ if this.keys_open && !this.card_open() {
1016- this.keys_open = false;1016+ if key == "escape" {
1017- cx.notify();1017+ if this.keys_filter.is_empty() {
1018- return;1018+ this.keys_open = false;
1019+ } else {
1020+ this.keys_filter.clear();
1021+ }
1022+ cx.notify();
1023+ return;
1024+ }
1025+ if key == "backspace" {
1026+ this.keys_filter.pop();
1027+ cx.notify();
1028+ return;
1029+ }
1030+ if let Some(c) = typed(key) {
1031+ this.keys_filter.push(c);
1032+ cx.notify();
1033+ return;
1034+ }
1019 }1035 }
1020 // The dock's Sources filter (MOCK-SPEC "Dock" §2), the same door1036 // The dock's Sources filter (MOCK-SPEC "Dock" §2), the same door
1021 // legacy `render.rs` gives it: owns the keyboard only while it1037 // legacy `render.rs` gives it: owns the keyboard only while it
crates/engine/examples/bench.rsmodified+1 -0
@@ -863,6 +863,7 @@ fn export_bench(path: &Path, seat: &str, out_dir: &Path) {
863 fade_in: 0,863 fade_in: 0,
864 fade_out: 0,864 fade_out: 0,
865 transition_out: 0,865 transition_out: 0,
866+ visualizer: 0,
866 start: 0,867 start: 0,
867 in_frame,868 in_frame,
868 out_frame: in_frame + span,869 out_frame: in_frame + span,
crates/engine/src/decode.rsmodified+42 -8
@@ -628,6 +628,7 @@ impl DecodeSession {
628 color: ColorParams,628 color: ColorParams,
629 transform: TransformParams,629 transform: TransformParams,
630 canvas: Composer,630 canvas: Composer,
631+ flags: u8,
631 ) -> crate::Result<FrameStream> {632 ) -> crate::Result<FrameStream> {
632 let (tx, rx) = sync_channel(2);633 let (tx, rx) = sync_channel(2);
633 let cancel = Arc::new(AtomicBool::new(false));634 let cancel = Arc::new(AtomicBool::new(false));
@@ -678,7 +679,7 @@ impl DecodeSession {
678 return;679 return;
679 }680 }
680 let t = f64::from(start_frame + index) / fps;681 let t = f64::from(start_frame + index) / fps;
681- let (y, u, v) = visualizer_i420(&peaks, t, width, height);682+ let (y, u, v) = visualizer_i420(&peaks, t, width, height, flags);
682 let frame = render.frame(start_frame + index, &y, &u, &v, width, height);683 let frame = render.frame(start_frame + index, &y, &u, &v, width, height);
683 if tx.send(frame).is_err() {684 if tx.send(frame).is_err() {
684 return; // caller moved on685 return; // caller moved on
@@ -1408,6 +1409,10 @@ fn rgb_to_i420(rgb: &[u8], width: usize, height: usize) -> (Vec<u8>, Vec<u8>, Ve
1408 /// caller that decodes them ([`DecodeSession::open_visualizer`], preview and1409 /// caller that decodes them ([`DecodeSession::open_visualizer`], preview and
1409 /// export both) and the painter that reads them.1410 /// export both) and the painter that reads them.
1410 pub(crate) const VIZ_BUCKETS_PER_SEC: u32 = 60;1411 pub(crate) const VIZ_BUCKETS_PER_SEC: u32 = 60;
1412+pub const VIZ_OUTLINE: u8 = 1 << 1;
1413+pub const VIZ_SMOOTH: u8 = 1 << 2;
1414+pub const VIZ_FAST: u8 = 1 << 3;
1415+pub const VIZ_TINT: u8 = 1 << 4;
1411 1416
1412 /// How much sound one visualizer frame shows, centered on the frame's own1417 /// How much sound one visualizer frame shows, centered on the frame's own
1413 /// time: two seconds, so a glance reads the shape of the around-now rather1418 /// time: two seconds, so a glance reads the shape of the around-now rather
@@ -1430,6 +1435,7 @@ pub(crate) fn visualizer_i420(
1430 t_secs: f64,1435 t_secs: f64,
1431 width: u32,1436 width: u32,
1432 height: u32,1437 height: u32,
1438+ flags: u8,
1433 ) -> (Vec<u8>, Vec<u8>, Vec<u8>) {1439 ) -> (Vec<u8>, Vec<u8>, Vec<u8>) {
1434 // Even dims, like every canvas this engine composes at: an odd caller is1440 // Even dims, like every canvas this engine composes at: an odd caller is
1435 // shaved rather than handed chroma math it did not ask about.1441 // shaved rather than handed chroma math it did not ask about.
@@ -1438,8 +1444,8 @@ pub(crate) fn visualizer_i420(
1438 let (w, h) = (width as usize, height as usize);1444 let (w, h) = (width as usize, height as usize);
1439 let (cw, ch) = crate::scale::chroma_dims(w, h);1445 let (cw, ch) = crate::scale::chroma_dims(w, h);
1440 let mut y = vec![16u8; w * h];1446 let mut y = vec![16u8; w * h];
1441- let u = vec![128u8; cw * ch];1447+ let mut u = vec![128u8; cw * ch];
1442- let v = vec![128u8; cw * ch];1448+ let mut v = vec![128u8; cw * ch];
1443 let center = h / 2;1449 let center = h / 2;
1444 let duration = peaks.len() as f64 / f64::from(VIZ_BUCKETS_PER_SEC);1450 let duration = peaks.len() as f64 / f64::from(VIZ_BUCKETS_PER_SEC);
1445 if peaks.is_empty() || !t_secs.is_finite() || !(0.0..=duration).contains(&t_secs) {1451 if peaks.is_empty() || !t_secs.is_finite() || !(0.0..=duration).contains(&t_secs) {
@@ -1449,16 +1455,19 @@ pub(crate) fn visualizer_i420(
1449 return (y, u, v);1455 return (y, u, v);
1450 }1456 }
1451 let per_sec = f64::from(VIZ_BUCKETS_PER_SEC);1457 let per_sec = f64::from(VIZ_BUCKETS_PER_SEC);
1458+ let window = if flags & VIZ_FAST != 0 { 0.4 } else { VIZ_WINDOW_SECS };
1452 // The window, clamped to the peaks that exist: a frame near either end1459 // The window, clamped to the peaks that exist: a frame near either end
1453 // looks past the file's edge, and draws the part of the window that is1460 // looks past the file's edge, and draws the part of the window that is
1454 // real rather than padding it out.1461 // real rather than padding it out.
1455- let first = (((t_secs - VIZ_WINDOW_SECS / 2.0).max(0.0) * per_sec).floor() as usize)1462+ let first = (((t_secs - window / 2.0).max(0.0) * per_sec).floor() as usize)
1456 .min(peaks.len() - 1);1463 .min(peaks.len() - 1);
1457- let last = ((((t_secs + VIZ_WINDOW_SECS / 2.0).min(duration) * per_sec).ceil() as usize)1464+ let last = ((((t_secs + window / 2.0).min(duration) * per_sec).ceil() as usize)
1458 .clamp(first + 1, peaks.len()))1465 .clamp(first + 1, peaks.len()))
1459 .min(peaks.len());1466 .min(peaks.len());
1460 let span = (last - first) as f64;1467 let span = (last - first) as f64;
1461 let scale = center as f32;1468 let scale = center as f32;
1469+ let smooth = flags & VIZ_SMOOTH != 0;
1470+ let outline = flags & VIZ_OUTLINE != 0;
1462 for col in 0..w {1471 for col in 0..w {
1463 // The buckets this column draws: at least one, whatever the window's1472 // The buckets this column draws: at least one, whatever the window's
1464 // width is against the picture's -- a short clip stretches, a long1473 // width is against the picture's -- a short clip stretches, a long
@@ -1467,8 +1476,13 @@ pub(crate) fn visualizer_i420(
1467 let b1 = first1476 let b1 = first
1468 + (((col + 1) as f64 * span / w as f64).ceil() as usize)1477 + (((col + 1) as f64 * span / w as f64).ceil() as usize)
1469 .clamp(b0 - first + 1, last - first);1478 .clamp(b0 - first + 1, last - first);
1479+ let (s0, s1) = if smooth {
1480+ (b0.saturating_sub(1), (b1 + 1).min(peaks.len()))
1481+ } else {
1482+ (b0, b1)
1483+ };
1470 let (mut lo, mut hi) = (f32::INFINITY, f32::NEG_INFINITY);1484 let (mut lo, mut hi) = (f32::INFINITY, f32::NEG_INFINITY);
1471- for &(min, max) in &peaks[b0..b1] {1485+ for &(min, max) in &peaks[s0..s1] {
1472 lo = lo.min(min);1486 lo = lo.min(min);
1473 hi = hi.max(max);1487 hi = hi.max(max);
1474 }1488 }
@@ -1477,8 +1491,28 @@ pub(crate) fn visualizer_i420(
1477 let bottom = (scale - lo * scale).round();1491 let bottom = (scale - lo * scale).round();
1478 let top = (top as isize).clamp(0, h as isize - 1) as usize;1492 let top = (top as isize).clamp(0, h as isize - 1) as usize;
1479 let bottom = (bottom as isize).clamp(top as isize, h as isize - 1) as usize;1493 let bottom = (bottom as isize).clamp(top as isize, h as isize - 1) as usize;
1480- for row in top..=bottom {1494+ if outline {
1481- y[row * w + col] = 220;1495+ y[top * w + col] = 220;
1496+ y[bottom * w + col] = 220;
1497+ } else {
1498+ for row in top..=bottom {
1499+ y[row * w + col] = 220;
1500+ }
1501+ }
1502+ }
1503+ if flags & VIZ_TINT != 0 {
1504+ // Cyan on the ink, black stays black: chroma follows luma so a
1505+ // grade still reaches the bars around it.
1506+ for cy in 0..ch {
1507+ for cx in 0..cw {
1508+ let ink = y[cy * 2 * w + cx * 2] > 16
1509+ || y[cy * 2 * w + cx * 2 + 1] > 16
1510+ || y[(cy * 2 + 1).min(h - 1) * w + cx * 2] > 16;
1511+ if ink {
1512+ u[cy * cw + cx] = 80;
1513+ v[cy * cw + cx] = 80;
1514+ }
1515+ }
1482 }1516 }
1483 }1517 }
1484 (y, u, v)1518 (y, u, v)
crates/engine/src/edith.rsmodified+76 -51
@@ -31,7 +31,7 @@
31 //! ([`crate::PlaybackSession::set_frame_rate`]), and the *only* thing that says31 //! ([`crate::PlaybackSession::set_frame_rate`]), and the *only* thing that says
32 //! so once one was, since every clip number in the file is counted in it.32 //! so once one was, since every clip number in the file is counted in it.
33 //! Printed so it reads back bit-exactly. A file without one (every dialect33 //! Printed so it reads back bit-exactly. A file without one (every dialect
34-//! before v9) means "whatever the scaffolding source runs at", which is what34+//! before v9) means 0"whatever the scaffolding source runs at", which is what
35 //! such a project always was and is an answer only a project holding a video has35 //! such a project always was and is an answer only a project holding a video has
36 //! ([`crate::PlaybackSession::open_project`]).36 //! ([`crate::PlaybackSession::open_project`]).
37 //!37 //!
@@ -118,7 +118,7 @@
118 //! its fit policy already placed.118 //! its fit policy already placed.
119 //!119 //!
120 //! A lane line is `<kind> <lane> <start> <in> <out> <source> <link> <eq>120 //! A lane line is `<kind> <lane> <start> <in> <out> <source> <link> <eq>
121-//! <color> <fit> <speed> <fade_in> <fade_out> <transition_out> <transform>`:121+//! <color> <fit> <speed> <fade_in> <fade_out> <transition_out> <transform> <visualizer>`:
122 //! which lane the clip is on -- its kind and its 1-based number122 //! which lane the clip is on -- its kind and its 1-based number
123 //! among the lanes of that kind, the [`crate::project::Lane::label`] a header123 //! among the lanes of that kind, the [`crate::project::Lane::label`] a header
124 //! column shows -- then where the clip sits on the timeline, the half-open124 //! column shows -- then where the clip sits on the timeline, the half-open
@@ -134,7 +134,9 @@
134 //! ([`crate::project::Clip::transition_out`], `0` for a hard cut), and last of134 //! ([`crate::project::Clip::transition_out`], `0` for a hard cut), and last of
135 //! all the transform line it is placed, sized, turned and cropped by, on top135 //! all the transform line it is placed, sized, turned and cropped by, on top
136 //! of everything its fit policy already did (`-` for a clip left at its fit136 //! of everything its fit policy already did (`-` for a clip left at its fit
137-//! policy's own spot, [`crate::project::Clip::transform`]).137+//! policy's own spot, [`crate::project::Clip::transform`]), and a visualizer
138+//! flags byte (`0` for an ordinary picture, bit 0 for a waveform of the
139+//! source's sound, the rest outline/smooth/fast/tint).
138 //! Timeline placement is140 //! Timeline placement is
139 //! explicit, so a *gap* is simply a stretch no line covers -- there is nothing141 //! explicit, so a *gap* is simply a stretch no line covers -- there is nothing
140 //! to write for one, and nothing that can disagree about its length. The `<in>`142 //! to write for one, and nothing that can disagree about its length. The `<in>`
@@ -203,7 +205,7 @@
203 //! nothing, and an older one plays everything at real time, and an older one205 //! nothing, and an older one plays everything at real time, and an older one
204 //! mixes flat, and an older one shows no subtitles, and an older one is shown206 //! mixes flat, and an older one shows no subtitles, and an older one is shown
205 //! in the reference rendition, and an older one places none of the words it207 //! in the reference rendition, and an older one places none of the words it
206-//! names -- and saving any of them writes v20. An older208+//! names -- and saving any of them writes v21. An older
207 //! reader refuses a newer file by name.209 //! reader refuses a newer file by name.
208 //!210 //!
209 //! Text because an edit list is a few integers and a path, and a path is211 //! Text because an edit list is a few integers and a path, and a path is
@@ -240,7 +242,8 @@ use crate::transform::TransformParams;
240 242
241 /// What [`save`] writes. Read support goes back to `edith 1`; see the module243 /// What [`save`] writes. Read support goes back to `edith 1`; see the module
242 /// docs for what those dialects looked like.244 /// docs for what those dialects looked like.
243-const MAGIC: &[u8] = b"edith 20";245+const MAGIC: &[u8] = b"edith 21";
246+const MAGIC_V20: &[u8] = b"edith 20";
244 const MAGIC_V19: &[u8] = b"edith 19";247 const MAGIC_V19: &[u8] = b"edith 19";
245 const MAGIC_V18: &[u8] = b"edith 18";248 const MAGIC_V18: &[u8] = b"edith 18";
246 const MAGIC_V17: &[u8] = b"edith 17";249 const MAGIC_V17: &[u8] = b"edith 17";
@@ -592,7 +595,7 @@ fn emit(
592 let transform = c.transform.map_or("-".to_string(), |e| e.to_string());595 let transform = c.transform.map_or("-".to_string(), |e| e.to_string());
593 out.extend_from_slice(596 out.extend_from_slice(
594 format!(597 format!(
595- "{keyword} {ord} {} {} {} {} {link} {eq} {color} {} {} {} {} {} {transform}\n",598+ "{keyword} {ord} {} {} {} {} {link} {eq} {color} {} {} {} {} {} {transform} {}\n",
596 c.start,599 c.start,
597 c.in_frame,600 c.in_frame,
598 c.out_frame,601 c.out_frame,
@@ -602,6 +605,7 @@ fn emit(
602 c.fade_in,605 c.fade_in,
603 c.fade_out,606 c.fade_out,
604 c.transition_out,607 c.transition_out,
608+ c.visualizer,
605 )609 )
606 .as_bytes(),610 .as_bytes(),
607 );611 );
@@ -644,8 +648,10 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
644 // The dialects that wrote a source line without its stream field. Reading648 // The dialects that wrote a source line without its stream field. Reading
645 // one is the whole of what "an old project still opens" means here.649 // one is the whole of what "an old project still opens" means here.
646 let streamless = v1 || first == MAGIC_V2;650 let streamless = v1 || first == MAGIC_V2;
651+ // The one that carries per-clip visualizer flags...
652+ let v21 = first == MAGIC;
647 // The one that carries a per-clip transform (position/scale/rotate/crop)...653 // The one that carries a per-clip transform (position/scale/rotate/crop)...
648- let v20 = first == MAGIC;654+ let v20 = v21 || first == MAGIC_V20;
649 // ...the one that carries a per-clip cross-dissolve into its successor...655 // ...the one that carries a per-clip cross-dissolve into its successor...
650 let v19 = v20 || first == MAGIC_V19;656 let v19 = v20 || first == MAGIC_V19;
651 // ...the one that carries a per-clip fade envelope...657 // ...the one that carries a per-clip fade envelope...
@@ -1046,6 +1052,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
1046 fade_in: 0,1052 fade_in: 0,
1047 fade_out: 0,1053 fade_out: 0,
1048 transition_out: 0,1054 transition_out: 0,
1055+ visualizer: 0,
1049 start: queued,1056 start: queued,
1050 in_frame: number(f[0], n)?,1057 in_frame: number(f[0], n)?,
1051 out_frame: number(f[1], n)?,1058 out_frame: number(f[1], n)?,
@@ -1176,7 +1183,8 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
1176 + usize::from(v8)1183 + usize::from(v8)
1177 + 2 * usize::from(v18)1184 + 2 * usize::from(v18)
1178 + usize::from(v19)1185 + usize::from(v19)
1179- + usize::from(v20);1186+ + usize::from(v20)
1187+ + usize::from(v21);
1180 let f = fields(rest, want, "clip", n)?;1188 let f = fields(rest, want, "clip", n)?;
1181 let in_frame = number(f[1], n)?;1189 let in_frame = number(f[1], n)?;
1182 let out_frame = number(f[2], n)?;1190 let out_frame = number(f[2], n)?;
@@ -1191,6 +1199,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
1191 fade_in: number(f.get(9).copied().unwrap_or(b"0"), n)?.min(frames),1199 fade_in: number(f.get(9).copied().unwrap_or(b"0"), n)?.min(frames),
1192 fade_out: number(f.get(10).copied().unwrap_or(b"0"), n)?.min(frames),1200 fade_out: number(f.get(10).copied().unwrap_or(b"0"), n)?.min(frames),
1193 transition_out: number(f.get(11).copied().unwrap_or(b"0"), n)?.min(frames),1201 transition_out: number(f.get(11).copied().unwrap_or(b"0"), n)?.min(frames),
1202+ visualizer: number(f.get(13).copied().unwrap_or(b"0"), n)? as u8,
1194 start: number(f[0], n)?,1203 start: number(f[0], n)?,
1195 in_frame,1204 in_frame,
1196 out_frame,1205 out_frame,
@@ -1620,7 +1629,7 @@ mod tests {
1620 video 1 0 0 30 0 - - - fit 1000\n";1629 video 1 0 0 30 0 - - - fit 1000\n";
1621 let old = parse(v9, &dir).expect("v9 still loads");1630 let old = parse(v9, &dir).expect("v9 still loads");
1622 assert_eq!(old.subtitles, Vec::new());1631 assert_eq!(old.subtitles, Vec::new());
1623- assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 20\n"));1632+ assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 21\n"));
1624 // ...and the line itself is not a v9 line: a dialect may not be mixed.1633 // ...and the line itself is not a v9 line: a dialect may not be mixed.
1625 let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir)1634 let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir)
1626 .unwrap_err()1635 .unwrap_err()
@@ -2039,6 +2048,7 @@ mod tests {
2039 fade_in: 0,2048 fade_in: 0,
2040 fade_out: 0,2049 fade_out: 0,
2041 transition_out: 0,2050 transition_out: 0,
2051+ visualizer: 0,
2042 start,2052 start,
2043 in_frame,2053 in_frame,
2044 out_frame,2054 out_frame,
@@ -2098,10 +2108,10 @@ mod tests {
2098 let bytes = flat(&dir, &sources, &lanes, 12);2108 let bytes = flat(&dir, &sources, &lanes, 12);
2099 assert_eq!(2109 assert_eq!(
2100 String::from_utf8_lossy(&bytes),2110 String::from_utf8_lossy(&bytes),
2101- "edith 20\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\2111+ "edith 21\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
2102 source 2 /elsewhere/b.mp4\n\2112 source 2 /elsewhere/b.mp4\n\
2103- video 1 0 0 30 0 0 - - fit 1000 0 0 0 -\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 -\n\2113+ video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0\n\
2104- audio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n",2114+ audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n",
2105 "the file under the project directory is written relative to it, \2115 "the file under the project directory is written relative to it, \
2106 each with the audio stream it plays"2116 each with the audio stream it plays"
2107 );2117 );
@@ -2135,9 +2145,9 @@ mod tests {
2135 let bytes = flat(&dir, &sources, &lanes, 7);2145 let bytes = flat(&dir, &sources, &lanes, 7);
2136 assert_eq!(2146 assert_eq!(
2137 String::from_utf8_lossy(&bytes),2147 String::from_utf8_lossy(&bytes),
2138- "edith 20\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\2148+ "edith 21\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\
2139- video 1 0 0 30 0 4 - - fit 1000 0 0 0 -\naudio 1\n\2149+ video 1 0 0 30 0 4 - - fit 1000 0 0 0 - 0\naudio 1\n\
2140- video 2 40 0 10 0 - - - fit 1000 0 0 0 -\naudio 2 0 0 30 0 4 - - fit 1000 0 0 0 -\n",2150+ video 2 40 0 10 0 - - - fit 1000 0 0 0 - 0\naudio 2 0 0 30 0 4 - - fit 1000 0 0 0 - 0\n",
2141 "an empty lane is a line of its own; everything else is its clips"2151 "an empty lane is a line of its own; everything else is its clips"
2142 );2152 );
2143 let back = parse(&bytes, &dir).expect("parse");2153 let back = parse(&bytes, &dir).expect("parse");
@@ -2224,6 +2234,7 @@ mod tests {
2224 fade_in: 0,2234 fade_in: 0,
2225 fade_out: 0,2235 fade_out: 0,
2226 transition_out: 0,2236 transition_out: 0,
2237+ visualizer: 0,
2227 eq: Some(0),2238 eq: Some(0),
2228 ..clip(0, 0, 30, 0, Some(0))2239 ..clip(0, 0, 30, 0, Some(0))
2229 },2240 },
@@ -2231,6 +2242,7 @@ mod tests {
2231 fade_in: 0,2242 fade_in: 0,
2232 fade_out: 0,2243 fade_out: 0,
2233 transition_out: 0,2244 transition_out: 0,
2245+ visualizer: 0,
2234 eq: Some(1),2246 eq: Some(1),
2235 ..clip(30, 10, 20, 0, None)2247 ..clip(30, 10, 20, 0, None)
2236 },2248 },
@@ -2240,6 +2252,7 @@ mod tests {
2240 fade_in: 0,2252 fade_in: 0,
2241 fade_out: 0,2253 fade_out: 0,
2242 transition_out: 0,2254 transition_out: 0,
2255+ visualizer: 0,
2243 eq: Some(0),2256 eq: Some(0),
2244 ..clip(0, 0, 30, 0, Some(0))2257 ..clip(0, 0, 30, 0, Some(0))
2245 },2258 },
@@ -2247,6 +2260,7 @@ mod tests {
2247 fade_in: 0,2260 fade_in: 0,
2248 fade_out: 0,2261 fade_out: 0,
2249 transition_out: 0,2262 transition_out: 0,
2263+ visualizer: 0,
2250 eq: Some(2),2264 eq: Some(2),
2251 ..clip(30, 0, 10, 0, None)2265 ..clip(30, 0, 10, 0, None)
2252 },2266 },
@@ -2255,12 +2269,12 @@ mod tests {
2255 let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0);2269 let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0);
2256 assert_eq!(2270 assert_eq!(
2257 String::from_utf8_lossy(&bytes),2271 String::from_utf8_lossy(&bytes),
2258- "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2272+ "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2259 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\2273 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
2260 eq 16777215.0:-0.1:3.918315e-39:hs\n\2274 eq 16777215.0:-0.1:3.918315e-39:hs\n\
2261 eq\n\2275 eq\n\
2262- video 1 0 0 30 0 0 0 - fit 1000 0 0 0 -\nvideo 1 30 10 20 0 - 1 - fit 1000 0 0 0 -\n\2276+ video 1 0 0 30 0 0 0 - fit 1000 0 0 0 - 0\nvideo 1 30 10 20 0 - 1 - fit 1000 0 0 0 - 0\n\
2263- audio 1 0 0 30 0 0 0 - fit 1000 0 0 0 -\naudio 1 30 0 10 0 - 2 - fit 1000 0 0 0 -\n",2277+ audio 1 0 0 30 0 0 0 - fit 1000 0 0 0 - 0\naudio 1 30 0 10 0 - 2 - fit 1000 0 0 0 - 0\n",
2264 "the table comes before the clips, and a clip names a line of it"2278 "the table comes before the clips, and a clip names a line of it"
2265 );2279 );
2266 2280
@@ -2332,6 +2346,7 @@ mod tests {
2332 fade_in: 0,2346 fade_in: 0,
2333 fade_out: 0,2347 fade_out: 0,
2334 transition_out: 0,2348 transition_out: 0,
2349+ visualizer: 0,
2335 color: Some(0),2350 color: Some(0),
2336 fit: FitPolicy::default(),2351 fit: FitPolicy::default(),
2337 speed: Speed::NORMAL,2352 speed: Speed::NORMAL,
@@ -2341,6 +2356,7 @@ mod tests {
2341 fade_in: 0,2356 fade_in: 0,
2342 fade_out: 0,2357 fade_out: 0,
2343 transition_out: 0,2358 transition_out: 0,
2359+ visualizer: 0,
2344 color: Some(1),2360 color: Some(1),
2345 fit: FitPolicy::default(),2361 fit: FitPolicy::default(),
2346 speed: Speed::NORMAL,2362 speed: Speed::NORMAL,
@@ -2352,6 +2368,7 @@ mod tests {
2352 fade_in: 0,2368 fade_in: 0,
2353 fade_out: 0,2369 fade_out: 0,
2354 transition_out: 0,2370 transition_out: 0,
2371+ visualizer: 0,
2355 color: Some(0),2372 color: Some(0),
2356 fit: FitPolicy::default(),2373 fit: FitPolicy::default(),
2357 speed: Speed::NORMAL,2374 speed: Speed::NORMAL,
@@ -2361,6 +2378,7 @@ mod tests {
2361 fade_in: 0,2378 fade_in: 0,
2362 fade_out: 0,2379 fade_out: 0,
2363 transition_out: 0,2380 transition_out: 0,
2381+ visualizer: 0,
2364 color: Some(2),2382 color: Some(2),
2365 fit: FitPolicy::default(),2383 fit: FitPolicy::default(),
2366 speed: Speed::NORMAL,2384 speed: Speed::NORMAL,
@@ -2371,12 +2389,12 @@ mod tests {
2371 let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0);2389 let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0);
2372 assert_eq!(2390 assert_eq!(
2373 String::from_utf8_lossy(&bytes),2391 String::from_utf8_lossy(&bytes),
2374- "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2392+ "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2375 color 0.1:1.2:0.9:-0.3\n\2393 color 0.1:1.2:0.9:-0.3\n\
2376 color -1e-7:16777215.0:3.918315e-39:-0.0\n\2394 color -1e-7:16777215.0:3.918315e-39:-0.0\n\
2377 color 0.0:1.0:1.0:0.0\n\2395 color 0.0:1.0:1.0:0.0\n\
2378- video 1 0 0 30 0 0 - 0 fit 1000 0 0 0 -\nvideo 1 30 10 20 0 - - 1 fit 1000 0 0 0 -\n\2396+ video 1 0 0 30 0 0 - 0 fit 1000 0 0 0 - 0\nvideo 1 30 10 20 0 - - 1 fit 1000 0 0 0 - 0\n\
2379- audio 1 0 0 30 0 0 - 0 fit 1000 0 0 0 -\naudio 1 30 0 10 0 - - 2 fit 1000 0 0 0 -\n",2397+ audio 1 0 0 30 0 0 - 0 fit 1000 0 0 0 - 0\naudio 1 30 0 10 0 - - 2 fit 1000 0 0 0 - 0\n",
2380 "the table comes before the clips, and a clip names a line of it"2398 "the table comes before the clips, and a clip names a line of it"
2381 );2399 );
2382 2400
@@ -2436,9 +2454,9 @@ mod tests {
2436 (1280, 720),2454 (1280, 720),
2437 old.playhead2455 old.playhead
2438 )),2456 )),
2439- "edith 20\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\2457+ "edith 21\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
2440 eq 80.0:-3.0:0.707:ls\n\2458 eq 80.0:-3.0:0.707:ls\n\
2441- video 1 0 0 30 0 0 0 - fit 1000 0 0 0 -\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n"2459+ video 1 0 0 30 0 0 0 - fit 1000 0 0 0 - 0\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n"
2442 );2460 );
2443 }2461 }
2444 2462
@@ -2454,6 +2472,7 @@ mod tests {
2454 fade_in: 0,2472 fade_in: 0,
2455 fade_out: 0,2473 fade_out: 0,
2456 transition_out: 0,2474 transition_out: 0,
2475+ visualizer: 0,
2457 start,2476 start,
2458 in_frame,2477 in_frame,
2459 out_frame,2478 out_frame,
@@ -2478,9 +2497,9 @@ mod tests {
2478 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);2497 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);
2479 assert_eq!(2498 assert_eq!(
2480 String::from_utf8_lossy(&bytes),2499 String::from_utf8_lossy(&bytes),
2481- "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2500+ "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2482- video 1 0 0 30 0 - - - fit 2000 0 0 0 -\nvideo 1 15 30 40 0 - - - fit 250 0 0 0 -\n\2501+ video 1 0 0 30 0 - - - fit 2000 0 0 0 - 0\nvideo 1 15 30 40 0 - - - fit 250 0 0 0 - 0\n\
2483- audio 1 0 0 30 0 - - - fit 2000 0 0 0 -\n",2502+ audio 1 0 0 30 0 - - - fit 2000 0 0 0 - 0\n",
2484 "the rate is the clip line's last field, in thousandths"2503 "the rate is the clip line's last field, in thousandths"
2485 );2504 );
2486 let back = parse(&bytes, &dir).expect("parse");2505 let back = parse(&bytes, &dir).expect("parse");
@@ -2507,8 +2526,8 @@ mod tests {
2507 (1280, 720),2526 (1280, 720),
2508 old.playhead2527 old.playhead
2509 )),2528 )),
2510- "edith 20\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\2529+ "edith 21\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
2511- video 1 0 0 30 0 0 - - fit 1000 0 0 0 -\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n"2530+ video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n"
2512 );2531 );
2513 // A rate outside what the editor can set is a corrupt line, by name.2532 // A rate outside what the editor can set is a corrupt line, by name.
2514 let bad = b"edith 8\nsource 0 a.mp4\nvideo 1 0 0 30 0 - - - fit 9000\n";2533 let bad = b"edith 8\nsource 0 a.mp4\nvideo 1 0 0 30 0 - - - fit 9000\n";
@@ -2541,6 +2560,7 @@ mod tests {
2541 fade_in: 5,2560 fade_in: 5,
2542 fade_out: 7,2561 fade_out: 7,
2543 transition_out: 0,2562 transition_out: 0,
2563+ visualizer: 0,
2544 start: 0,2564 start: 0,
2545 in_frame: 0,2565 in_frame: 0,
2546 out_frame: 30,2566 out_frame: 30,
@@ -2556,8 +2576,8 @@ mod tests {
2556 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);2576 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);
2557 assert_eq!(2577 assert_eq!(
2558 String::from_utf8_lossy(&bytes),2578 String::from_utf8_lossy(&bytes),
2559- "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2579+ "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2560- video 1 0 0 30 0 - - - fit 1000 5 7 0 -\n",2580+ video 1 0 0 30 0 - - - fit 1000 5 7 0 - 0\n",
2561 "the fades are the clip line's last two fields"2581 "the fades are the clip line's last two fields"
2562 );2582 );
2563 let back = parse(&bytes, &dir).expect("parse");2583 let back = parse(&bytes, &dir).expect("parse");
@@ -2592,6 +2612,7 @@ mod tests {
2592 fade_in: 0,2612 fade_in: 0,
2593 fade_out: 0,2613 fade_out: 0,
2594 transition_out: 9,2614 transition_out: 9,
2615+ visualizer: 0,
2595 start: 0,2616 start: 0,
2596 in_frame: 0,2617 in_frame: 0,
2597 out_frame: 30,2618 out_frame: 30,
@@ -2607,8 +2628,8 @@ mod tests {
2607 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);2628 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);
2608 assert_eq!(2629 assert_eq!(
2609 String::from_utf8_lossy(&bytes),2630 String::from_utf8_lossy(&bytes),
2610- "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2631+ "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2611- video 1 0 0 30 0 - - - fit 1000 0 0 9 -\n",2632+ video 1 0 0 30 0 - - - fit 1000 0 0 9 - 0\n",
2612 "the dissolve is the clip line's own last field"2633 "the dissolve is the clip line's own last field"
2613 );2634 );
2614 let back = parse(&bytes, &dir).expect("parse");2635 let back = parse(&bytes, &dir).expect("parse");
@@ -2679,6 +2700,7 @@ mod tests {
2679 fade_in: 0,2700 fade_in: 0,
2680 fade_out: 0,2701 fade_out: 0,
2681 transition_out: 0,2702 transition_out: 0,
2703+ visualizer: 0,
2682 transform: Some(0),2704 transform: Some(0),
2683 fit: FitPolicy::default(),2705 fit: FitPolicy::default(),
2684 speed: Speed::NORMAL,2706 speed: Speed::NORMAL,
@@ -2688,6 +2710,7 @@ mod tests {
2688 fade_in: 0,2710 fade_in: 0,
2689 fade_out: 0,2711 fade_out: 0,
2690 transition_out: 0,2712 transition_out: 0,
2713+ visualizer: 0,
2691 transform: Some(1),2714 transform: Some(1),
2692 fit: FitPolicy::default(),2715 fit: FitPolicy::default(),
2693 speed: Speed::NORMAL,2716 speed: Speed::NORMAL,
@@ -2699,6 +2722,7 @@ mod tests {
2699 fade_in: 0,2722 fade_in: 0,
2700 fade_out: 0,2723 fade_out: 0,
2701 transition_out: 0,2724 transition_out: 0,
2725+ visualizer: 0,
2702 transform: Some(0),2726 transform: Some(0),
2703 fit: FitPolicy::default(),2727 fit: FitPolicy::default(),
2704 speed: Speed::NORMAL,2728 speed: Speed::NORMAL,
@@ -2708,6 +2732,7 @@ mod tests {
2708 fade_in: 0,2732 fade_in: 0,
2709 fade_out: 0,2733 fade_out: 0,
2710 transition_out: 0,2734 transition_out: 0,
2735+ visualizer: 0,
2711 transform: Some(2),2736 transform: Some(2),
2712 fit: FitPolicy::default(),2737 fit: FitPolicy::default(),
2713 speed: Speed::NORMAL,2738 speed: Speed::NORMAL,
@@ -2737,12 +2762,12 @@ mod tests {
2737 );2762 );
2738 assert_eq!(2763 assert_eq!(
2739 String::from_utf8_lossy(&bytes),2764 String::from_utf8_lossy(&bytes),
2740- "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2765+ "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2741 transform 0.1:-0.2:1.5:90.0:0.1:0.0:0.0:0.05\n\2766 transform 0.1:-0.2:1.5:90.0:0.1:0.0:0.0:0.05\n\
2742 transform -1e-7:16777215.0:3.918315e-39:-0.0:0.0:0.0:0.0:0.0\n\2767 transform -1e-7:16777215.0:3.918315e-39:-0.0:0.0:0.0:0.0:0.0\n\
2743 transform 0.0:0.0:1.0:0.0:0.0:0.0:0.0:0.0\n\2768 transform 0.0:0.0:1.0:0.0:0.0:0.0:0.0:0.0\n\
2744- video 1 0 0 30 0 0 - - fit 1000 0 0 0 0\nvideo 1 30 10 20 0 - - - fit 1000 0 0 0 1\n\2769+ video 1 0 0 30 0 0 - - fit 1000 0 0 0 0 0\nvideo 1 30 10 20 0 - - - fit 1000 0 0 0 1 0\n\
2745- audio 1 0 0 30 0 0 - - fit 1000 0 0 0 0\naudio 1 30 0 10 0 - - - fit 1000 0 0 0 2\n",2770+ audio 1 0 0 30 0 0 - - fit 1000 0 0 0 0 0\naudio 1 30 0 10 0 - - - fit 1000 0 0 0 2 0\n",
2746 "the table comes before the clips, and a clip names a line of it"2771 "the table comes before the clips, and a clip names a line of it"
2747 );2772 );
2748 2773
@@ -2817,10 +2842,10 @@ mod tests {
2817 );2842 );
2818 assert_eq!(2843 assert_eq!(
2819 String::from_utf8_lossy(&bytes),2844 String::from_utf8_lossy(&bytes),
2820- "edith 20\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\2845+ "edith 21\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\
2821 limiter -1.5 on\nsource 0 a.mp4\n\2846 limiter -1.5 on\nsource 0 a.mp4\n\
2822- video 1 0 0 30 0 - - - fit 1000 0 0 0 -\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 -\n\2847+ video 1 0 0 30 0 - - - fit 1000 0 0 0 - 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0\n\
2823- audio 2 0 0 30 0 - - - fit 1000 0 0 0 -\n\2848+ audio 2 0 0 30 0 - - - fit 1000 0 0 0 - 0\n\
2824 gain audio 1 3.0\ngain audio 2 -6.5\n",2849 gain audio 1 3.0\ngain audio 2 -6.5\n",
2825 "the mix is lines of its own, the gains after the lanes they name"2850 "the mix is lines of its own, the gains after the lanes they name"
2826 );2851 );
@@ -2849,8 +2874,8 @@ mod tests {
2849 (1280, 720),2874 (1280, 720),
2850 old.playhead2875 old.playhead
2851 )),2876 )),
2852- "edith 20\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\2877+ "edith 21\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
2853- video 1 0 0 30 0 - - - fit 1000 0 0 0 -\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 -\n"2878+ video 1 0 0 30 0 - - - fit 1000 0 0 0 - 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0\n"
2854 );2879 );
2855 2880
2856 // Each of the three refuses by name, on its own line.2881 // Each of the three refuses by name, on its own line.
@@ -3013,10 +3038,10 @@ mod tests {
3013 assert!(old.eq.is_empty(), "nothing before v5 equalizes anything");3038 assert!(old.eq.is_empty(), "nothing before v5 equalizes anything");
3014 assert_eq!(3039 assert_eq!(
3015 String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)),3040 String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)),
3016- "edith 20\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\3041+ "edith 21\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
3017 source 2 /elsewhere/b.mp4\n\3042 source 2 /elsewhere/b.mp4\n\
3018- video 1 0 0 30 0 0 - - fit 1000 0 0 0 -\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 -\n\3043+ video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0\n\
3019- audio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n"3044+ audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n"
3020 );3045 );
3021 // An empty lane's line is still the whole of that lane, eq or no eq.3046 // An empty lane's line is still the whole of that lane, eq or no eq.
3022 let empty = parse(3047 let empty = parse(
@@ -3066,10 +3091,10 @@ mod tests {
3066 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);3091 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);
3067 assert_eq!(3092 assert_eq!(
3068 String::from_utf8_lossy(&v5),3093 String::from_utf8_lossy(&v5),
3069- "edith 20\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\3094+ "edith 21\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
3070 source 0 /elsewhere/b.mp4\n\3095 source 0 /elsewhere/b.mp4\n\
3071- video 1 0 0 30 0 0 - - fit 1000 0 0 0 -\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 -\n\3096+ video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0\n\
3072- audio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n",3097+ audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n",
3073 "a re-saved v2 project differs only by its version, the lane \3098 "a re-saved v2 project differs only by its version, the lane \
3074 numbers, the streams it always meant and an equalizer it has none of"3099 numbers, the streams it always meant and an equalizer it has none of"
3075 );3100 );
@@ -3098,7 +3123,7 @@ mod tests {
3098 // Saved again it is the current version, which round-trips to the3123 // Saved again it is the current version, which round-trips to the
3099 // same document.3124 // same document.
3100 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);3125 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);
3101- assert!(v5.starts_with(b"edith 20\n"));3126+ assert!(v5.starts_with(b"edith 21\n"));
3102 let again = parse(&v5, &dir).expect("v5 parses");3127 let again = parse(&v5, &dir).expect("v5 parses");
3103 assert_eq!(again.lanes, back.lanes);3128 assert_eq!(again.lanes, back.lanes);
3104 // A dialect may not be mixed: lane lines under v1, `clip` under v2.3129 // A dialect may not be mixed: lane lines under v1, `clip` under v2.
@@ -3209,8 +3234,8 @@ mod tests {
3209 let bytes = std::fs::read(&path).expect("read back");3234 let bytes = std::fs::read(&path).expect("read back");
3210 assert_eq!(3235 assert_eq!(
3211 String::from_utf8_lossy(&bytes),3236 String::from_utf8_lossy(&bytes),
3212- "edith 20\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\3237+ "edith 21\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\
3213- video 1 0 0 30 0 - - - fit 1000 0 0 0 -\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 -\n"3238+ video 1 0 0 30 0 - - - fit 1000 0 0 0 - 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0\n"
3214 );3239 );
3215 // Loading rejoins the *given* directory, so the file is reached by the3240 // Loading rejoins the *given* directory, so the file is reached by the
3216 // way the project was opened -- the same file, through the link, still3241 // way the project was opened -- the same file, through the link, still
@@ -3254,10 +3279,10 @@ mod tests {
3254 #[test]3279 #[test]
3255 fn a_wrong_first_line_is_refused_by_name() {3280 fn a_wrong_first_line_is_refused_by_name() {
3256 let dir = PathBuf::from("/proj");3281 let dir = PathBuf::from("/proj");
3257- let err = parse(b"edith 21\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir)3282+ let err = parse(b"edith 22\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir)
3258 .unwrap_err()3283 .unwrap_err()
3259 .to_string();3284 .to_string();
3260- assert_eq!(err, "line 1: unsupported version 21");3285+ assert_eq!(err, "line 1: unsupported version 22");
3261 for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] {3286 for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] {
3262 assert_eq!(3287 assert_eq!(
3263 parse(junk, &dir).unwrap_err().to_string(),3288 parse(junk, &dir).unwrap_err().to_string(),
crates/engine/src/export.rsmodified+12 -3
@@ -2760,7 +2760,8 @@ fn run(
2760 let want = untouched.then(|| encoder.dma_want(meta)).flatten();2760 let want = untouched.then(|| encoder.dma_want(meta)).flatten();
2761 // Opened at the file's own frame, which is the only place the2761 // Opened at the file's own frame, which is the only place the
2762 // file's numbering is used -- the span's are the timeline's.2762 // file's numbering is used -- the span's are the timeline's.
2763- let pictures = if crate::is_audio(&entry.path) {2763+ let flags = project.composite_visualizer_at(span.start);
2764+ let pictures = if crate::is_audio(&entry.path) || flags & 1 != 0 {
2764 ClipDecoder::visualizer(2765 ClipDecoder::visualizer(
2765 &entry.path,2766 &entry.path,
2766 entry.audio_stream,2767 entry.audio_stream,
@@ -2768,6 +2769,7 @@ fn run(
2768 meta.width,2769 meta.width,
2769 meta.height,2770 meta.height,
2770 meta.frame_rate,2771 meta.frame_rate,
2772+ flags,
2771 )?2773 )?
2772 } else {2774 } else {
2773 ClipDecoder::open(&entry.path, rate.source_at(in_frame), want)?2775 ClipDecoder::open(&entry.path, rate.source_at(in_frame), want)?
@@ -2826,7 +2828,9 @@ fn run(
2826 Ok(Dissolve {2828 Ok(Dissolve {
2827 window,2829 window,
2828 tail_start: span.len - window,2830 tail_start: span.len - window,
2829- decoder: if crate::is_audio(&entry.path) {2831+ decoder: if crate::is_audio(&entry.path)
2832+ || project.composite_visualizer_at(b_start) & 1 != 0
2833+ {
2830 ClipDecoder::visualizer(2834 ClipDecoder::visualizer(
2831 &entry.path,2835 &entry.path,
2832 entry.audio_stream,2836 entry.audio_stream,
@@ -2834,6 +2838,7 @@ fn run(
2834 meta.width,2838 meta.width,
2835 meta.height,2839 meta.height,
2836 meta.frame_rate,2840 meta.frame_rate,
2841+ project.composite_visualizer_at(b_start),
2837 )?2842 )?
2838 } else {2843 } else {
2839 ClipDecoder::open(&entry.path, b_rate.source_at(b_in_frame), None)?2844 ClipDecoder::open(&entry.path, b_rate.source_at(b_in_frame), None)?
@@ -4418,6 +4423,7 @@ enum ClipDecoder {
4418 height: u32,4423 height: u32,
4419 fps: f64,4424 fps: f64,
4420 next: u32,4425 next: u32,
4426+ flags: u8,
4421 y: Vec<u8>,4427 y: Vec<u8>,
4422 u: Vec<u8>,4428 u: Vec<u8>,
4423 v: Vec<u8>,4429 v: Vec<u8>,
@@ -4530,6 +4536,7 @@ impl ClipDecoder {
4530 width: u32,4536 width: u32,
4531 height: u32,4537 height: u32,
4532 fps: f64,4538 fps: f64,
4539+ flags: u8,
4533 ) -> crate::Result<Self> {4540 ) -> crate::Result<Self> {
4534 let peaks = crate::waveform::peaks(path, stream, crate::decode::VIZ_BUCKETS_PER_SEC)4541 let peaks = crate::waveform::peaks(path, stream, crate::decode::VIZ_BUCKETS_PER_SEC)
4535 .ok()4542 .ok()
@@ -4542,6 +4549,7 @@ impl ClipDecoder {
4542 height,4549 height,
4543 fps,4550 fps,
4544 next: start_frame,4551 next: start_frame,
4552+ flags,
4545 y: Vec::new(),4553 y: Vec::new(),
4546 u: Vec::new(),4554 u: Vec::new(),
4547 v: Vec::new(),4555 v: Vec::new(),
@@ -4562,12 +4570,13 @@ impl ClipDecoder {
4562 height,4570 height,
4563 fps,4571 fps,
4564 next,4572 next,
4573+ flags,
4565 y,4574 y,
4566 u,4575 u,
4567 v,4576 v,
4568 } => {4577 } => {
4569 let (yy, uu, vv) =4578 let (yy, uu, vv) =
4570- crate::decode::visualizer_i420(peaks, f64::from(*next) / *fps, *width, *height);4579+ crate::decode::visualizer_i420(peaks, f64::from(*next) / *fps, *width, *height, *flags);
4571 *y = yy;4580 *y = yy;
4572 *u = uu;4581 *u = uu;
4573 *v = vv;4582 *v = vv;
crates/engine/src/playback.rsmodified+14 -8
@@ -707,6 +707,7 @@ impl PlaybackSession {
707 fade_in: 0,707 fade_in: 0,
708 fade_out: 0,708 fade_out: 0,
709 transition_out: 0,709 transition_out: 0,
710+ visualizer: 0,
710 start: 0,711 start: 0,
711 in_frame: 0,712 in_frame: 0,
712 out_frame: meta.frame_count,713 out_frame: meta.frame_count,
@@ -797,6 +798,7 @@ impl PlaybackSession {
797 fade_in: 0,798 fade_in: 0,
798 fade_out: 0,799 fade_out: 0,
799 transition_out: 0,800 transition_out: 0,
801+ visualizer: 0,
800 start: 0,802 start: 0,
801 in_frame: 0,803 in_frame: 0,
802 out_frame: place_frames(meta.frame_count, IMAGE_ONLY_RATE),804 out_frame: place_frames(meta.frame_count, IMAGE_ONLY_RATE),
@@ -1835,7 +1837,9 @@ impl PlaybackSession {
1835 start,1837 start,
1836 from: Some((source, in_frame)),1838 from: Some((source, in_frame)),
1837 ..1839 ..
1838- }) if crate::is_audio(&self.project.sources()[source].path) => {1840+ }) if crate::is_audio(&self.project.sources()[source].path)
1841+ || self.project.composite_visualizer_at(start) & 1 != 0 =>
1842+ {
1839 let (path, stream) = {1843 let (path, stream) = {
1840 let src = &self.project.sources()[source];1844 let src = &self.project.sources()[source];
1841 (src.path.clone(), src.audio_stream)1845 (src.path.clone(), src.audio_stream)
@@ -1859,6 +1863,7 @@ impl PlaybackSession {
1859 self.meta.height,1863 self.meta.height,
1860 self.project.composite_fit_at(start),1864 self.project.composite_fit_at(start),
1861 ),1865 ),
1866+ self.project.composite_visualizer_at(start),
1862 )1867 )
1863 .inspect_err(|e| {1868 .inspect_err(|e| {
1864 eprintln!("timeline frame {start}: visualizer open failed: {e}")1869 eprintln!("timeline frame {start}: visualizer open failed: {e}")
@@ -2970,6 +2975,12 @@ impl PlaybackSession {
2970 self.edit(Dirty::Picture, |p| p.set_fit(lane, idx, fit))2975 self.edit(Dirty::Picture, |p| p.set_fit(lane, idx, fit))
2971 }2976 }
2972 2977
2978+ /// Waveform flags on a visualizer clip. Reseeks like a grade: the
2979+ /// painter reads them on the next picture.
2980+ pub fn set_visualizer(&mut self, lane: Lane, idx: usize, flags: u8) -> bool {
2981+ self.edit(Dirty::Picture, |p| p.set_visualizer(lane, idx, flags))
2982+ }
2983+
2973 /// Timeline frames of ramp-up from silence at the start of the clip at2984 /// Timeline frames of ramp-up from silence at the start of the clip at
2974 /// `idx` of `lane`. `0` for an index that is not there.2985 /// `idx` of `lane`. `0` for an index that is not there.
2975 pub fn fade_in_of(&self, lane: Lane, idx: usize) -> u32 {2986 pub fn fade_in_of(&self, lane: Lane, idx: usize) -> u32 {
@@ -3101,6 +3112,7 @@ impl PlaybackSession {
3101 fade_in: 0,3112 fade_in: 0,
3102 fade_out: 0,3113 fade_out: 0,
3103 transition_out: 0,3114 transition_out: 0,
3115+ visualizer: 0,
3104 start: 0,3116 start: 0,
3105 in_frame: 0,3117 in_frame: 0,
3106 out_frame: match image {3118 out_frame: match image {
@@ -3270,13 +3282,6 @@ impl PlaybackSession {
3270 out_frame: u32,3282 out_frame: u32,
3271 onto: Option<Lane>,3283 onto: Option<Lane>,
3272 ) -> crate::Result<bool> {3284 ) -> crate::Result<bool> {
3273- if !crate::is_audio(path) {
3274- return Err(format!(
3275- "{} is not audio: a visualizer needs a sound file",
3276- path.display()
3277- )
3278- .into());
3279- }
3280 if out_frame <= in_frame {3285 if out_frame <= in_frame {
3281 return Err("visualizer clip is empty".into());3286 return Err("visualizer clip is empty".into());
3282 }3287 }
@@ -3301,6 +3306,7 @@ impl PlaybackSession {
3301 fade_in: 0,3306 fade_in: 0,
3302 fade_out: 0,3307 fade_out: 0,
3303 transition_out: 0,3308 transition_out: 0,
3309+ visualizer: 1,
3304 start: 0,3310 start: 0,
3305 in_frame,3311 in_frame,
3306 out_frame,3312 out_frame,
crates/engine/src/project.rsmodified+35 -0
@@ -456,6 +456,11 @@ pub struct Clip {
456 /// trusting this field alone, exactly as a stored fade is trusted only456 /// trusting this field alone, exactly as a stored fade is trusted only
457 /// because a clip's own length is checked beside it.457 /// because a clip's own length is checked beside it.
458 pub transition_out: u32,458 pub transition_out: u32,
459+ /// Non-zero: this clip is a waveform of its source's sound, painted
460+ /// onto a video lane. Bit 0 is the flag itself; 1 outline, 2 smooth,
461+ /// 3 fast window, 4 tint. Zero is an ordinary picture. Older project
462+ /// files have no field and mean zero.
463+ pub visualizer: u8,
459 }464 }
460 465
461 impl Clip {466 impl Clip {
@@ -941,6 +946,7 @@ impl Project {
941 fade_in: 0,946 fade_in: 0,
942 fade_out: 0,947 fade_out: 0,
943 transition_out: 0,948 transition_out: 0,
949+ visualizer: 0,
944 start: 0,950 start: 0,
945 in_frame: 0,951 in_frame: 0,
946 out_frame: frame_count.max(1),952 out_frame: frame_count.max(1),
@@ -1340,6 +1346,7 @@ impl Project {
1340 fade_in: 0,1346 fade_in: 0,
1341 fade_out: 0,1347 fade_out: 0,
1342 transition_out: 0,1348 transition_out: 0,
1349+ visualizer: 0,
1343 start,1350 start,
1344 in_frame: 0,1351 in_frame: 0,
1345 out_frame: frame_count.max(1),1352 out_frame: frame_count.max(1),
@@ -2628,6 +2635,18 @@ impl Project {
2628 true2635 true
2629 }2636 }
2630 2637
2638+ /// Waveform style flags on the clip at `idx` of `lane`. Bit 0 marks it
2639+ /// a visualizer; the rest are outline/smooth/fast/tint. `false` (no
2640+ /// history) for an index that is not there.
2641+ pub fn set_visualizer(&mut self, lane: Lane, idx: usize, flags: u8) -> bool {
2642+ if idx >= self.lane(lane).len() {
2643+ return false;
2644+ }
2645+ self.snapshot();
2646+ self.lane_mut(lane).expect("checked above")[idx].visualizer = flags;
2647+ true
2648+ }
2649+
2631 /// Timeline frames of ramp-up from silence at the start of the clip at2650 /// Timeline frames of ramp-up from silence at the start of the clip at
2632 /// `idx` of `lane`. `0` for an index that is not there, same as a clip2651 /// `idx` of `lane`. `0` for an index that is not there, same as a clip
2633 /// that has none.2652 /// that has none.
@@ -3007,6 +3026,14 @@ impl Project {
3007 .map_or(FitPolicy::default(), |(lane, idx)| self.fit_of(lane, idx))3026 .map_or(FitPolicy::default(), |(lane, idx)| self.fit_of(lane, idx))
3008 }3027 }
3009 3028
3029+ /// Waveform flags of the topmost video clip at `timeline_frame`, or 0
3030+ /// over a gap / a picture that is not a visualizer.
3031+ pub fn composite_visualizer_at(&self, timeline_frame: u32) -> u8 {
3032+ self.composite_clip_at(timeline_frame)
3033+ .map(|(lane, idx)| self.lane(lane)[idx].visualizer)
3034+ .unwrap_or(0)
3035+ }
3036+
3010 /// [`spans_from`](Project::spans_from) over the composite: every stretch the3037 /// [`spans_from`](Project::spans_from) over the composite: every stretch the
3011 /// viewer sees from `timeline_frame` to the end, in order. What an export3038 /// viewer sees from `timeline_frame` to the end, in order. What an export
3012 /// encodes and what playback walks at a clip boundary.3039 /// encodes and what playback walks at a clip boundary.
@@ -5683,6 +5710,7 @@ mod tests {
5683 fade_in: 0,5710 fade_in: 0,
5684 fade_out: 0,5711 fade_out: 0,
5685 transition_out: 0,5712 transition_out: 0,
5713+ visualizer: 0,
5686 start,5714 start,
5687 in_frame,5715 in_frame,
5688 out_frame,5716 out_frame,
@@ -7193,6 +7221,7 @@ mod tests {
7193 fade_in: 0,7221 fade_in: 0,
7194 fade_out: 0,7222 fade_out: 0,
7195 transition_out: 0,7223 transition_out: 0,
7224+ visualizer: 0,
7196 start: 0,7225 start: 0,
7197 in_frame: 100,7226 in_frame: 100,
7198 out_frame: 102,7227 out_frame: 102,
@@ -7269,6 +7298,7 @@ mod tests {
7269 fade_in: 0,7298 fade_in: 0,
7270 fade_out: 0,7299 fade_out: 0,
7271 transition_out: 0,7300 transition_out: 0,
7301+ visualizer: 0,
7272 source: wav,7302 source: wav,
7273 ..PASTED7303 ..PASTED
7274 };7304 };
@@ -7983,6 +8013,7 @@ mod tests {
7983 fade_in: 0,8013 fade_in: 0,
7984 fade_out: 0,8014 fade_out: 0,
7985 transition_out: 0,8015 transition_out: 0,
8016+ visualizer: 0,
7986 start,8017 start,
7987 in_frame,8018 in_frame,
7988 out_frame,8019 out_frame,
@@ -9091,6 +9122,7 @@ mod tests {
9091 fade_in: 0,9122 fade_in: 0,
9092 fade_out: 0,9123 fade_out: 0,
9093 transition_out: 0,9124 transition_out: 0,
9125+ visualizer: 0,
9094 eq: Some(i),9126 eq: Some(i),
9095 ..video[0]9127 ..video[0]
9096 }]9128 }]
@@ -9133,6 +9165,7 @@ mod tests {
9133 fade_in: 0,9165 fade_in: 0,
9134 fade_out: 0,9166 fade_out: 0,
9135 transition_out: 0,9167 transition_out: 0,
9168+ visualizer: 0,
9136 color: Some(i),9169 color: Some(i),
9137 fit: FitPolicy::default(),9170 fit: FitPolicy::default(),
9138 speed: Speed::NORMAL,9171 speed: Speed::NORMAL,
@@ -9197,6 +9230,7 @@ mod tests {
9197 fade_in: 0,9230 fade_in: 0,
9198 fade_out: 0,9231 fade_out: 0,
9199 transition_out: 0,9232 transition_out: 0,
9233+ visualizer: 0,
9200 start,9234 start,
9201 in_frame,9235 in_frame,
9202 out_frame,9236 out_frame,
@@ -9995,6 +10029,7 @@ mod tests {
9995 fade_in: 0,10029 fade_in: 0,
9996 fade_out: 0,10030 fade_out: 0,
9997 transition_out: 0,10031 transition_out: 0,
10032+ visualizer: 0,
9998 start,10033 start,
9999 in_frame: start,10034 in_frame: start,
10000 out_frame: end,10035 out_frame: end,
crates/engine/src/proxy.rsmodified+1 -0
@@ -559,6 +559,7 @@ fn started(
559 fade_in: 0,559 fade_in: 0,
560 fade_out: 0,560 fade_out: 0,
561 transition_out: 0,561 transition_out: 0,
562+ visualizer: 0,
562 start: 0,563 start: 0,
563 in_frame: 0,564 in_frame: 0,
564 out_frame: meta.frame_count.max(1),565 out_frame: meta.frame_count.max(1),
crates/engine/src/silence.rsmodified+1 -0
@@ -322,6 +322,7 @@ mod tests {
322 fade_in: 0,322 fade_in: 0,
323 fade_out: 0,323 fade_out: 0,
324 transition_out: 0,324 transition_out: 0,
325+ visualizer: 0,
325 start,326 start,
326 in_frame,327 in_frame,
327 out_frame,328 out_frame,
crates/engine/src/sweep.rsmodified+1 -0
@@ -69,6 +69,7 @@ fn clip(start: u32, in_frame: u32, out_frame: u32) -> Clip {
69 fade_in: 0,69 fade_in: 0,
70 fade_out: 0,70 fade_out: 0,
71 transition_out: 0,71 transition_out: 0,
72+ visualizer: 0,
72 start,73 start,
73 in_frame,74 in_frame,
74 out_frame,75 out_frame,
crates/engine/tests/audio_export.rsmodified+11 -0
@@ -64,6 +64,7 @@ fn mixed_project() -> Project {
64 fade_in: 0,64 fade_in: 0,
65 fade_out: 0,65 fade_out: 0,
66 transition_out: 0,66 transition_out: 0,
67+ visualizer: 0,
67 start,68 start,
68 in_frame: 0,69 in_frame: 0,
69 out_frame: 30,70 out_frame: 30,
@@ -90,6 +91,7 @@ fn mixed_project() -> Project {
90 fade_in: 0,91 fade_in: 0,
91 fade_out: 0,92 fade_out: 0,
92 transition_out: 0,93 transition_out: 0,
94+ visualizer: 0,
93 start: 0,95 start: 0,
94 in_frame: 0,96 in_frame: 0,
95 out_frame: 90,97 out_frame: 90,
@@ -339,6 +341,7 @@ fn a_still_and_a_song_export_as_an_mp4_with_sound() {
339 fade_in: 0,341 fade_in: 0,
340 fade_out: 0,342 fade_out: 0,
341 transition_out: 0,343 transition_out: 0,
344+ visualizer: 0,
342 start: 0,345 start: 0,
343 in_frame: 0,346 in_frame: 0,
344 out_frame: frames,347 out_frame: frames,
@@ -408,6 +411,7 @@ fn a_fader_is_one_tracks_own_and_the_limiter_holds_the_sum() {
408 fade_in: 0,411 fade_in: 0,
409 fade_out: 0,412 fade_out: 0,
410 transition_out: 0,413 transition_out: 0,
414+ visualizer: 0,
411 start: 0,415 start: 0,
412 in_frame: 0,416 in_frame: 0,
413 out_frame: 30,417 out_frame: 30,
@@ -649,6 +653,7 @@ fn the_sound_is_written_at_the_rate_that_was_asked_for() {
649 fade_in: 0,653 fade_in: 0,
650 fade_out: 0,654 fade_out: 0,
651 transition_out: 0,655 transition_out: 0,
656+ visualizer: 0,
652 start: 0,657 start: 0,
653 in_frame: 0,658 in_frame: 0,
654 out_frame: 60,659 out_frame: 60,
@@ -667,6 +672,7 @@ fn the_sound_is_written_at_the_rate_that_was_asked_for() {
667 fade_in: 0,672 fade_in: 0,
668 fade_out: 0,673 fade_out: 0,
669 transition_out: 0,674 transition_out: 0,
675+ visualizer: 0,
670 start: 0,676 start: 0,
671 in_frame: 0,677 in_frame: 0,
672 out_frame: 60,678 out_frame: 60,
@@ -727,6 +733,7 @@ fn a_silent_clip_exports_as_silence_over_its_own_span() {
727 fade_in: 0,733 fade_in: 0,
728 fade_out: 0,734 fade_out: 0,
729 transition_out: 0,735 transition_out: 0,
736+ visualizer: 0,
730 start,737 start,
731 in_frame: 0,738 in_frame: 0,
732 out_frame: 30,739 out_frame: 30,
@@ -824,6 +831,7 @@ fn a_51_ac3_source_round_trips_through_a_wav() {
824 fade_in: 0,831 fade_in: 0,
825 fade_out: 0,832 fade_out: 0,
826 transition_out: 0,833 transition_out: 0,
834+ visualizer: 0,
827 start: 0,835 start: 0,
828 in_frame: 0,836 in_frame: 0,
829 out_frame: 30,837 out_frame: 30,
@@ -957,6 +965,7 @@ fn a_fade_in_reaches_the_exported_audio() {
957 fade_in: 45, // 1.5 s at 30 fps965 fade_in: 45, // 1.5 s at 30 fps
958 fade_out: 0,966 fade_out: 0,
959 transition_out: 0,967 transition_out: 0,
968+ visualizer: 0,
960 start: 0,969 start: 0,
961 in_frame: 0,970 in_frame: 0,
962 out_frame: 90, // 3.0 s at 30 fps971 out_frame: 90, // 3.0 s at 30 fps
@@ -1042,6 +1051,7 @@ fn a_split_and_crossfaded_clip_has_no_muted_interior() {
1042 fade_in: 0,1051 fade_in: 0,
1043 fade_out: 0,1052 fade_out: 0,
1044 transition_out: 0,1053 transition_out: 0,
1054+ visualizer: 0,
1045 start,1055 start,
1046 in_frame,1056 in_frame,
1047 out_frame,1057 out_frame,
@@ -1148,6 +1158,7 @@ fn a_mono_timeline_exports_as_dual_mono_ogg() {
1148 fade_in: 0,1158 fade_in: 0,
1149 fade_out: 0,1159 fade_out: 0,
1150 transition_out: 0,1160 transition_out: 0,
1161+ visualizer: 0,
1151 start: 0,1162 start: 0,
1152 in_frame: 0,1163 in_frame: 0,
1153 out_frame: 30,1164 out_frame: 30,
crates/engine/tests/audio_files.rsmodified+44 -0
@@ -420,6 +420,7 @@ fn a_silent_first_source_does_not_stop_the_scan_for_one_with_sound() {
420 fade_in: 0,420 fade_in: 0,
421 fade_out: 0,421 fade_out: 0,
422 transition_out: 0,422 transition_out: 0,
423+ visualizer: 0,
423 start: 0,424 start: 0,
424 in_frame: 0,425 in_frame: 0,
425 out_frame: meta1.frame_count,426 out_frame: meta1.frame_count,
@@ -651,6 +652,7 @@ fn place_visualizer_puts_a_waveform_on_a_video_lane() {
651 );652 );
652 let video = session.lane_clips(Lane::V1);653 let video = session.lane_clips(Lane::V1);
653 assert_eq!(video.len(), 1);654 assert_eq!(video.len(), 1);
655+ assert_eq!(video[0].visualizer & 1, 1, "the clip is marked a waveform");
654 assert_eq!(video[0].source, audio.source);656 assert_eq!(video[0].source, audio.source);
655 assert_eq!(657 assert_eq!(
656 (video[0].in_frame, video[0].out_frame),658 (video[0].in_frame, video[0].out_frame),
@@ -683,11 +685,53 @@ fn place_visualizer_puts_a_waveform_on_a_video_lane() {
683 drop(session);685 drop(session);
684 let reloaded = PlaybackSession::open_project(&project).expect("reload visualizer project");686 let reloaded = PlaybackSession::open_project(&project).expect("reload visualizer project");
685 assert_eq!(reloaded.lane_clips(Lane::V1).len(), 1);687 assert_eq!(reloaded.lane_clips(Lane::V1).len(), 1);
688+ assert_eq!(reloaded.lane_clips(Lane::V1)[0].visualizer & 1, 1);
686 assert_eq!(reloaded.lane_clips(Lane::A1).len(), 1);689 assert_eq!(reloaded.lane_clips(Lane::A1).len(), 1);
687 drop(reloaded);690 drop(reloaded);
688 let _ = std::fs::remove_dir_all(&dir);691 let _ = std::fs::remove_dir_all(&dir);
689 }692 }
690 693
694+#[test]
695+fn place_visualizer_paints_a_video_file_soundtrack() {
696+ let dir = Scratch::dir("ve_av_viz");
697+ let film = {
698+ let to = dir.join("test_av.mp4");
699+ std::fs::copy(asset("test_av.mp4"), &to).expect("copy");
700+ to
701+ };
702+ let mut session = open(&film);
703+ let picture = session.lane_clips(Lane::V1)[0];
704+ let before = session.lane_clips(Lane::V1).len();
705+ assert!(
706+ session
707+ .place_visualizer(picture.end(), &film, 0, picture.in_frame, picture.out_frame, None)
708+ .expect("place visualizer of a film"),
709+ "placed"
710+ );
711+ let video = session.lane_clips(Lane::V1);
712+ assert_eq!(video.len(), before + 1);
713+ let viz = *video.last().unwrap();
714+ assert_eq!(viz.visualizer & 1, 1);
715+ assert_eq!((viz.in_frame, viz.out_frame), (picture.in_frame, picture.out_frame));
716+ session.seek(f64::from(viz.start) / 30.0 + 0.5);
717+ let deadline = std::time::Instant::now() + std::time::Duration::from_secs(15);
718+ let mut saw = false;
719+ let mut frames = 0u32;
720+ while std::time::Instant::now() < deadline && frames < 45 {
721+ if let Some(frame) = session.try_frame() {
722+ frames += 1;
723+ if frame.bgra.chunks_exact(4).any(|p| p[0] > 32 || p[1] > 32 || p[2] > 32) {
724+ saw = true;
725+ break;
726+ }
727+ } else {
728+ std::thread::sleep(std::time::Duration::from_millis(10));
729+ }
730+ }
731+ assert!(saw, "film soundtrack visualizer stayed black after {frames} pictures");
732+ let _ = std::fs::remove_dir_all(&dir);
733+}
734+
691 /// ...and the door the editor itself had onto that same broken project: a copy735 /// ...and the door the editor itself had onto that same broken project: a copy
692 /// of the song pasted from the clipboard used to land on `V1` as well as `A1`,736 /// of the song pasted from the clipboard used to land on `V1` as well as `A1`,
693 /// where it decodes to nothing -- and the save it wrote was refused on the way737 /// where it decodes to nothing -- and the save it wrote was refused on the way
crates/engine/tests/eq_audio.rsmodified+1 -0
@@ -57,6 +57,7 @@ fn clip(start: u32, source: usize, frames: u32) -> Clip {
57 fade_in: 0,57 fade_in: 0,
58 fade_out: 0,58 fade_out: 0,
59 transition_out: 0,59 transition_out: 0,
60+ visualizer: 0,
60 start,61 start,
61 in_frame: 0,62 in_frame: 0,
62 out_frame: frames,63 out_frame: frames,
crates/engine/tests/export.rsmodified+2 -0
@@ -240,6 +240,7 @@ fn exports_at_the_project_resolution_with_the_watched_geometry() {
240 fade_in: 0,240 fade_in: 0,
241 fade_out: 0,241 fade_out: 0,
242 transition_out: 0,242 transition_out: 0,
243+ visualizer: 0,
243 start,244 start,
244 in_frame: 0,245 in_frame: 0,
245 out_frame: 10,246 out_frame: 10,
@@ -327,6 +328,7 @@ fn exports_the_audio_stream_the_timeline_plays() {
327 fade_in: 0,328 fade_in: 0,
328 fade_out: 0,329 fade_out: 0,
329 transition_out: 0,330 transition_out: 0,
331+ visualizer: 0,
330 start: 0,332 start: 0,
331 in_frame: 0,333 in_frame: 0,
332 out_frame: meta.frame_count,334 out_frame: meta.frame_count,
crates/engine/tests/lanes.rsmodified+2 -0
@@ -237,6 +237,7 @@ fn the_mp4_copy_follows_the_lane_that_holds_the_sound() {
237 let clip = Clip {237 let clip = Clip {
238 fade_in: 0,238 fade_in: 0,
239 transition_out: 0,239 transition_out: 0,
240+ visualizer: 0,
240 fade_out: 0,241 fade_out: 0,
241 start: 0,242 start: 0,
242 in_frame: 0,243 in_frame: 0,
@@ -304,6 +305,7 @@ fn two_audio_lanes_are_summed() {
304 fade_in: 0,305 fade_in: 0,
305 fade_out: 0,306 fade_out: 0,
306 transition_out: 0,307 transition_out: 0,
308+ visualizer: 0,
307 start: TOP_IN,309 start: TOP_IN,
308 in_frame: TOP_IN,310 in_frame: TOP_IN,
309 out_frame: TOP_OUT,311 out_frame: TOP_OUT,
crates/engine/tests/opus_export.rsmodified+2 -0
@@ -85,6 +85,7 @@ fn project(video: &Path, sound: &Path, sound_in: u32) -> Project {
85 fade_in: 0,85 fade_in: 0,
86 fade_out: 0,86 fade_out: 0,
87 transition_out: 0,87 transition_out: 0,
88+ visualizer: 0,
88 start: 0,89 start: 0,
89 in_frame,90 in_frame,
90 out_frame,91 out_frame,
@@ -469,6 +470,7 @@ fn a_copied_picture_names_the_sound_it_was_written_with() {
469 fade_in: 0,470 fade_in: 0,
470 fade_out: 0,471 fade_out: 0,
471 transition_out: 0,472 transition_out: 0,
473+ visualizer: 0,
472 start: 0,474 start: 0,
473 in_frame: 0,475 in_frame: 0,
474 out_frame,476 out_frame,
crates/engine/tests/silence.rsmodified+2 -0
@@ -141,6 +141,7 @@ fn speed_mode_refuses_a_clip_that_laps_over_a_silence() {
141 fade_in: 0,141 fade_in: 0,
142 fade_out: 0,142 fade_out: 0,
143 transition_out: 0,143 transition_out: 0,
144+ visualizer: 0,
144 start: 0,145 start: 0,
145 in_frame: 0,146 in_frame: 0,
146 out_frame: 20,147 out_frame: 20,
@@ -180,6 +181,7 @@ fn whole(source: usize, frames: u32) -> Clip {
180 fade_in: 0,181 fade_in: 0,
181 fade_out: 0,182 fade_out: 0,
182 transition_out: 0,183 transition_out: 0,
184+ visualizer: 0,
183 start: 0,185 start: 0,
184 in_frame: 0,186 in_frame: 0,
185 out_frame: frames,187 out_frame: frames,