Stable envelope height, full hue/sat, strands and glow
Browse files at this commit7ebfc448b47be34f9de8364967e1cee4a15c244fParent: 92b906f- feat
- stable envelope height, full hue/sat, strands and glow
23 changed files +426 -158
- crates/app/src/player/library.rs +31 -2
- crates/app/src/tests/cards.rs +1 -0
- crates/app/src/tests/editing.rs +4 -0
- crates/app/src/tests/layout.rs +2 -0
- crates/app/src/tests/view.rs +1 -0
- crates/app/src/timeline_math.rs +1 -0
- crates/app/src/ui/dock_stance.rs +159 -90
- crates/engine/examples/bench.rs +1 -0
- crates/engine/src/decode.rs +82 -13
- crates/engine/src/edith.rs +72 -49
- crates/engine/src/export.rs +7 -1
- crates/engine/src/playback.rs +9 -0
- crates/engine/src/project.rs +32 -3
- crates/engine/src/proxy.rs +1 -0
- crates/engine/src/silence.rs +1 -0
- crates/engine/src/sweep.rs +1 -0
- crates/engine/tests/audio_export.rs +11 -0
- crates/engine/tests/audio_files.rs +1 -0
- crates/engine/tests/eq_audio.rs +1 -0
- crates/engine/tests/export.rs +2 -0
- crates/engine/tests/lanes.rs +2 -0
- crates/engine/tests/opus_export.rs +2 -0
- crates/engine/tests/silence.rs +2 -0
crates/app/src/player/library.rsmodified+31 -2
| @@ -223,7 +223,36 @@ impl Player { | |||
| 223 | cx.notify(); | 223 | cx.notify(); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | + pub(crate) fn viz_paint(&self) -> u32 { | ||
| 227 | + self.selected | ||
| 228 | + .anchor() | ||
| 229 | + .and_then(|(lane, idx)| { | ||
| 230 | + self.session | ||
| 231 | + .as_ref()? | ||
| 232 | + .lane_clips(lane) | ||
| 233 | + .get(idx) | ||
| 234 | + .map(|c| c.viz_paint) | ||
| 235 | + }) | ||
| 236 | + .unwrap_or(0) | ||
| 237 | + } | ||
| 238 | + | ||
| 226 | pub(crate) fn set_viz_hue(&mut self, hue: u8, cx: &mut Context<Self>) { | 239 | pub(crate) fn set_viz_hue(&mut self, hue: u8, cx: &mut Context<Self>) { |
| 240 | + self.set_viz_paint_with(cx, |p| engine::decode::with_viz_paint_hue(p, hue)); | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + pub(crate) fn set_viz_sat(&mut self, sat: u8, cx: &mut Context<Self>) { | ||
| 244 | + self.set_viz_paint_with(cx, |p| engine::decode::with_viz_paint_sat(p, sat)); | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + pub(crate) fn set_viz_strands(&mut self, n: u8, cx: &mut Context<Self>) { | ||
| 248 | + self.set_viz_paint_with(cx, |p| engine::decode::with_viz_paint_strands(p, n)); | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + pub(crate) fn set_viz_glow(&mut self, n: u8, cx: &mut Context<Self>) { | ||
| 252 | + self.set_viz_paint_with(cx, |p| engine::decode::with_viz_paint_glow(p, n)); | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + fn set_viz_paint_with(&mut self, cx: &mut Context<Self>, f: impl FnOnce(u32) -> u32) { | ||
| 227 | let Some((lane, idx)) = self.selected.anchor() else { | 256 | let Some((lane, idx)) = self.selected.anchor() else { |
| 228 | return; | 257 | return; |
| 229 | }; | 258 | }; |
| @@ -236,8 +265,8 @@ impl Player { | |||
| 236 | if clip.visualizer & 1 == 0 { | 265 | if clip.visualizer & 1 == 0 { |
| 237 | return; | 266 | return; |
| 238 | } | 267 | } |
| 239 | - let next = engine::decode::with_viz_hue(clip.visualizer, hue); | 268 | + let next = f(clip.viz_paint); |
| 240 | - if next != clip.visualizer && session.set_visualizer(lane, idx, next) { | 269 | + if next != clip.viz_paint && session.set_viz_paint(lane, idx, next) { |
| 241 | self.reset_after_reseek(); | 270 | self.reset_after_reseek(); |
| 242 | } | 271 | } |
| 243 | cx.notify(); | 272 | cx.notify(); |
crates/app/src/tests/cards.rsmodified+1 -0
| @@ -1383,6 +1383,7 @@ fn a_duration_row_shows_only_for_a_transition_and_its_room_is_the_successors() { | |||
| 1383 | fade_out, | 1383 | fade_out, |
| 1384 | transition_out, | 1384 | transition_out, |
| 1385 | visualizer: 0, | 1385 | visualizer: 0, |
| 1386 | + viz_paint: 0, | ||
| 1386 | } | 1387 | } |
| 1387 | } | 1388 | } |
| 1388 | // A plain cut carries neither field, so the row has nothing to show. | 1389 | // A plain cut carries neither field, so the row has nothing to show. |
crates/app/src/tests/editing.rsmodified+4 -0
| @@ -631,6 +631,7 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { | |||
| 631 | fade_out: 0, | 631 | fade_out: 0, |
| 632 | transition_out: 0, | 632 | transition_out: 0, |
| 633 | visualizer: 0, | 633 | visualizer: 0, |
| 634 | + viz_paint: 0, | ||
| 634 | start: 30, | 635 | start: 30, |
| 635 | in_frame: 0, | 636 | in_frame: 0, |
| 636 | out_frame: 60, | 637 | out_frame: 60, |
| @@ -1066,6 +1067,7 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() { | |||
| 1066 | fade_out: 0, | 1067 | fade_out: 0, |
| 1067 | transition_out: 0, | 1068 | transition_out: 0, |
| 1068 | visualizer: 0, | 1069 | visualizer: 0, |
| 1070 | + viz_paint: 0, | ||
| 1069 | start: 30, | 1071 | start: 30, |
| 1070 | in_frame: 0, | 1072 | in_frame: 0, |
| 1071 | out_frame: 60, | 1073 | out_frame: 60, |
| @@ -1798,6 +1800,7 @@ fn a_copied_clip_is_renumbered_or_dropped_when_a_row_leaves_the_library() { | |||
| 1798 | fade_out: 0, | 1800 | fade_out: 0, |
| 1799 | transition_out: 0, | 1801 | transition_out: 0, |
| 1800 | visualizer: 0, | 1802 | visualizer: 0, |
| 1803 | + viz_paint: 0, | ||
| 1801 | start: 0, | 1804 | start: 0, |
| 1802 | in_frame: 0, | 1805 | in_frame: 0, |
| 1803 | out_frame: 30, | 1806 | out_frame: 30, |
| @@ -1951,6 +1954,7 @@ fn trim_to_playhead_needs_a_subject_cut_with_the_playhead_on_it() { | |||
| 1951 | fade_out: 0, | 1954 | fade_out: 0, |
| 1952 | transition_out: 0, | 1955 | transition_out: 0, |
| 1953 | visualizer: 0, | 1956 | visualizer: 0, |
| 1957 | + viz_paint: 0, | ||
| 1954 | start: 100, | 1958 | start: 100, |
| 1955 | in_frame: 0, | 1959 | in_frame: 0, |
| 1956 | out_frame: 60, | 1960 | out_frame: 60, |
crates/app/src/tests/layout.rsmodified+2 -0
| @@ -747,6 +747,7 @@ fn a_drop_moves_the_clip_that_was_picked_up_not_its_old_index() { | |||
| 747 | fade_out: 0, | 747 | fade_out: 0, |
| 748 | transition_out: 0, | 748 | transition_out: 0, |
| 749 | visualizer: 0, | 749 | visualizer: 0, |
| 750 | + viz_paint: 0, | ||
| 750 | start, | 751 | start, |
| 751 | in_frame: 0, | 752 | in_frame: 0, |
| 752 | out_frame: 30, | 753 | out_frame: 30, |
| @@ -3565,6 +3566,7 @@ fn the_cut_readout_counts_from_the_playhead() { | |||
| 3565 | fade_out: 0, | 3566 | fade_out: 0, |
| 3566 | transition_out: 0, | 3567 | transition_out: 0, |
| 3567 | visualizer: 0, | 3568 | visualizer: 0, |
| 3569 | + viz_paint: 0, | ||
| 3568 | start, | 3570 | start, |
| 3569 | in_frame: 0, | 3571 | in_frame: 0, |
| 3570 | out_frame: len, | 3572 | out_frame: len, |
crates/app/src/tests/view.rsmodified+1 -0
| @@ -158,6 +158,7 @@ fn the_marks_are_every_lane_the_playhead_and_the_start() { | |||
| 158 | fade_out: 0, | 158 | fade_out: 0, |
| 159 | transition_out: 0, | 159 | transition_out: 0, |
| 160 | visualizer: 0, | 160 | visualizer: 0, |
| 161 | + viz_paint: 0, | ||
| 161 | start, | 162 | start, |
| 162 | in_frame: 0, | 163 | in_frame: 0, |
| 163 | out_frame: frames, | 164 | out_frame: frames, |
crates/app/src/timeline_math.rsmodified+1 -0
| @@ -889,6 +889,7 @@ mod drop_landing_tests { | |||
| 889 | fade_out: 0, | 889 | fade_out: 0, |
| 890 | transition_out: 0, | 890 | transition_out: 0, |
| 891 | visualizer: 0, | 891 | visualizer: 0, |
| 892 | + viz_paint: 0, | ||
| 892 | start, | 893 | start, |
| 893 | in_frame: 0, | 894 | in_frame: 0, |
| 894 | out_frame: frames, | 895 | out_frame: frames, |
crates/app/src/ui/dock_stance.rsmodified+159 -90
| @@ -189,7 +189,7 @@ fn dock_tab( | |||
| 189 | .children(hitmap::control(id, label_text, true)) | 189 | .children(hitmap::control(id, label_text, true)) |
| 190 | .child( | 190 | .child( |
| 191 | div() | 191 | div() |
| 192 | - .font(style.font) | 192 | + .font(style.font.clone()) |
| 193 | .text_size(style.size) | 193 | .text_size(style.size) |
| 194 | .text_color(rgb(if active { INK1() } else { INK3() })) | 194 | .text_color(rgb(if active { INK1() } else { INK3() })) |
| 195 | .child(label_text), | 195 | .child(label_text), |
| @@ -201,7 +201,7 @@ fn section_head(text: impl Into<SharedString>) -> impl IntoElement { | |||
| 201 | let style = head(); | 201 | let style = head(); |
| 202 | div() | 202 | div() |
| 203 | .flex_none() | 203 | .flex_none() |
| 204 | - .font(style.font) | 204 | + .font(style.font.clone()) |
| 205 | .text_size(style.size) | 205 | .text_size(style.size) |
| 206 | .text_color(rgb(INK3())) | 206 | .text_color(rgb(INK3())) |
| 207 | .child(text.into()) | 207 | .child(text.into()) |
| @@ -449,7 +449,7 @@ fn source_row( | |||
| 449 | // usage moved down to the metadata line. | 449 | // usage moved down to the metadata line. |
| 450 | .min_w(relative(0.6)) | 450 | .min_w(relative(0.6)) |
| 451 | .truncate() | 451 | .truncate() |
| 452 | - .font(style.font) | 452 | + .font(style.font.clone()) |
| 453 | .text_size(style.size) | 453 | .text_size(style.size) |
| 454 | .text_color(rgb(INK1())) | 454 | .text_color(rgb(INK1())) |
| 455 | .child(name) | 455 | .child(name) |
| @@ -526,7 +526,7 @@ fn source_row( | |||
| 526 | div() | 526 | div() |
| 527 | .pl(px(14.)) | 527 | .pl(px(14.)) |
| 528 | .truncate() | 528 | .truncate() |
| 529 | - .font(style.font) | 529 | + .font(style.font.clone()) |
| 530 | .text_size(style.size) | 530 | .text_size(style.size) |
| 531 | .text_color(rgb(INK3())) | 531 | .text_color(rgb(INK3())) |
| 532 | .child(under) | 532 | .child(under) |
| @@ -1022,7 +1022,7 @@ fn sources_tab( | |||
| 1022 | .id("dock-filter") | 1022 | .id("dock-filter") |
| 1023 | .flex_none() | 1023 | .flex_none() |
| 1024 | .cursor_text() | 1024 | .cursor_text() |
| 1025 | - .font(style.font) | 1025 | + .font(style.font.clone()) |
| 1026 | .text_size(style.size) | 1026 | .text_size(style.size) |
| 1027 | .text_color(rgb(if player.dock_filter_edit { | 1027 | .text_color(rgb(if player.dock_filter_edit { |
| 1028 | INK1() | 1028 | INK1() |
| @@ -1059,7 +1059,7 @@ fn sources_tab( | |||
| 1059 | let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); | 1059 | let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); |
| 1060 | d.child( | 1060 | d.child( |
| 1061 | div() | 1061 | div() |
| 1062 | - .font(style.font) | 1062 | + .font(style.font.clone()) |
| 1063 | .text_size(style.size) | 1063 | .text_size(style.size) |
| 1064 | .text_color(rgb(INK3())) | 1064 | .text_color(rgb(INK3())) |
| 1065 | // One noun for both empties -- nothing imported and | 1065 | // One noun for both empties -- nothing imported and |
| @@ -1187,34 +1187,17 @@ 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 is | 1187 | /// these onto. Drag-while-playing and every other gesture on a row is |
| 1188 | /// whatever that card already does; nothing about the gesture is reimplemented | 1188 | /// whatever that card already does; nothing about the gesture is reimplemented |
| 1189 | /// here. | 1189 | /// here. |
| 1190 | -const VIZ_HUE_IDS: [&str; 16] = [ | ||
| 1191 | - "dock-viz-hue-0", | ||
| 1192 | - "dock-viz-hue-1", | ||
| 1193 | - "dock-viz-hue-2", | ||
| 1194 | - "dock-viz-hue-3", | ||
| 1195 | - "dock-viz-hue-4", | ||
| 1196 | - "dock-viz-hue-5", | ||
| 1197 | - "dock-viz-hue-6", | ||
| 1198 | - "dock-viz-hue-7", | ||
| 1199 | - "dock-viz-hue-8", | ||
| 1200 | - "dock-viz-hue-9", | ||
| 1201 | - "dock-viz-hue-10", | ||
| 1202 | - "dock-viz-hue-11", | ||
| 1203 | - "dock-viz-hue-12", | ||
| 1204 | - "dock-viz-hue-13", | ||
| 1205 | - "dock-viz-hue-14", | ||
| 1206 | - "dock-viz-hue-15", | ||
| 1207 | -]; | ||
| 1208 | - | ||
| 1209 | fn viz_style_verbs(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | 1190 | fn viz_style_verbs(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { |
| 1210 | - let flags = player.selected.anchor().and_then(|(lane, idx)| { | 1191 | + let clip = player.selected.anchor().and_then(|(lane, idx)| { |
| 1211 | let session = player.session.as_ref()?; | 1192 | let session = player.session.as_ref()?; |
| 1212 | let clip = session.lane_clips(lane).get(idx)?; | 1193 | let clip = session.lane_clips(lane).get(idx)?; |
| 1213 | - (clip.visualizer & 1 != 0).then_some(clip.visualizer) | 1194 | + (clip.visualizer & 1 != 0).then_some(*clip) |
| 1214 | }); | 1195 | }); |
| 1215 | - let Some(flags) = flags else { | 1196 | + let Some(clip) = clip else { |
| 1216 | return div().id("dock-viz-styles"); | 1197 | return div().id("dock-viz-styles"); |
| 1217 | }; | 1198 | }; |
| 1199 | + let flags = clip.visualizer; | ||
| 1200 | + let paint = clip.viz_paint; | ||
| 1218 | let pick = |id: &'static str, label_text: &'static str, style: u8, on: bool| { | 1201 | let pick = |id: &'static str, label_text: &'static str, style: u8, on: bool| { |
| 1219 | let row = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); | 1202 | let row = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); |
| 1220 | div() | 1203 | div() |
| @@ -1250,7 +1233,7 @@ fn viz_style_verbs(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | |||
| 1250 | .items_center() | 1233 | .items_center() |
| 1251 | .cursor_pointer() | 1234 | .cursor_pointer() |
| 1252 | .text_color(rgb(if on { INK1() } else { INK3() })) | 1235 | .text_color(rgb(if on { INK1() } else { INK3() })) |
| 1253 | - .font(style.font) | 1236 | + .font(style.font.clone()) |
| 1254 | .text_size(style.size) | 1237 | .text_size(style.size) |
| 1255 | .children(hitmap::control(id, label_text, true)) | 1238 | .children(hitmap::control(id, label_text, true)) |
| 1256 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | 1239 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { |
| @@ -1299,82 +1282,168 @@ fn viz_style_verbs(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | |||
| 1299 | engine::decode::VIZ_FAST, | 1282 | engine::decode::VIZ_FAST, |
| 1300 | flags & engine::decode::VIZ_FAST != 0, | 1283 | flags & engine::decode::VIZ_FAST != 0, |
| 1301 | )) | 1284 | )) |
| 1302 | - .child(viz_hue_row(flags, cx)) | 1285 | + .child(viz_paint_knobs(paint, cx)) |
| 1303 | } | 1286 | } |
| 1304 | 1287 | ||
| 1305 | -fn viz_hue_row(flags: u8, cx: &mut Context<Player>) -> impl IntoElement { | 1288 | +fn viz_step( |
| 1306 | - let hue = engine::decode::viz_hue(flags); | 1289 | + id: &'static str, |
| 1307 | - let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); | 1290 | + glyph: &'static str, |
| 1308 | - let step = |id: &'static str, glyph: &'static str, by: i8, cx: &mut Context<Player>| { | 1291 | + cx: &mut Context<Player>, |
| 1309 | - div() | 1292 | + f: impl Fn(&mut Player, &mut Context<Player>) + 'static + Copy, |
| 1310 | - .id(id) | 1293 | +) -> impl IntoElement { |
| 1311 | - .flex() | ||
| 1312 | - .w(px(HIT_MIN)) | ||
| 1313 | - .h(px(HIT_MIN)) | ||
| 1314 | - .items_center() | ||
| 1315 | - .justify_center() | ||
| 1316 | - .rounded(px(3.)) | ||
| 1317 | - .bg(rgb(DARK_RAISED())) | ||
| 1318 | - .cursor_pointer() | ||
| 1319 | - .children(hitmap::control(id, "Colour", true)) | ||
| 1320 | - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | ||
| 1321 | - let cur = this | ||
| 1322 | - .selected | ||
| 1323 | - .anchor() | ||
| 1324 | - .and_then(|(lane, idx)| { | ||
| 1325 | - this.session | ||
| 1326 | - .as_ref()? | ||
| 1327 | - .lane_clips(lane) | ||
| 1328 | - .get(idx) | ||
| 1329 | - .map(|c| engine::decode::viz_hue(c.visualizer)) | ||
| 1330 | - }) | ||
| 1331 | - .unwrap_or(0); | ||
| 1332 | - this.set_viz_hue((cur as i16 + i16::from(by)).rem_euclid(16) as u8, cx); | ||
| 1333 | - })) | ||
| 1334 | - .child(glyph) | ||
| 1335 | - }; | ||
| 1336 | div() | 1294 | div() |
| 1337 | - .id("dock-viz-hue") | 1295 | + .id(id) |
| 1338 | - .flex_none() | ||
| 1339 | .flex() | 1296 | .flex() |
| 1297 | + .w(px(HIT_MIN)) | ||
| 1298 | + .h(px(HIT_MIN)) | ||
| 1340 | .items_center() | 1299 | .items_center() |
| 1300 | + .justify_center() | ||
| 1301 | + .rounded(px(3.)) | ||
| 1302 | + .bg(rgb(DARK_RAISED())) | ||
| 1303 | + .cursor_pointer() | ||
| 1304 | + .children(hitmap::control(id, glyph, true)) | ||
| 1305 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| f(this, cx))) | ||
| 1306 | + .child(glyph) | ||
| 1307 | +} | ||
| 1308 | + | ||
| 1309 | +fn viz_paint_knobs(paint: u32, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 1310 | + let hue = engine::decode::viz_hue_ui(paint); | ||
| 1311 | + let sat = engine::decode::viz_sat_ui(paint); | ||
| 1312 | + let strands = engine::decode::viz_strands_of(paint); | ||
| 1313 | + let glow = engine::decode::viz_glow_of(paint); | ||
| 1314 | + let style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); | ||
| 1315 | + div() | ||
| 1316 | + .flex() | ||
| 1317 | + .flex_col() | ||
| 1341 | .gap(px(4.)) | 1318 | .gap(px(4.)) |
| 1342 | - .h(px(CONTROL_H)) | ||
| 1343 | .px(px(8.)) | 1319 | .px(px(8.)) |
| 1344 | .child( | 1320 | .child( |
| 1345 | div() | 1321 | div() |
| 1346 | - .font(style.font) | 1322 | + .id("dock-viz-hue") |
| 1347 | - .text_size(style.size) | 1323 | + .flex() |
| 1348 | - .text_color(rgb(INK2())) | 1324 | + .items_center() |
| 1349 | - .child("Colour"), | 1325 | + .gap(px(4.)) |
| 1326 | + .h(px(CONTROL_H)) | ||
| 1327 | + .child( | ||
| 1328 | + div() | ||
| 1329 | + .font(style.font.clone()) | ||
| 1330 | + .text_size(style.size) | ||
| 1331 | + .text_color(rgb(INK2())) | ||
| 1332 | + .child("Colour"), | ||
| 1333 | + ) | ||
| 1334 | + .child(viz_step("dock-viz-hue-minus", "−", cx, |this, cx| { | ||
| 1335 | + this.set_viz_hue(engine::decode::viz_hue_ui(this.viz_paint()).wrapping_sub(4), cx); | ||
| 1336 | + })) | ||
| 1337 | + .child( | ||
| 1338 | + div() | ||
| 1339 | + .id("dock-viz-hue-bar") | ||
| 1340 | + .flex_1() | ||
| 1341 | + .flex() | ||
| 1342 | + .h(px(14.)) | ||
| 1343 | + .children((0u8..64).map(|i| { | ||
| 1344 | + let h = i.saturating_mul(4); | ||
| 1345 | + let (r, g, b) = engine::decode::viz_ink_from_paint( | ||
| 1346 | + engine::decode::with_viz_paint_hue(paint, h), | ||
| 1347 | + ); | ||
| 1348 | + let color = (u32::from(r) << 16) | (u32::from(g) << 8) | u32::from(b); | ||
| 1349 | + div() | ||
| 1350 | + .id(("dock-viz-hue", u64::from(i))) | ||
| 1351 | + .flex_1() | ||
| 1352 | + .h_full() | ||
| 1353 | + .bg(rgb(color)) | ||
| 1354 | + .when(hue.abs_diff(h) < 3, |d| d.border_1().border_color(rgb(INK1()))) | ||
| 1355 | + .cursor_pointer() | ||
| 1356 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | ||
| 1357 | + this.set_viz_hue(h, cx); | ||
| 1358 | + })) | ||
| 1359 | + .into_any_element() | ||
| 1360 | + })), | ||
| 1361 | + ) | ||
| 1362 | + .child(viz_step("dock-viz-hue-plus", "+", cx, |this, cx| { | ||
| 1363 | + this.set_viz_hue(engine::decode::viz_hue_ui(this.viz_paint()).wrapping_add(4), cx); | ||
| 1364 | + })), | ||
| 1350 | ) | 1365 | ) |
| 1351 | - .child(step("dock-viz-hue-minus", "−", -1, cx)) | ||
| 1352 | .child( | 1366 | .child( |
| 1353 | div() | 1367 | div() |
| 1354 | - .id("dock-viz-hue-swatches") | ||
| 1355 | - .flex_1() | ||
| 1356 | .flex() | 1368 | .flex() |
| 1357 | - .gap(px(2.)) | 1369 | + .items_center() |
| 1358 | - .children((0u8..16).map(|i| { | 1370 | + .gap(px(4.)) |
| 1359 | - let (r, g, b) = engine::decode::viz_ink_rgb(i); | 1371 | + .h(px(CONTROL_H)) |
| 1360 | - let color = (u32::from(r) << 16) | (u32::from(g) << 8) | u32::from(b); | 1372 | + .child( |
| 1361 | div() | 1373 | div() |
| 1362 | - .id(("dock-viz-hue", u64::from(i))) | 1374 | + .font(style.font.clone()) |
| 1363 | - .flex_1() | 1375 | + .text_size(style.size) |
| 1364 | - .h(px(14.)) | 1376 | + .text_color(rgb(INK2())) |
| 1365 | - .min_w(px(8.)) | 1377 | + .child("Sat"), |
| 1366 | - .rounded(px(2.)) | 1378 | + ) |
| 1367 | - .bg(rgb(color)) | 1379 | + .child(viz_step("dock-viz-sat-minus", "−", cx, |this, cx| { |
| 1368 | - .when(i == hue, |d| d.border_1().border_color(rgb(INK1()))) | 1380 | + this.set_viz_sat(engine::decode::viz_sat_ui(this.viz_paint()).saturating_sub(16), cx); |
| 1369 | - .cursor_pointer() | 1381 | + })) |
| 1370 | - .children(hitmap::control(VIZ_HUE_IDS[i as usize], "Colour", true)) | 1382 | + .child( |
| 1371 | - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | 1383 | + div() |
| 1372 | - this.set_viz_hue(i, cx); | 1384 | + .font(style.font.clone()) |
| 1373 | - })) | 1385 | + .text_size(style.size) |
| 1374 | - .into_any_element() | 1386 | + .text_color(rgb(INK1())) |
| 1387 | + .child(format!("{sat}")), | ||
| 1388 | + ) | ||
| 1389 | + .child(viz_step("dock-viz-sat-plus", "+", cx, |this, cx| { | ||
| 1390 | + this.set_viz_sat(engine::decode::viz_sat_ui(this.viz_paint()).saturating_add(16).min(255), cx); | ||
| 1391 | + })), | ||
| 1392 | + ) | ||
| 1393 | + .child( | ||
| 1394 | + div() | ||
| 1395 | + .flex() | ||
| 1396 | + .items_center() | ||
| 1397 | + .gap(px(4.)) | ||
| 1398 | + .h(px(CONTROL_H)) | ||
| 1399 | + .child( | ||
| 1400 | + div() | ||
| 1401 | + .font(style.font.clone()) | ||
| 1402 | + .text_size(style.size) | ||
| 1403 | + .text_color(rgb(INK2())) | ||
| 1404 | + .child("Strands"), | ||
| 1405 | + ) | ||
| 1406 | + .child(viz_step("dock-viz-strands-minus", "−", cx, |this, cx| { | ||
| 1407 | + this.set_viz_strands(engine::decode::viz_strands_of(this.viz_paint()).saturating_sub(1).max(1), cx); | ||
| 1408 | + })) | ||
| 1409 | + .child( | ||
| 1410 | + div() | ||
| 1411 | + .font(style.font.clone()) | ||
| 1412 | + .text_size(style.size) | ||
| 1413 | + .text_color(rgb(INK1())) | ||
| 1414 | + .child(format!("{strands}")), | ||
| 1415 | + ) | ||
| 1416 | + .child(viz_step("dock-viz-strands-plus", "+", cx, |this, cx| { | ||
| 1417 | + this.set_viz_strands(engine::decode::viz_strands_of(this.viz_paint()).saturating_add(1).min(32), cx); | ||
| 1418 | + })), | ||
| 1419 | + ) | ||
| 1420 | + .child( | ||
| 1421 | + div() | ||
| 1422 | + .flex() | ||
| 1423 | + .items_center() | ||
| 1424 | + .gap(px(4.)) | ||
| 1425 | + .h(px(CONTROL_H)) | ||
| 1426 | + .child( | ||
| 1427 | + div() | ||
| 1428 | + .font(style.font.clone()) | ||
| 1429 | + .text_size(style.size) | ||
| 1430 | + .text_color(rgb(INK2())) | ||
| 1431 | + .child("Glow"), | ||
| 1432 | + ) | ||
| 1433 | + .child(viz_step("dock-viz-glow-minus", "−", cx, |this, cx| { | ||
| 1434 | + this.set_viz_glow(engine::decode::viz_glow_of(this.viz_paint()).saturating_sub(1), cx); | ||
| 1435 | + })) | ||
| 1436 | + .child( | ||
| 1437 | + div() | ||
| 1438 | + .font(style.font.clone()) | ||
| 1439 | + .text_size(style.size) | ||
| 1440 | + .text_color(rgb(INK1())) | ||
| 1441 | + .child(format!("{glow}")), | ||
| 1442 | + ) | ||
| 1443 | + .child(viz_step("dock-viz-glow-plus", "+", cx, |this, cx| { | ||
| 1444 | + this.set_viz_glow(engine::decode::viz_glow_of(this.viz_paint()).saturating_add(1).min(16), cx); | ||
| 1375 | })), | 1445 | })), |
| 1376 | ) | 1446 | ) |
| 1377 | - .child(step("dock-viz-hue-plus", "+", 1, cx)) | ||
| 1378 | } | 1447 | } |
| 1379 | 1448 | ||
| 1380 | fn clip_tab( | 1449 | fn clip_tab( |
| @@ -1614,7 +1683,7 @@ fn keys_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 1614 | .id("dock-keys-filter") | 1683 | .id("dock-keys-filter") |
| 1615 | .flex_none() | 1684 | .flex_none() |
| 1616 | .cursor_text() | 1685 | .cursor_text() |
| 1617 | - .font(style.font) | 1686 | + .font(style.font.clone()) |
| 1618 | .text_size(style.size) | 1687 | .text_size(style.size) |
| 1619 | .text_color(rgb(INK1())) | 1688 | .text_color(rgb(INK1())) |
| 1620 | .children(hitmap::control("dock.keys-filter", "Filter keys", true)) | 1689 | .children(hitmap::control("dock.keys-filter", "Filter keys", true)) |
crates/engine/examples/bench.rsmodified+1 -0
| @@ -864,6 +864,7 @@ fn export_bench(path: &Path, seat: &str, out_dir: &Path) { | |||
| 864 | fade_out: 0, | 864 | fade_out: 0, |
| 865 | transition_out: 0, | 865 | transition_out: 0, |
| 866 | visualizer: 0, | 866 | visualizer: 0, |
| 867 | + viz_paint: 0, | ||
| 867 | start: 0, | 868 | start: 0, |
| 868 | in_frame, | 869 | in_frame, |
| 869 | out_frame: in_frame + span, | 870 | out_frame: in_frame + span, |
crates/engine/src/decode.rsmodified+82 -13
| @@ -56,6 +56,7 @@ pub enum Backend { | |||
| 56 | /// A gap: black frames, nothing decoded at all. | 56 | /// A gap: black frames, nothing decoded at all. |
| 57 | Gap, | 57 | Gap, |
| 58 | /// A waveform visualizer: the picture is painted from the audio's peaks | 58 | /// A waveform visualizer: the picture is painted from the audio's peaks |
| 59 | + /// A waveform viz_paint: 0, | ||
| 59 | /// ([`visualizer_i420`]), no decoder seat and no stream of pictures at all. | 60 | /// ([`visualizer_i420`]), no decoder seat and no stream of pictures at all. |
| 60 | Visualizer, | 61 | Visualizer, |
| 61 | } | 62 | } |
| @@ -629,6 +630,7 @@ impl DecodeSession { | |||
| 629 | transform: TransformParams, | 630 | transform: TransformParams, |
| 630 | canvas: Composer, | 631 | canvas: Composer, |
| 631 | flags: u8, | 632 | flags: u8, |
| 633 | + paint: u32, | ||
| 632 | ) -> crate::Result<FrameStream> { | 634 | ) -> crate::Result<FrameStream> { |
| 633 | let (tx, rx) = sync_channel(2); | 635 | let (tx, rx) = sync_channel(2); |
| 634 | let cancel = Arc::new(AtomicBool::new(false)); | 636 | let cancel = Arc::new(AtomicBool::new(false)); |
| @@ -679,7 +681,7 @@ impl DecodeSession { | |||
| 679 | return; | 681 | return; |
| 680 | } | 682 | } |
| 681 | let t = f64::from(start_frame + index) / fps; | 683 | let t = f64::from(start_frame + index) / fps; |
| 682 | - let (y, u, v) = visualizer_i420(&peaks, t, width, height, flags); | 684 | + let (y, u, v) = visualizer_i420(&peaks, t, width, height, flags, paint); |
| 683 | let frame = render.frame(start_frame + index, &y, &u, &v, width, height); | 685 | let frame = render.frame(start_frame + index, &y, &u, &v, width, height); |
| 684 | if tx.send(frame).is_err() { | 686 | if tx.send(frame).is_err() { |
| 685 | return; // caller moved on | 687 | return; // caller moved on |
| @@ -1444,6 +1446,65 @@ pub fn viz_ink_rgb(hue: u8) -> (u8, u8, u8) { | |||
| 1444 | hsv_to_rgb(212.0 + f32::from(hue & 15) * 22.5, 0.63, 0.84) | 1446 | hsv_to_rgb(212.0 + f32::from(hue & 15) * 22.5, 0.63, 0.84) |
| 1445 | } | 1447 | } |
| 1446 | 1448 | ||
| 1449 | +pub fn viz_ink_from_paint(paint: u32) -> (u8, u8, u8) { | ||
| 1450 | + if paint == 0 { | ||
| 1451 | + return hsv_to_rgb(212.0, 0.63, 0.84); | ||
| 1452 | + } | ||
| 1453 | + let hue = (paint & 0xFF) as f32 * 360.0 / 256.0; | ||
| 1454 | + let sat_b = ((paint >> 8) & 0xFF) as u8; | ||
| 1455 | + let sat = if sat_b == 0 { 0.63 } else { f32::from(sat_b) / 255.0 }; | ||
| 1456 | + hsv_to_rgb(hue, sat, 0.84) | ||
| 1457 | +} | ||
| 1458 | + | ||
| 1459 | +pub fn viz_strands_of(paint: u32) -> u8 { | ||
| 1460 | + match ((paint >> 16) & 0xFF) as u8 { | ||
| 1461 | + 0 => 8, | ||
| 1462 | + n => n.clamp(1, 32), | ||
| 1463 | + } | ||
| 1464 | +} | ||
| 1465 | + | ||
| 1466 | +pub fn viz_glow_of(paint: u32) -> u8 { | ||
| 1467 | + match ((paint >> 24) & 0xFF) as u8 { | ||
| 1468 | + 0 => 2, | ||
| 1469 | + n => n.min(16), | ||
| 1470 | + } | ||
| 1471 | +} | ||
| 1472 | + | ||
| 1473 | +pub fn with_viz_paint_hue(paint: u32, hue: u8) -> u32 { | ||
| 1474 | + let sat = match (paint >> 8) & 0xFF { | ||
| 1475 | + 0 => 255, | ||
| 1476 | + s => s, | ||
| 1477 | + }; | ||
| 1478 | + (paint & !0xFF) | u32::from(hue) | (sat << 8) | ||
| 1479 | +} | ||
| 1480 | + | ||
| 1481 | +pub fn with_viz_paint_sat(paint: u32, sat: u8) -> u32 { | ||
| 1482 | + (paint & !(0xFF << 8)) | (u32::from(sat.max(1)) << 8) | ||
| 1483 | +} | ||
| 1484 | + | ||
| 1485 | +pub fn with_viz_paint_strands(paint: u32, n: u8) -> u32 { | ||
| 1486 | + (paint & !(0xFF << 16)) | (u32::from(n.clamp(1, 32)) << 16) | ||
| 1487 | +} | ||
| 1488 | + | ||
| 1489 | +pub fn with_viz_paint_glow(paint: u32, n: u8) -> u32 { | ||
| 1490 | + (paint & !(0xFF << 24)) | (u32::from(n.min(16)) << 24) | ||
| 1491 | +} | ||
| 1492 | + | ||
| 1493 | +pub fn viz_hue_ui(paint: u32) -> u8 { | ||
| 1494 | + if paint == 0 { 150 } else { (paint & 0xFF) as u8 } | ||
| 1495 | +} | ||
| 1496 | + | ||
| 1497 | +pub fn viz_sat_ui(paint: u32) -> u8 { | ||
| 1498 | + if paint == 0 { | ||
| 1499 | + 160 | ||
| 1500 | + } else { | ||
| 1501 | + match ((paint >> 8) & 0xFF) as u8 { | ||
| 1502 | + 0 => 160, | ||
| 1503 | + s => s, | ||
| 1504 | + } | ||
| 1505 | + } | ||
| 1506 | +} | ||
| 1507 | + | ||
| 1447 | fn hsv_to_rgb(h: f32, s: f32, v: f32) -> (u8, u8, u8) { | 1508 | fn hsv_to_rgb(h: f32, s: f32, v: f32) -> (u8, u8, u8) { |
| 1448 | let h = ((h % 360.0) + 360.0) % 360.0; | 1509 | let h = ((h % 360.0) + 360.0) % 360.0; |
| 1449 | let c = v * s; | 1510 | let c = v * s; |
| @@ -1607,6 +1668,7 @@ pub(crate) fn visualizer_i420( | |||
| 1607 | width: u32, | 1668 | width: u32, |
| 1608 | height: u32, | 1669 | height: u32, |
| 1609 | flags: u8, | 1670 | flags: u8, |
| 1671 | + paint: u32, | ||
| 1610 | ) -> (Vec<u8>, Vec<u8>, Vec<u8>) { | 1672 | ) -> (Vec<u8>, Vec<u8>, Vec<u8>) { |
| 1611 | let width = width & !1; | 1673 | let width = width & !1; |
| 1612 | let height = height & !1; | 1674 | let height = height & !1; |
| @@ -1616,7 +1678,7 @@ pub(crate) fn visualizer_i420( | |||
| 1616 | let mut y = vec![bg_y; w * h]; | 1678 | let mut y = vec![bg_y; w * h]; |
| 1617 | let mut u = vec![bg_u; cw * ch]; | 1679 | let mut u = vec![bg_u; cw * ch]; |
| 1618 | let mut v = vec![bg_v; cw * ch]; | 1680 | let mut v = vec![bg_v; cw * ch]; |
| 1619 | - let (ink_r, ink_g, ink_b) = viz_ink_rgb(viz_hue(flags)); | 1681 | + let (ink_r, ink_g, ink_b) = viz_ink_from_paint(paint); |
| 1620 | let (ink_y, ink_u, ink_v) = rgb_yuv(ink_r as i32, ink_g as i32, ink_b as i32); | 1682 | let (ink_y, ink_u, ink_v) = rgb_yuv(ink_r as i32, ink_g as i32, ink_b as i32); |
| 1621 | let center = h as f32 / 2.0; | 1683 | let center = h as f32 / 2.0; |
| 1622 | let half = h as f32 * 0.42; | 1684 | let half = h as f32 * 0.42; |
| @@ -1669,15 +1731,18 @@ pub(crate) fn visualizer_i420( | |||
| 1669 | let f = (pos - i as f64) as f32; | 1731 | let f = (pos - i as f64) as f32; |
| 1670 | sig[col] = signed(i) + (signed(i.saturating_add(1)) - signed(i)) * f; | 1732 | sig[col] = signed(i) + (signed(i.saturating_add(1)) - signed(i)) * f; |
| 1671 | } | 1733 | } |
| 1672 | - let peak = lo | 1734 | + // Whole-file peak, not the window's: a 2s window that gains or loses |
| 1735 | + // a loud hit used to rescale every column, so the same bump changed | ||
| 1736 | + // height as it entered and left the picture. | ||
| 1737 | + let peak = peaks | ||
| 1673 | .iter() | 1738 | .iter() |
| 1674 | - .zip(&hi) | 1739 | + .map(|&(l, h)| l.abs().max(h.abs())) |
| 1675 | - .map(|(l, h)| l.abs().max(h.abs())) | ||
| 1676 | .fold(0.0f32, f32::max); | 1740 | .fold(0.0f32, f32::max); |
| 1677 | if peak > 1e-4 { | 1741 | if peak > 1e-4 { |
| 1678 | for i in 0..w { | 1742 | for i in 0..w { |
| 1679 | lo[i] /= peak; | 1743 | lo[i] /= peak; |
| 1680 | hi[i] /= peak; | 1744 | hi[i] /= peak; |
| 1745 | + sig[i] /= peak; | ||
| 1681 | } | 1746 | } |
| 1682 | } | 1747 | } |
| 1683 | viz_smooth(&mut lo, &mut hi); | 1748 | viz_smooth(&mut lo, &mut hi); |
| @@ -1691,8 +1756,8 @@ pub(crate) fn visualizer_i420( | |||
| 1691 | for col in 0..w { | 1756 | for col in 0..w { |
| 1692 | let env = lo[col].abs().max(hi[col]).max(0.06); | 1757 | let env = lo[col].abs().max(hi[col]).max(0.06); |
| 1693 | let x_phase = (col as f64 / w.max(1) as f64) * 2.15 * tau; | 1758 | let x_phase = (col as f64 / w.max(1) as f64) * 2.15 * tau; |
| 1694 | - for s in 0..24 { | 1759 | + for s in 0..u32::from(viz_strands_of(paint)).max(1) { |
| 1695 | - let frac = s as f32 / 23.0; | 1760 | + let frac = s as f32 / (viz_strands_of(paint).max(2) as f32 - 1.0); |
| 1696 | let scale = 0.28 + 0.72 * frac; | 1761 | let scale = 0.28 + 0.72 * frac; |
| 1697 | let wave = (x_phase + travel + s as f64 * 0.05).sin() as f32; | 1762 | let wave = (x_phase + travel + s as f64 * 0.05).sin() as f32; |
| 1698 | let row = (center + half * env * scale * wave).round() as i32; | 1763 | let row = (center + half * env * scale * wave).round() as i32; |
| @@ -1718,8 +1783,12 @@ pub(crate) fn visualizer_i420( | |||
| 1718 | let amp = (w.min(h) as f32) * 0.18; | 1783 | let amp = (w.min(h) as f32) * 0.18; |
| 1719 | let tau = std::f32::consts::TAU; | 1784 | let tau = std::f32::consts::TAU; |
| 1720 | let steps = w.max(h) * 4; | 1785 | let steps = w.max(h) * 4; |
| 1721 | - for strand in 0..8u8 { | 1786 | + for strand in 0..viz_strands_of(paint) { |
| 1722 | - let (ir, ig, ib) = viz_ink_rgb(viz_hue(flags).wrapping_add(if strand < 4 { 0 } else { 8 })); | 1787 | + let (ir, ig, ib) = viz_ink_from_paint(if strand < viz_strands_of(paint) / 2 { |
| 1788 | + paint | ||
| 1789 | + } else { | ||
| 1790 | + with_viz_paint_hue(paint, viz_hue_ui(paint).wrapping_add(128)) | ||
| 1791 | + }); | ||
| 1723 | let (iy, iu, iv) = rgb_yuv(ir as i32, ig as i32, ib as i32); | 1792 | let (iy, iu, iv) = rgb_yuv(ir as i32, ig as i32, ib as i32); |
| 1724 | let scale = 0.65 + 0.35 * f32::from(strand % 4) / 3.0; | 1793 | let scale = 0.65 + 0.35 * f32::from(strand % 4) / 3.0; |
| 1725 | let phase = f32::from(strand) * 0.35; | 1794 | let phase = f32::from(strand) * 0.35; |
| @@ -2104,7 +2173,7 @@ mod tests { | |||
| 2104 | *p = (-a.abs(), a.abs()); | 2173 | *p = (-a.abs(), a.abs()); |
| 2105 | } | 2174 | } |
| 2106 | let flags = 1u8; | 2175 | let flags = 1u8; |
| 2107 | - let (y, u, v) = visualizer_i420(&peaks, 1.0, 320, 180, flags); | 2176 | + let (y, u, v) = visualizer_i420(&peaks, 1.0, 320, 180, flags, 0); |
| 2108 | let ink = y.iter().filter(|&&p| p > 40).count(); | 2177 | let ink = y.iter().filter(|&&p| p > 40).count(); |
| 2109 | assert!(ink > 200, "envelope missing: {ink}"); | 2178 | assert!(ink > 200, "envelope missing: {ink}"); |
| 2110 | assert!(ink < y.len() * 9 / 10, "solid frame, not an envelope: {ink}"); | 2179 | assert!(ink < y.len() * 9 / 10, "solid frame, not an envelope: {ink}"); |
| @@ -2117,13 +2186,13 @@ mod tests { | |||
| 2117 | assert!(blue > 10, "default ink was not timeline blue: {blue}"); | 2186 | assert!(blue > 10, "default ink was not timeline blue: {blue}"); |
| 2118 | 2187 | ||
| 2119 | let ring = with_viz_style(flags, VIZ_STYLE_RING); | 2188 | let ring = with_viz_style(flags, VIZ_STYLE_RING); |
| 2120 | - let (yr, _, _) = visualizer_i420(&peaks, 1.0, 320, 180, ring); | 2189 | + let (yr, _, _) = visualizer_i420(&peaks, 1.0, 320, 180, ring, 0); |
| 2121 | let ring_ink = yr.iter().filter(|&&p| p > 40).count(); | 2190 | let ring_ink = yr.iter().filter(|&&p| p > 40).count(); |
| 2122 | assert!(ring_ink > 80, "ring missing: {ring_ink}"); | 2191 | assert!(ring_ink > 80, "ring missing: {ring_ink}"); |
| 2123 | assert!(ring_ink < ink, "ring should be a stroke, not a fill"); | 2192 | assert!(ring_ink < ink, "ring should be a stroke, not a fill"); |
| 2124 | 2193 | ||
| 2125 | - let hue = with_viz_hue(flags, 8); | 2194 | + let hue_paint = with_viz_paint_hue(0, 40); |
| 2126 | - let (_, u2, v2) = visualizer_i420(&peaks, 1.0, 64, 32, hue); | 2195 | + let (_, u2, v2) = visualizer_i420(&peaks, 1.0, 64, 32, flags, hue_paint); |
| 2127 | let mut shifted = 0usize; | 2196 | let mut shifted = 0usize; |
| 2128 | for i in 0..u2.len() { | 2197 | for i in 0..u2.len() { |
| 2129 | if u2[i] < 120 && v2[i] > 130 { | 2198 | if u2[i] < 120 && v2[i] > 130 { |
crates/engine/src/edith.rsmodified+72 -49
| @@ -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> <visualizer>`: | 121 | +//! <color> <fit> <speed> <fade_in> <fade_out> <transition_out> <transform> <visualizer> <viz_paint>`: |
| 122 | //! which lane the clip is on -- its kind and its 1-based number | 122 | //! 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 header | 123 | //! 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-open | 124 | //! column shows -- then where the clip sits on the timeline, the half-open |
| @@ -205,7 +205,7 @@ | |||
| 205 | //! nothing, and an older one plays everything at real time, and an older one | 205 | //! nothing, and an older one plays everything at real time, and an older one |
| 206 | //! mixes flat, and an older one shows no subtitles, and an older one is shown | 206 | //! mixes flat, and an older one shows no subtitles, and an older one is shown |
| 207 | //! in the reference rendition, and an older one places none of the words it | 207 | //! in the reference rendition, and an older one places none of the words it |
| 208 | -//! names -- and saving any of them writes v21. An older | 208 | +//! names -- and saving any of them writes v22. An older |
| 209 | //! reader refuses a newer file by name. | 209 | //! reader refuses a newer file by name. |
| 210 | //! | 210 | //! |
| 211 | //! Text because an edit list is a few integers and a path, and a path is | 211 | //! Text because an edit list is a few integers and a path, and a path is |
| @@ -242,7 +242,8 @@ use crate::transform::TransformParams; | |||
| 242 | 242 | ||
| 243 | /// What [`save`] writes. Read support goes back to `edith 1`; see the module | 243 | /// What [`save`] writes. Read support goes back to `edith 1`; see the module |
| 244 | /// docs for what those dialects looked like. | 244 | /// docs for what those dialects looked like. |
| 245 | -const MAGIC: &[u8] = b"edith 21"; | 245 | +const MAGIC: &[u8] = b"edith 22"; |
| 246 | +const MAGIC_V21: &[u8] = b"edith 21"; | ||
| 246 | const MAGIC_V20: &[u8] = b"edith 20"; | 247 | const MAGIC_V20: &[u8] = b"edith 20"; |
| 247 | const MAGIC_V19: &[u8] = b"edith 19"; | 248 | const MAGIC_V19: &[u8] = b"edith 19"; |
| 248 | const MAGIC_V18: &[u8] = b"edith 18"; | 249 | const MAGIC_V18: &[u8] = b"edith 18"; |
| @@ -595,7 +596,7 @@ fn emit( | |||
| 595 | let transform = c.transform.map_or("-".to_string(), |e| e.to_string()); | 596 | let transform = c.transform.map_or("-".to_string(), |e| e.to_string()); |
| 596 | out.extend_from_slice( | 597 | out.extend_from_slice( |
| 597 | format!( | 598 | format!( |
| 598 | - "{keyword} {ord} {} {} {} {} {link} {eq} {color} {} {} {} {} {} {transform} {}\n", | 599 | + "{keyword} {ord} {} {} {} {} {link} {eq} {color} {} {} {} {} {} {transform} {} {}\n", |
| 599 | c.start, | 600 | c.start, |
| 600 | c.in_frame, | 601 | c.in_frame, |
| 601 | c.out_frame, | 602 | c.out_frame, |
| @@ -606,6 +607,7 @@ fn emit( | |||
| 606 | c.fade_out, | 607 | c.fade_out, |
| 607 | c.transition_out, | 608 | c.transition_out, |
| 608 | c.visualizer, | 609 | c.visualizer, |
| 610 | + c.viz_paint, | ||
| 609 | ) | 611 | ) |
| 610 | .as_bytes(), | 612 | .as_bytes(), |
| 611 | ); | 613 | ); |
| @@ -648,8 +650,10 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> { | |||
| 648 | // The dialects that wrote a source line without its stream field. Reading | 650 | // The dialects that wrote a source line without its stream field. Reading |
| 649 | // one is the whole of what "an old project still opens" means here. | 651 | // one is the whole of what "an old project still opens" means here. |
| 650 | let streamless = v1 || first == MAGIC_V2; | 652 | let streamless = v1 || first == MAGIC_V2; |
| 653 | + // The one that carries packed visualizer paint (hue/sat/strands/glow)... | ||
| 654 | + let v22 = first == MAGIC; | ||
| 651 | // The one that carries per-clip visualizer flags... | 655 | // The one that carries per-clip visualizer flags... |
| 652 | - let v21 = first == MAGIC; | 656 | + let v21 = v22 || first == MAGIC_V21; |
| 653 | // The one that carries a per-clip transform (position/scale/rotate/crop)... | 657 | // The one that carries a per-clip transform (position/scale/rotate/crop)... |
| 654 | let v20 = v21 || first == MAGIC_V20; | 658 | let v20 = v21 || first == MAGIC_V20; |
| 655 | // ...the one that carries a per-clip cross-dissolve into its successor... | 659 | // ...the one that carries a per-clip cross-dissolve into its successor... |
| @@ -1053,6 +1057,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> { | |||
| 1053 | fade_out: 0, | 1057 | fade_out: 0, |
| 1054 | transition_out: 0, | 1058 | transition_out: 0, |
| 1055 | visualizer: 0, | 1059 | visualizer: 0, |
| 1060 | + viz_paint: 0, | ||
| 1056 | start: queued, | 1061 | start: queued, |
| 1057 | in_frame: number(f[0], n)?, | 1062 | in_frame: number(f[0], n)?, |
| 1058 | out_frame: number(f[1], n)?, | 1063 | out_frame: number(f[1], n)?, |
| @@ -1184,7 +1189,8 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> { | |||
| 1184 | + 2 * usize::from(v18) | 1189 | + 2 * usize::from(v18) |
| 1185 | + usize::from(v19) | 1190 | + usize::from(v19) |
| 1186 | + usize::from(v20) | 1191 | + usize::from(v20) |
| 1187 | - + usize::from(v21); | 1192 | + + usize::from(v21) |
| 1193 | + + usize::from(v22); | ||
| 1188 | let f = fields(rest, want, "clip", n)?; | 1194 | let f = fields(rest, want, "clip", n)?; |
| 1189 | let in_frame = number(f[1], n)?; | 1195 | let in_frame = number(f[1], n)?; |
| 1190 | let out_frame = number(f[2], n)?; | 1196 | let out_frame = number(f[2], n)?; |
| @@ -1200,6 +1206,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> { | |||
| 1200 | fade_out: number(f.get(10).copied().unwrap_or(b"0"), n)?.min(frames), | 1206 | fade_out: number(f.get(10).copied().unwrap_or(b"0"), n)?.min(frames), |
| 1201 | transition_out: number(f.get(11).copied().unwrap_or(b"0"), n)?.min(frames), | 1207 | 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, | 1208 | visualizer: number(f.get(13).copied().unwrap_or(b"0"), n)? as u8, |
| 1209 | + viz_paint: number(f.get(14).copied().unwrap_or(b"0"), n)? as u32, | ||
| 1203 | start: number(f[0], n)?, | 1210 | start: number(f[0], n)?, |
| 1204 | in_frame, | 1211 | in_frame, |
| 1205 | out_frame, | 1212 | out_frame, |
| @@ -1629,7 +1636,7 @@ mod tests { | |||
| 1629 | video 1 0 0 30 0 - - - fit 1000\n"; | 1636 | video 1 0 0 30 0 - - - fit 1000\n"; |
| 1630 | let old = parse(v9, &dir).expect("v9 still loads"); | 1637 | let old = parse(v9, &dir).expect("v9 still loads"); |
| 1631 | assert_eq!(old.subtitles, Vec::new()); | 1638 | assert_eq!(old.subtitles, Vec::new()); |
| 1632 | - assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 21\n")); | 1639 | + assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 22\n")); |
| 1633 | // ...and the line itself is not a v9 line: a dialect may not be mixed. | 1640 | // ...and the line itself is not a v9 line: a dialect may not be mixed. |
| 1634 | let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir) | 1641 | let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir) |
| 1635 | .unwrap_err() | 1642 | .unwrap_err() |
| @@ -2049,6 +2056,7 @@ mod tests { | |||
| 2049 | fade_out: 0, | 2056 | fade_out: 0, |
| 2050 | transition_out: 0, | 2057 | transition_out: 0, |
| 2051 | visualizer: 0, | 2058 | visualizer: 0, |
| 2059 | + viz_paint: 0, | ||
| 2052 | start, | 2060 | start, |
| 2053 | in_frame, | 2061 | in_frame, |
| 2054 | out_frame, | 2062 | out_frame, |
| @@ -2108,10 +2116,10 @@ mod tests { | |||
| 2108 | let bytes = flat(&dir, &sources, &lanes, 12); | 2116 | let bytes = flat(&dir, &sources, &lanes, 12); |
| 2109 | assert_eq!( | 2117 | assert_eq!( |
| 2110 | String::from_utf8_lossy(&bytes), | 2118 | String::from_utf8_lossy(&bytes), |
| 2111 | - "edith 21\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ | 2119 | + "edith 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2112 | source 2 /elsewhere/b.mp4\n\ | 2120 | source 2 /elsewhere/b.mp4\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\ | 2121 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0 0\n\ |
| 2114 | - audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n", | 2122 | + audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n", |
| 2115 | "the file under the project directory is written relative to it, \ | 2123 | "the file under the project directory is written relative to it, \ |
| 2116 | each with the audio stream it plays" | 2124 | each with the audio stream it plays" |
| 2117 | ); | 2125 | ); |
| @@ -2145,9 +2153,9 @@ mod tests { | |||
| 2145 | let bytes = flat(&dir, &sources, &lanes, 7); | 2153 | let bytes = flat(&dir, &sources, &lanes, 7); |
| 2146 | assert_eq!( | 2154 | assert_eq!( |
| 2147 | String::from_utf8_lossy(&bytes), | 2155 | String::from_utf8_lossy(&bytes), |
| 2148 | - "edith 21\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\ | 2156 | + "edith 22\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2149 | - video 1 0 0 30 0 4 - - fit 1000 0 0 0 - 0\naudio 1\n\ | 2157 | + video 1 0 0 30 0 4 - - fit 1000 0 0 0 - 0 0\naudio 1\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", | 2158 | + video 2 40 0 10 0 - - - fit 1000 0 0 0 - 0 0\naudio 2 0 0 30 0 4 - - fit 1000 0 0 0 - 0 0\n", |
| 2151 | "an empty lane is a line of its own; everything else is its clips" | 2159 | "an empty lane is a line of its own; everything else is its clips" |
| 2152 | ); | 2160 | ); |
| 2153 | let back = parse(&bytes, &dir).expect("parse"); | 2161 | let back = parse(&bytes, &dir).expect("parse"); |
| @@ -2235,6 +2243,7 @@ mod tests { | |||
| 2235 | fade_out: 0, | 2243 | fade_out: 0, |
| 2236 | transition_out: 0, | 2244 | transition_out: 0, |
| 2237 | visualizer: 0, | 2245 | visualizer: 0, |
| 2246 | + viz_paint: 0, | ||
| 2238 | eq: Some(0), | 2247 | eq: Some(0), |
| 2239 | ..clip(0, 0, 30, 0, Some(0)) | 2248 | ..clip(0, 0, 30, 0, Some(0)) |
| 2240 | }, | 2249 | }, |
| @@ -2243,6 +2252,7 @@ mod tests { | |||
| 2243 | fade_out: 0, | 2252 | fade_out: 0, |
| 2244 | transition_out: 0, | 2253 | transition_out: 0, |
| 2245 | visualizer: 0, | 2254 | visualizer: 0, |
| 2255 | + viz_paint: 0, | ||
| 2246 | eq: Some(1), | 2256 | eq: Some(1), |
| 2247 | ..clip(30, 10, 20, 0, None) | 2257 | ..clip(30, 10, 20, 0, None) |
| 2248 | }, | 2258 | }, |
| @@ -2253,6 +2263,7 @@ mod tests { | |||
| 2253 | fade_out: 0, | 2263 | fade_out: 0, |
| 2254 | transition_out: 0, | 2264 | transition_out: 0, |
| 2255 | visualizer: 0, | 2265 | visualizer: 0, |
| 2266 | + viz_paint: 0, | ||
| 2256 | eq: Some(0), | 2267 | eq: Some(0), |
| 2257 | ..clip(0, 0, 30, 0, Some(0)) | 2268 | ..clip(0, 0, 30, 0, Some(0)) |
| 2258 | }, | 2269 | }, |
| @@ -2261,6 +2272,7 @@ mod tests { | |||
| 2261 | fade_out: 0, | 2272 | fade_out: 0, |
| 2262 | transition_out: 0, | 2273 | transition_out: 0, |
| 2263 | visualizer: 0, | 2274 | visualizer: 0, |
| 2275 | + viz_paint: 0, | ||
| 2264 | eq: Some(2), | 2276 | eq: Some(2), |
| 2265 | ..clip(30, 0, 10, 0, None) | 2277 | ..clip(30, 0, 10, 0, None) |
| 2266 | }, | 2278 | }, |
| @@ -2269,12 +2281,12 @@ mod tests { | |||
| 2269 | let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0); | 2281 | let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0); |
| 2270 | assert_eq!( | 2282 | assert_eq!( |
| 2271 | String::from_utf8_lossy(&bytes), | 2283 | String::from_utf8_lossy(&bytes), |
| 2272 | - "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2284 | + "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2273 | eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\ | 2285 | eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\ |
| 2274 | eq 16777215.0:-0.1:3.918315e-39:hs\n\ | 2286 | eq 16777215.0:-0.1:3.918315e-39:hs\n\ |
| 2275 | eq\n\ | 2287 | eq\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\ | 2288 | + video 1 0 0 30 0 0 0 - fit 1000 0 0 0 - 0 0\nvideo 1 30 10 20 0 - 1 - fit 1000 0 0 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", | 2289 | + audio 1 0 0 30 0 0 0 - fit 1000 0 0 0 - 0 0\naudio 1 30 0 10 0 - 2 - fit 1000 0 0 0 - 0 0\n", |
| 2278 | "the table comes before the clips, and a clip names a line of it" | 2290 | "the table comes before the clips, and a clip names a line of it" |
| 2279 | ); | 2291 | ); |
| 2280 | 2292 | ||
| @@ -2347,6 +2359,7 @@ mod tests { | |||
| 2347 | fade_out: 0, | 2359 | fade_out: 0, |
| 2348 | transition_out: 0, | 2360 | transition_out: 0, |
| 2349 | visualizer: 0, | 2361 | visualizer: 0, |
| 2362 | + viz_paint: 0, | ||
| 2350 | color: Some(0), | 2363 | color: Some(0), |
| 2351 | fit: FitPolicy::default(), | 2364 | fit: FitPolicy::default(), |
| 2352 | speed: Speed::NORMAL, | 2365 | speed: Speed::NORMAL, |
| @@ -2357,6 +2370,7 @@ mod tests { | |||
| 2357 | fade_out: 0, | 2370 | fade_out: 0, |
| 2358 | transition_out: 0, | 2371 | transition_out: 0, |
| 2359 | visualizer: 0, | 2372 | visualizer: 0, |
| 2373 | + viz_paint: 0, | ||
| 2360 | color: Some(1), | 2374 | color: Some(1), |
| 2361 | fit: FitPolicy::default(), | 2375 | fit: FitPolicy::default(), |
| 2362 | speed: Speed::NORMAL, | 2376 | speed: Speed::NORMAL, |
| @@ -2369,6 +2383,7 @@ mod tests { | |||
| 2369 | fade_out: 0, | 2383 | fade_out: 0, |
| 2370 | transition_out: 0, | 2384 | transition_out: 0, |
| 2371 | visualizer: 0, | 2385 | visualizer: 0, |
| 2386 | + viz_paint: 0, | ||
| 2372 | color: Some(0), | 2387 | color: Some(0), |
| 2373 | fit: FitPolicy::default(), | 2388 | fit: FitPolicy::default(), |
| 2374 | speed: Speed::NORMAL, | 2389 | speed: Speed::NORMAL, |
| @@ -2379,6 +2394,7 @@ mod tests { | |||
| 2379 | fade_out: 0, | 2394 | fade_out: 0, |
| 2380 | transition_out: 0, | 2395 | transition_out: 0, |
| 2381 | visualizer: 0, | 2396 | visualizer: 0, |
| 2397 | + viz_paint: 0, | ||
| 2382 | color: Some(2), | 2398 | color: Some(2), |
| 2383 | fit: FitPolicy::default(), | 2399 | fit: FitPolicy::default(), |
| 2384 | speed: Speed::NORMAL, | 2400 | speed: Speed::NORMAL, |
| @@ -2389,12 +2405,12 @@ mod tests { | |||
| 2389 | let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0); | 2405 | let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0); |
| 2390 | assert_eq!( | 2406 | assert_eq!( |
| 2391 | String::from_utf8_lossy(&bytes), | 2407 | String::from_utf8_lossy(&bytes), |
| 2392 | - "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2408 | + "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2393 | color 0.1:1.2:0.9:-0.3\n\ | 2409 | color 0.1:1.2:0.9:-0.3\n\ |
| 2394 | color -1e-7:16777215.0:3.918315e-39:-0.0\n\ | 2410 | color -1e-7:16777215.0:3.918315e-39:-0.0\n\ |
| 2395 | color 0.0:1.0:1.0:0.0\n\ | 2411 | color 0.0:1.0:1.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\ | 2412 | + video 1 0 0 30 0 0 - 0 fit 1000 0 0 0 - 0 0\nvideo 1 30 10 20 0 - - 1 fit 1000 0 0 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", | 2413 | + audio 1 0 0 30 0 0 - 0 fit 1000 0 0 0 - 0 0\naudio 1 30 0 10 0 - - 2 fit 1000 0 0 0 - 0 0\n", |
| 2398 | "the table comes before the clips, and a clip names a line of it" | 2414 | "the table comes before the clips, and a clip names a line of it" |
| 2399 | ); | 2415 | ); |
| 2400 | 2416 | ||
| @@ -2454,9 +2470,9 @@ mod tests { | |||
| 2454 | (1280, 720), | 2470 | (1280, 720), |
| 2455 | old.playhead | 2471 | old.playhead |
| 2456 | )), | 2472 | )), |
| 2457 | - "edith 21\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ | 2473 | + "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2458 | eq 80.0:-3.0:0.707:ls\n\ | 2474 | eq 80.0:-3.0:0.707:ls\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" | 2475 | + video 1 0 0 30 0 0 0 - fit 1000 0 0 0 - 0 0\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n" |
| 2460 | ); | 2476 | ); |
| 2461 | } | 2477 | } |
| 2462 | 2478 | ||
| @@ -2473,6 +2489,7 @@ mod tests { | |||
| 2473 | fade_out: 0, | 2489 | fade_out: 0, |
| 2474 | transition_out: 0, | 2490 | transition_out: 0, |
| 2475 | visualizer: 0, | 2491 | visualizer: 0, |
| 2492 | + viz_paint: 0, | ||
| 2476 | start, | 2493 | start, |
| 2477 | in_frame, | 2494 | in_frame, |
| 2478 | out_frame, | 2495 | out_frame, |
| @@ -2497,9 +2514,9 @@ mod tests { | |||
| 2497 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); | 2514 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); |
| 2498 | assert_eq!( | 2515 | assert_eq!( |
| 2499 | String::from_utf8_lossy(&bytes), | 2516 | String::from_utf8_lossy(&bytes), |
| 2500 | - "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2517 | + "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\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\ | 2518 | + video 1 0 0 30 0 - - - fit 2000 0 0 0 - 0 0\nvideo 1 15 30 40 0 - - - fit 250 0 0 0 - 0 0\n\ |
| 2502 | - audio 1 0 0 30 0 - - - fit 2000 0 0 0 - 0\n", | 2519 | + audio 1 0 0 30 0 - - - fit 2000 0 0 0 - 0 0\n", |
| 2503 | "the rate is the clip line's last field, in thousandths" | 2520 | "the rate is the clip line's last field, in thousandths" |
| 2504 | ); | 2521 | ); |
| 2505 | let back = parse(&bytes, &dir).expect("parse"); | 2522 | let back = parse(&bytes, &dir).expect("parse"); |
| @@ -2526,8 +2543,8 @@ mod tests { | |||
| 2526 | (1280, 720), | 2543 | (1280, 720), |
| 2527 | old.playhead | 2544 | old.playhead |
| 2528 | )), | 2545 | )), |
| 2529 | - "edith 21\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ | 2546 | + "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\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" | 2547 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n" |
| 2531 | ); | 2548 | ); |
| 2532 | // A rate outside what the editor can set is a corrupt line, by name. | 2549 | // A rate outside what the editor can set is a corrupt line, by name. |
| 2533 | let bad = b"edith 8\nsource 0 a.mp4\nvideo 1 0 0 30 0 - - - fit 9000\n"; | 2550 | let bad = b"edith 8\nsource 0 a.mp4\nvideo 1 0 0 30 0 - - - fit 9000\n"; |
| @@ -2561,6 +2578,7 @@ mod tests { | |||
| 2561 | fade_out: 7, | 2578 | fade_out: 7, |
| 2562 | transition_out: 0, | 2579 | transition_out: 0, |
| 2563 | visualizer: 0, | 2580 | visualizer: 0, |
| 2581 | + viz_paint: 0, | ||
| 2564 | start: 0, | 2582 | start: 0, |
| 2565 | in_frame: 0, | 2583 | in_frame: 0, |
| 2566 | out_frame: 30, | 2584 | out_frame: 30, |
| @@ -2576,8 +2594,8 @@ mod tests { | |||
| 2576 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); | 2594 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); |
| 2577 | assert_eq!( | 2595 | assert_eq!( |
| 2578 | String::from_utf8_lossy(&bytes), | 2596 | String::from_utf8_lossy(&bytes), |
| 2579 | - "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2597 | + "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2580 | - video 1 0 0 30 0 - - - fit 1000 5 7 0 - 0\n", | 2598 | + video 1 0 0 30 0 - - - fit 1000 5 7 0 - 0 0\n", |
| 2581 | "the fades are the clip line's last two fields" | 2599 | "the fades are the clip line's last two fields" |
| 2582 | ); | 2600 | ); |
| 2583 | let back = parse(&bytes, &dir).expect("parse"); | 2601 | let back = parse(&bytes, &dir).expect("parse"); |
| @@ -2613,6 +2631,7 @@ mod tests { | |||
| 2613 | fade_out: 0, | 2631 | fade_out: 0, |
| 2614 | transition_out: 9, | 2632 | transition_out: 9, |
| 2615 | visualizer: 0, | 2633 | visualizer: 0, |
| 2634 | + viz_paint: 0, | ||
| 2616 | start: 0, | 2635 | start: 0, |
| 2617 | in_frame: 0, | 2636 | in_frame: 0, |
| 2618 | out_frame: 30, | 2637 | out_frame: 30, |
| @@ -2628,8 +2647,8 @@ mod tests { | |||
| 2628 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); | 2647 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); |
| 2629 | assert_eq!( | 2648 | assert_eq!( |
| 2630 | String::from_utf8_lossy(&bytes), | 2649 | String::from_utf8_lossy(&bytes), |
| 2631 | - "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2650 | + "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2632 | - video 1 0 0 30 0 - - - fit 1000 0 0 9 - 0\n", | 2651 | + video 1 0 0 30 0 - - - fit 1000 0 0 9 - 0 0\n", |
| 2633 | "the dissolve is the clip line's own last field" | 2652 | "the dissolve is the clip line's own last field" |
| 2634 | ); | 2653 | ); |
| 2635 | let back = parse(&bytes, &dir).expect("parse"); | 2654 | let back = parse(&bytes, &dir).expect("parse"); |
| @@ -2701,6 +2720,7 @@ mod tests { | |||
| 2701 | fade_out: 0, | 2720 | fade_out: 0, |
| 2702 | transition_out: 0, | 2721 | transition_out: 0, |
| 2703 | visualizer: 0, | 2722 | visualizer: 0, |
| 2723 | + viz_paint: 0, | ||
| 2704 | transform: Some(0), | 2724 | transform: Some(0), |
| 2705 | fit: FitPolicy::default(), | 2725 | fit: FitPolicy::default(), |
| 2706 | speed: Speed::NORMAL, | 2726 | speed: Speed::NORMAL, |
| @@ -2711,6 +2731,7 @@ mod tests { | |||
| 2711 | fade_out: 0, | 2731 | fade_out: 0, |
| 2712 | transition_out: 0, | 2732 | transition_out: 0, |
| 2713 | visualizer: 0, | 2733 | visualizer: 0, |
| 2734 | + viz_paint: 0, | ||
| 2714 | transform: Some(1), | 2735 | transform: Some(1), |
| 2715 | fit: FitPolicy::default(), | 2736 | fit: FitPolicy::default(), |
| 2716 | speed: Speed::NORMAL, | 2737 | speed: Speed::NORMAL, |
| @@ -2723,6 +2744,7 @@ mod tests { | |||
| 2723 | fade_out: 0, | 2744 | fade_out: 0, |
| 2724 | transition_out: 0, | 2745 | transition_out: 0, |
| 2725 | visualizer: 0, | 2746 | visualizer: 0, |
| 2747 | + viz_paint: 0, | ||
| 2726 | transform: Some(0), | 2748 | transform: Some(0), |
| 2727 | fit: FitPolicy::default(), | 2749 | fit: FitPolicy::default(), |
| 2728 | speed: Speed::NORMAL, | 2750 | speed: Speed::NORMAL, |
| @@ -2733,6 +2755,7 @@ mod tests { | |||
| 2733 | fade_out: 0, | 2755 | fade_out: 0, |
| 2734 | transition_out: 0, | 2756 | transition_out: 0, |
| 2735 | visualizer: 0, | 2757 | visualizer: 0, |
| 2758 | + viz_paint: 0, | ||
| 2736 | transform: Some(2), | 2759 | transform: Some(2), |
| 2737 | fit: FitPolicy::default(), | 2760 | fit: FitPolicy::default(), |
| 2738 | speed: Speed::NORMAL, | 2761 | speed: Speed::NORMAL, |
| @@ -2762,12 +2785,12 @@ mod tests { | |||
| 2762 | ); | 2785 | ); |
| 2763 | assert_eq!( | 2786 | assert_eq!( |
| 2764 | String::from_utf8_lossy(&bytes), | 2787 | String::from_utf8_lossy(&bytes), |
| 2765 | - "edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2788 | + "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2766 | transform 0.1:-0.2:1.5:90.0:0.1:0.0:0.0:0.05\n\ | 2789 | transform 0.1:-0.2:1.5:90.0:0.1:0.0:0.0:0.05\n\ |
| 2767 | transform -1e-7:16777215.0:3.918315e-39:-0.0:0.0:0.0:0.0:0.0\n\ | 2790 | transform -1e-7:16777215.0:3.918315e-39:-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\ | 2791 | transform 0.0:0.0:1.0:0.0:0.0:0.0:0.0:0.0\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\ | 2792 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 0 0 0\nvideo 1 30 10 20 0 - - - fit 1000 0 0 0 1 0 0\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", | 2793 | + audio 1 0 0 30 0 0 - - fit 1000 0 0 0 0 0 0\naudio 1 30 0 10 0 - - - fit 1000 0 0 0 2 0 0\n", |
| 2771 | "the table comes before the clips, and a clip names a line of it" | 2794 | "the table comes before the clips, and a clip names a line of it" |
| 2772 | ); | 2795 | ); |
| 2773 | 2796 | ||
| @@ -2842,10 +2865,10 @@ mod tests { | |||
| 2842 | ); | 2865 | ); |
| 2843 | assert_eq!( | 2866 | assert_eq!( |
| 2844 | String::from_utf8_lossy(&bytes), | 2867 | String::from_utf8_lossy(&bytes), |
| 2845 | - "edith 21\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\ | 2868 | + "edith 22\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\ |
| 2846 | limiter -1.5 on\nsource 0 a.mp4\n\ | 2869 | limiter -1.5 on\nsource 0 a.mp4\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\ | 2870 | + video 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n\ |
| 2848 | - audio 2 0 0 30 0 - - - fit 1000 0 0 0 - 0\n\ | 2871 | + audio 2 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n\ |
| 2849 | gain audio 1 3.0\ngain audio 2 -6.5\n", | 2872 | gain audio 1 3.0\ngain audio 2 -6.5\n", |
| 2850 | "the mix is lines of its own, the gains after the lanes they name" | 2873 | "the mix is lines of its own, the gains after the lanes they name" |
| 2851 | ); | 2874 | ); |
| @@ -2874,8 +2897,8 @@ mod tests { | |||
| 2874 | (1280, 720), | 2897 | (1280, 720), |
| 2875 | old.playhead | 2898 | old.playhead |
| 2876 | )), | 2899 | )), |
| 2877 | - "edith 21\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ | 2900 | + "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\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" | 2901 | + video 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n" |
| 2879 | ); | 2902 | ); |
| 2880 | 2903 | ||
| 2881 | // Each of the three refuses by name, on its own line. | 2904 | // Each of the three refuses by name, on its own line. |
| @@ -3038,10 +3061,10 @@ mod tests { | |||
| 3038 | assert!(old.eq.is_empty(), "nothing before v5 equalizes anything"); | 3061 | assert!(old.eq.is_empty(), "nothing before v5 equalizes anything"); |
| 3039 | assert_eq!( | 3062 | assert_eq!( |
| 3040 | String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)), | 3063 | String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)), |
| 3041 | - "edith 21\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ | 3064 | + "edith 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 3042 | source 2 /elsewhere/b.mp4\n\ | 3065 | source 2 /elsewhere/b.mp4\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\ | 3066 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0 0\n\ |
| 3044 | - audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n" | 3067 | + audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n" |
| 3045 | ); | 3068 | ); |
| 3046 | // An empty lane's line is still the whole of that lane, eq or no eq. | 3069 | // An empty lane's line is still the whole of that lane, eq or no eq. |
| 3047 | let empty = parse( | 3070 | let empty = parse( |
| @@ -3091,10 +3114,10 @@ mod tests { | |||
| 3091 | let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); | 3114 | let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); |
| 3092 | assert_eq!( | 3115 | assert_eq!( |
| 3093 | String::from_utf8_lossy(&v5), | 3116 | String::from_utf8_lossy(&v5), |
| 3094 | - "edith 21\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ | 3117 | + "edith 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 3095 | source 0 /elsewhere/b.mp4\n\ | 3118 | source 0 /elsewhere/b.mp4\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\ | 3119 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0 0\n\ |
| 3097 | - audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n", | 3120 | + audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n", |
| 3098 | "a re-saved v2 project differs only by its version, the lane \ | 3121 | "a re-saved v2 project differs only by its version, the lane \ |
| 3099 | numbers, the streams it always meant and an equalizer it has none of" | 3122 | numbers, the streams it always meant and an equalizer it has none of" |
| 3100 | ); | 3123 | ); |
| @@ -3123,7 +3146,7 @@ mod tests { | |||
| 3123 | // Saved again it is the current version, which round-trips to the | 3146 | // Saved again it is the current version, which round-trips to the |
| 3124 | // same document. | 3147 | // same document. |
| 3125 | let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); | 3148 | let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); |
| 3126 | - assert!(v5.starts_with(b"edith 21\n")); | 3149 | + assert!(v5.starts_with(b"edith 22\n")); |
| 3127 | let again = parse(&v5, &dir).expect("v5 parses"); | 3150 | let again = parse(&v5, &dir).expect("v5 parses"); |
| 3128 | assert_eq!(again.lanes, back.lanes); | 3151 | assert_eq!(again.lanes, back.lanes); |
| 3129 | // A dialect may not be mixed: lane lines under v1, `clip` under v2. | 3152 | // A dialect may not be mixed: lane lines under v1, `clip` under v2. |
| @@ -3234,8 +3257,8 @@ mod tests { | |||
| 3234 | let bytes = std::fs::read(&path).expect("read back"); | 3257 | let bytes = std::fs::read(&path).expect("read back"); |
| 3235 | assert_eq!( | 3258 | assert_eq!( |
| 3236 | String::from_utf8_lossy(&bytes), | 3259 | String::from_utf8_lossy(&bytes), |
| 3237 | - "edith 21\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\ | 3260 | + "edith 22\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\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" | 3261 | + video 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n" |
| 3239 | ); | 3262 | ); |
| 3240 | // Loading rejoins the *given* directory, so the file is reached by the | 3263 | // Loading rejoins the *given* directory, so the file is reached by the |
| 3241 | // way the project was opened -- the same file, through the link, still | 3264 | // way the project was opened -- the same file, through the link, still |
| @@ -3279,10 +3302,10 @@ mod tests { | |||
| 3279 | #[test] | 3302 | #[test] |
| 3280 | fn a_wrong_first_line_is_refused_by_name() { | 3303 | fn a_wrong_first_line_is_refused_by_name() { |
| 3281 | let dir = PathBuf::from("/proj"); | 3304 | let dir = PathBuf::from("/proj"); |
| 3282 | - let err = parse(b"edith 22\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir) | 3305 | + let err = parse(b"edith 23\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir) |
| 3283 | .unwrap_err() | 3306 | .unwrap_err() |
| 3284 | .to_string(); | 3307 | .to_string(); |
| 3285 | - assert_eq!(err, "line 1: unsupported version 22"); | 3308 | + assert_eq!(err, "line 1: unsupported version 23"); |
| 3286 | for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] { | 3309 | for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] { |
| 3287 | assert_eq!( | 3310 | assert_eq!( |
| 3288 | parse(junk, &dir).unwrap_err().to_string(), | 3311 | parse(junk, &dir).unwrap_err().to_string(), |
crates/engine/src/export.rsmodified+7 -1
| @@ -2770,6 +2770,7 @@ fn run( | |||
| 2770 | meta.height, | 2770 | meta.height, |
| 2771 | meta.frame_rate, | 2771 | meta.frame_rate, |
| 2772 | flags, | 2772 | flags, |
| 2773 | + project.composite_viz_paint_at(span.start), | ||
| 2773 | )? | 2774 | )? |
| 2774 | } else { | 2775 | } else { |
| 2775 | ClipDecoder::open(&entry.path, rate.source_at(in_frame), want)? | 2776 | ClipDecoder::open(&entry.path, rate.source_at(in_frame), want)? |
| @@ -2839,6 +2840,7 @@ fn run( | |||
| 2839 | meta.height, | 2840 | meta.height, |
| 2840 | meta.frame_rate, | 2841 | meta.frame_rate, |
| 2841 | project.composite_visualizer_at(b_start), | 2842 | project.composite_visualizer_at(b_start), |
| 2843 | + project.composite_viz_paint_at(b_start), | ||
| 2842 | )? | 2844 | )? |
| 2843 | } else { | 2845 | } else { |
| 2844 | ClipDecoder::open(&entry.path, b_rate.source_at(b_in_frame), None)? | 2846 | ClipDecoder::open(&entry.path, b_rate.source_at(b_in_frame), None)? |
| @@ -4424,6 +4426,7 @@ enum ClipDecoder { | |||
| 4424 | fps: f64, | 4426 | fps: f64, |
| 4425 | next: u32, | 4427 | next: u32, |
| 4426 | flags: u8, | 4428 | flags: u8, |
| 4429 | + paint: u32, | ||
| 4427 | y: Vec<u8>, | 4430 | y: Vec<u8>, |
| 4428 | u: Vec<u8>, | 4431 | u: Vec<u8>, |
| 4429 | v: Vec<u8>, | 4432 | v: Vec<u8>, |
| @@ -4537,6 +4540,7 @@ impl ClipDecoder { | |||
| 4537 | height: u32, | 4540 | height: u32, |
| 4538 | fps: f64, | 4541 | fps: f64, |
| 4539 | flags: u8, | 4542 | flags: u8, |
| 4543 | + paint: u32, | ||
| 4540 | ) -> crate::Result<Self> { | 4544 | ) -> crate::Result<Self> { |
| 4541 | let peaks = crate::waveform::peaks(path, stream, crate::decode::VIZ_BUCKETS_PER_SEC) | 4545 | let peaks = crate::waveform::peaks(path, stream, crate::decode::VIZ_BUCKETS_PER_SEC) |
| 4542 | .ok() | 4546 | .ok() |
| @@ -4550,6 +4554,7 @@ impl ClipDecoder { | |||
| 4550 | fps, | 4554 | fps, |
| 4551 | next: start_frame, | 4555 | next: start_frame, |
| 4552 | flags, | 4556 | flags, |
| 4557 | + paint, | ||
| 4553 | y: Vec::new(), | 4558 | y: Vec::new(), |
| 4554 | u: Vec::new(), | 4559 | u: Vec::new(), |
| 4555 | v: Vec::new(), | 4560 | v: Vec::new(), |
| @@ -4571,12 +4576,13 @@ impl ClipDecoder { | |||
| 4571 | fps, | 4576 | fps, |
| 4572 | next, | 4577 | next, |
| 4573 | flags, | 4578 | flags, |
| 4579 | + paint, | ||
| 4574 | y, | 4580 | y, |
| 4575 | u, | 4581 | u, |
| 4576 | v, | 4582 | v, |
| 4577 | } => { | 4583 | } => { |
| 4578 | let (yy, uu, vv) = | 4584 | let (yy, uu, vv) = |
| 4579 | - crate::decode::visualizer_i420(peaks, f64::from(*next) / *fps, *width, *height, *flags); | 4585 | + crate::decode::visualizer_i420(peaks, f64::from(*next) / *fps, *width, *height, *flags, *paint); |
| 4580 | *y = yy; | 4586 | *y = yy; |
| 4581 | *u = uu; | 4587 | *u = uu; |
| 4582 | *v = vv; | 4588 | *v = vv; |
crates/engine/src/playback.rsmodified+9 -0
| @@ -708,6 +708,7 @@ impl PlaybackSession { | |||
| 708 | fade_out: 0, | 708 | fade_out: 0, |
| 709 | transition_out: 0, | 709 | transition_out: 0, |
| 710 | visualizer: 0, | 710 | visualizer: 0, |
| 711 | + viz_paint: 0, | ||
| 711 | start: 0, | 712 | start: 0, |
| 712 | in_frame: 0, | 713 | in_frame: 0, |
| 713 | out_frame: meta.frame_count, | 714 | out_frame: meta.frame_count, |
| @@ -799,6 +800,7 @@ impl PlaybackSession { | |||
| 799 | fade_out: 0, | 800 | fade_out: 0, |
| 800 | transition_out: 0, | 801 | transition_out: 0, |
| 801 | visualizer: 0, | 802 | visualizer: 0, |
| 803 | + viz_paint: 0, | ||
| 802 | start: 0, | 804 | start: 0, |
| 803 | in_frame: 0, | 805 | in_frame: 0, |
| 804 | out_frame: place_frames(meta.frame_count, IMAGE_ONLY_RATE), | 806 | out_frame: place_frames(meta.frame_count, IMAGE_ONLY_RATE), |
| @@ -1864,6 +1866,7 @@ impl PlaybackSession { | |||
| 1864 | self.project.composite_fit_at(start), | 1866 | self.project.composite_fit_at(start), |
| 1865 | ), | 1867 | ), |
| 1866 | self.project.composite_visualizer_at(start), | 1868 | self.project.composite_visualizer_at(start), |
| 1869 | + self.project.composite_viz_paint_at(start), | ||
| 1867 | ) | 1870 | ) |
| 1868 | .inspect_err(|e| { | 1871 | .inspect_err(|e| { |
| 1869 | eprintln!("timeline frame {start}: visualizer open failed: {e}") | 1872 | eprintln!("timeline frame {start}: visualizer open failed: {e}") |
| @@ -2981,6 +2984,10 @@ impl PlaybackSession { | |||
| 2981 | self.edit(Dirty::Picture, |p| p.set_visualizer(lane, idx, flags)) | 2984 | self.edit(Dirty::Picture, |p| p.set_visualizer(lane, idx, flags)) |
| 2982 | } | 2985 | } |
| 2983 | 2986 | ||
| 2987 | + pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u32) -> bool { | ||
| 2988 | + self.edit(Dirty::Picture, |p| p.set_viz_paint(lane, idx, paint)) | ||
| 2989 | + } | ||
| 2990 | + | ||
| 2984 | /// Timeline frames of ramp-up from silence at the start of the clip at | 2991 | /// Timeline frames of ramp-up from silence at the start of the clip at |
| 2985 | /// `idx` of `lane`. `0` for an index that is not there. | 2992 | /// `idx` of `lane`. `0` for an index that is not there. |
| 2986 | pub fn fade_in_of(&self, lane: Lane, idx: usize) -> u32 { | 2993 | pub fn fade_in_of(&self, lane: Lane, idx: usize) -> u32 { |
| @@ -3113,6 +3120,7 @@ impl PlaybackSession { | |||
| 3113 | fade_out: 0, | 3120 | fade_out: 0, |
| 3114 | transition_out: 0, | 3121 | transition_out: 0, |
| 3115 | visualizer: 0, | 3122 | visualizer: 0, |
| 3123 | + viz_paint: 0, | ||
| 3116 | start: 0, | 3124 | start: 0, |
| 3117 | in_frame: 0, | 3125 | in_frame: 0, |
| 3118 | out_frame: match image { | 3126 | out_frame: match image { |
| @@ -3307,6 +3315,7 @@ impl PlaybackSession { | |||
| 3307 | fade_out: 0, | 3315 | fade_out: 0, |
| 3308 | transition_out: 0, | 3316 | transition_out: 0, |
| 3309 | visualizer: 1, | 3317 | visualizer: 1, |
| 3318 | + viz_paint: 0, | ||
| 3310 | start: 0, | 3319 | start: 0, |
| 3311 | in_frame, | 3320 | in_frame, |
| 3312 | out_frame, | 3321 | out_frame, |
crates/engine/src/project.rsmodified+32 -3
| @@ -457,10 +457,14 @@ pub struct Clip { | |||
| 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 | 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, | 460 | + /// onto a video lane. Bit 0 is the flag; bits 1-2 style; bit 3 fast. |
| 461 | - /// 3 fast window, 4 tint. Zero is an ordinary picture. Older project | 461 | + /// Zero is an ordinary picture. Older project files have no field and |
| 462 | - /// files have no field and mean zero. | 462 | + /// mean zero. |
| 463 | pub visualizer: u8, | 463 | pub visualizer: u8, |
| 464 | + /// Packed look: hue 0-255, sat 0-255, strands 0-255, glow 0-255. | ||
| 465 | + /// All-zero is the default (timeline azure, full sat, 8 strands, glow 2). | ||
| 466 | + /// Older files have no field and mean zero. | ||
| 467 | + pub viz_paint: u32, | ||
| 464 | } | 468 | } |
| 465 | 469 | ||
| 466 | impl Clip { | 470 | impl Clip { |
| @@ -947,6 +951,7 @@ impl Project { | |||
| 947 | fade_out: 0, | 951 | fade_out: 0, |
| 948 | transition_out: 0, | 952 | transition_out: 0, |
| 949 | visualizer: 0, | 953 | visualizer: 0, |
| 954 | + viz_paint: 0, | ||
| 950 | start: 0, | 955 | start: 0, |
| 951 | in_frame: 0, | 956 | in_frame: 0, |
| 952 | out_frame: frame_count.max(1), | 957 | out_frame: frame_count.max(1), |
| @@ -1347,6 +1352,7 @@ impl Project { | |||
| 1347 | fade_out: 0, | 1352 | fade_out: 0, |
| 1348 | transition_out: 0, | 1353 | transition_out: 0, |
| 1349 | visualizer: 0, | 1354 | visualizer: 0, |
| 1355 | + viz_paint: 0, | ||
| 1350 | start, | 1356 | start, |
| 1351 | in_frame: 0, | 1357 | in_frame: 0, |
| 1352 | out_frame: frame_count.max(1), | 1358 | out_frame: frame_count.max(1), |
| @@ -2647,6 +2653,15 @@ impl Project { | |||
| 2647 | true | 2653 | true |
| 2648 | } | 2654 | } |
| 2649 | 2655 | ||
| 2656 | + pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u32) -> bool { | ||
| 2657 | + if idx >= self.lane(lane).len() { | ||
| 2658 | + return false; | ||
| 2659 | + } | ||
| 2660 | + self.snapshot(); | ||
| 2661 | + self.lane_mut(lane).expect("checked above")[idx].viz_paint = paint; | ||
| 2662 | + true | ||
| 2663 | + } | ||
| 2664 | + | ||
| 2650 | /// Timeline frames of ramp-up from silence at the start of the clip at | 2665 | /// Timeline frames of ramp-up from silence at the start of the clip at |
| 2651 | /// `idx` of `lane`. `0` for an index that is not there, same as a clip | 2666 | /// `idx` of `lane`. `0` for an index that is not there, same as a clip |
| 2652 | /// that has none. | 2667 | /// that has none. |
| @@ -3034,6 +3049,12 @@ impl Project { | |||
| 3034 | .unwrap_or(0) | 3049 | .unwrap_or(0) |
| 3035 | } | 3050 | } |
| 3036 | 3051 | ||
| 3052 | + pub fn composite_viz_paint_at(&self, timeline_frame: u32) -> u32 { | ||
| 3053 | + self.composite_clip_at(timeline_frame) | ||
| 3054 | + .map(|(lane, idx)| self.lane(lane)[idx].viz_paint) | ||
| 3055 | + .unwrap_or(0) | ||
| 3056 | + } | ||
| 3057 | + | ||
| 3037 | /// [`spans_from`](Project::spans_from) over the composite: every stretch the | 3058 | /// [`spans_from`](Project::spans_from) over the composite: every stretch the |
| 3038 | /// viewer sees from `timeline_frame` to the end, in order. What an export | 3059 | /// viewer sees from `timeline_frame` to the end, in order. What an export |
| 3039 | /// encodes and what playback walks at a clip boundary. | 3060 | /// encodes and what playback walks at a clip boundary. |
| @@ -5711,6 +5732,7 @@ mod tests { | |||
| 5711 | fade_out: 0, | 5732 | fade_out: 0, |
| 5712 | transition_out: 0, | 5733 | transition_out: 0, |
| 5713 | visualizer: 0, | 5734 | visualizer: 0, |
| 5735 | + viz_paint: 0, | ||
| 5714 | start, | 5736 | start, |
| 5715 | in_frame, | 5737 | in_frame, |
| 5716 | out_frame, | 5738 | out_frame, |
| @@ -7222,6 +7244,7 @@ mod tests { | |||
| 7222 | fade_out: 0, | 7244 | fade_out: 0, |
| 7223 | transition_out: 0, | 7245 | transition_out: 0, |
| 7224 | visualizer: 0, | 7246 | visualizer: 0, |
| 7247 | + viz_paint: 0, | ||
| 7225 | start: 0, | 7248 | start: 0, |
| 7226 | in_frame: 100, | 7249 | in_frame: 100, |
| 7227 | out_frame: 102, | 7250 | out_frame: 102, |
| @@ -7299,6 +7322,7 @@ mod tests { | |||
| 7299 | fade_out: 0, | 7322 | fade_out: 0, |
| 7300 | transition_out: 0, | 7323 | transition_out: 0, |
| 7301 | visualizer: 0, | 7324 | visualizer: 0, |
| 7325 | + viz_paint: 0, | ||
| 7302 | source: wav, | 7326 | source: wav, |
| 7303 | ..PASTED | 7327 | ..PASTED |
| 7304 | }; | 7328 | }; |
| @@ -8014,6 +8038,7 @@ mod tests { | |||
| 8014 | fade_out: 0, | 8038 | fade_out: 0, |
| 8015 | transition_out: 0, | 8039 | transition_out: 0, |
| 8016 | visualizer: 0, | 8040 | visualizer: 0, |
| 8041 | + viz_paint: 0, | ||
| 8017 | start, | 8042 | start, |
| 8018 | in_frame, | 8043 | in_frame, |
| 8019 | out_frame, | 8044 | out_frame, |
| @@ -9123,6 +9148,7 @@ mod tests { | |||
| 9123 | fade_out: 0, | 9148 | fade_out: 0, |
| 9124 | transition_out: 0, | 9149 | transition_out: 0, |
| 9125 | visualizer: 0, | 9150 | visualizer: 0, |
| 9151 | + viz_paint: 0, | ||
| 9126 | eq: Some(i), | 9152 | eq: Some(i), |
| 9127 | ..video[0] | 9153 | ..video[0] |
| 9128 | }] | 9154 | }] |
| @@ -9166,6 +9192,7 @@ mod tests { | |||
| 9166 | fade_out: 0, | 9192 | fade_out: 0, |
| 9167 | transition_out: 0, | 9193 | transition_out: 0, |
| 9168 | visualizer: 0, | 9194 | visualizer: 0, |
| 9195 | + viz_paint: 0, | ||
| 9169 | color: Some(i), | 9196 | color: Some(i), |
| 9170 | fit: FitPolicy::default(), | 9197 | fit: FitPolicy::default(), |
| 9171 | speed: Speed::NORMAL, | 9198 | speed: Speed::NORMAL, |
| @@ -9231,6 +9258,7 @@ mod tests { | |||
| 9231 | fade_out: 0, | 9258 | fade_out: 0, |
| 9232 | transition_out: 0, | 9259 | transition_out: 0, |
| 9233 | visualizer: 0, | 9260 | visualizer: 0, |
| 9261 | + viz_paint: 0, | ||
| 9234 | start, | 9262 | start, |
| 9235 | in_frame, | 9263 | in_frame, |
| 9236 | out_frame, | 9264 | out_frame, |
| @@ -10030,6 +10058,7 @@ mod tests { | |||
| 10030 | fade_out: 0, | 10058 | fade_out: 0, |
| 10031 | transition_out: 0, | 10059 | transition_out: 0, |
| 10032 | visualizer: 0, | 10060 | visualizer: 0, |
| 10061 | + viz_paint: 0, | ||
| 10033 | start, | 10062 | start, |
| 10034 | in_frame: start, | 10063 | in_frame: start, |
| 10035 | out_frame: end, | 10064 | out_frame: end, |
crates/engine/src/proxy.rsmodified+1 -0
| @@ -560,6 +560,7 @@ fn started( | |||
| 560 | fade_out: 0, | 560 | fade_out: 0, |
| 561 | transition_out: 0, | 561 | transition_out: 0, |
| 562 | visualizer: 0, | 562 | visualizer: 0, |
| 563 | + viz_paint: 0, | ||
| 563 | start: 0, | 564 | start: 0, |
| 564 | in_frame: 0, | 565 | in_frame: 0, |
| 565 | out_frame: meta.frame_count.max(1), | 566 | out_frame: meta.frame_count.max(1), |
crates/engine/src/silence.rsmodified+1 -0
| @@ -323,6 +323,7 @@ mod tests { | |||
| 323 | fade_out: 0, | 323 | fade_out: 0, |
| 324 | transition_out: 0, | 324 | transition_out: 0, |
| 325 | visualizer: 0, | 325 | visualizer: 0, |
| 326 | + viz_paint: 0, | ||
| 326 | start, | 327 | start, |
| 327 | in_frame, | 328 | in_frame, |
| 328 | out_frame, | 329 | out_frame, |
crates/engine/src/sweep.rsmodified+1 -0
| @@ -70,6 +70,7 @@ fn clip(start: u32, in_frame: u32, out_frame: u32) -> Clip { | |||
| 70 | fade_out: 0, | 70 | fade_out: 0, |
| 71 | transition_out: 0, | 71 | transition_out: 0, |
| 72 | visualizer: 0, | 72 | visualizer: 0, |
| 73 | + viz_paint: 0, | ||
| 73 | start, | 74 | start, |
| 74 | in_frame, | 75 | in_frame, |
| 75 | out_frame, | 76 | out_frame, |
crates/engine/tests/audio_export.rsmodified+11 -0
| @@ -65,6 +65,7 @@ fn mixed_project() -> Project { | |||
| 65 | fade_out: 0, | 65 | fade_out: 0, |
| 66 | transition_out: 0, | 66 | transition_out: 0, |
| 67 | visualizer: 0, | 67 | visualizer: 0, |
| 68 | + viz_paint: 0, | ||
| 68 | start, | 69 | start, |
| 69 | in_frame: 0, | 70 | in_frame: 0, |
| 70 | out_frame: 30, | 71 | out_frame: 30, |
| @@ -92,6 +93,7 @@ fn mixed_project() -> Project { | |||
| 92 | fade_out: 0, | 93 | fade_out: 0, |
| 93 | transition_out: 0, | 94 | transition_out: 0, |
| 94 | visualizer: 0, | 95 | visualizer: 0, |
| 96 | + viz_paint: 0, | ||
| 95 | start: 0, | 97 | start: 0, |
| 96 | in_frame: 0, | 98 | in_frame: 0, |
| 97 | out_frame: 90, | 99 | out_frame: 90, |
| @@ -342,6 +344,7 @@ fn a_still_and_a_song_export_as_an_mp4_with_sound() { | |||
| 342 | fade_out: 0, | 344 | fade_out: 0, |
| 343 | transition_out: 0, | 345 | transition_out: 0, |
| 344 | visualizer: 0, | 346 | visualizer: 0, |
| 347 | + viz_paint: 0, | ||
| 345 | start: 0, | 348 | start: 0, |
| 346 | in_frame: 0, | 349 | in_frame: 0, |
| 347 | out_frame: frames, | 350 | out_frame: frames, |
| @@ -412,6 +415,7 @@ fn a_fader_is_one_tracks_own_and_the_limiter_holds_the_sum() { | |||
| 412 | fade_out: 0, | 415 | fade_out: 0, |
| 413 | transition_out: 0, | 416 | transition_out: 0, |
| 414 | visualizer: 0, | 417 | visualizer: 0, |
| 418 | + viz_paint: 0, | ||
| 415 | start: 0, | 419 | start: 0, |
| 416 | in_frame: 0, | 420 | in_frame: 0, |
| 417 | out_frame: 30, | 421 | out_frame: 30, |
| @@ -654,6 +658,7 @@ fn the_sound_is_written_at_the_rate_that_was_asked_for() { | |||
| 654 | fade_out: 0, | 658 | fade_out: 0, |
| 655 | transition_out: 0, | 659 | transition_out: 0, |
| 656 | visualizer: 0, | 660 | visualizer: 0, |
| 661 | + viz_paint: 0, | ||
| 657 | start: 0, | 662 | start: 0, |
| 658 | in_frame: 0, | 663 | in_frame: 0, |
| 659 | out_frame: 60, | 664 | out_frame: 60, |
| @@ -673,6 +678,7 @@ fn the_sound_is_written_at_the_rate_that_was_asked_for() { | |||
| 673 | fade_out: 0, | 678 | fade_out: 0, |
| 674 | transition_out: 0, | 679 | transition_out: 0, |
| 675 | visualizer: 0, | 680 | visualizer: 0, |
| 681 | + viz_paint: 0, | ||
| 676 | start: 0, | 682 | start: 0, |
| 677 | in_frame: 0, | 683 | in_frame: 0, |
| 678 | out_frame: 60, | 684 | out_frame: 60, |
| @@ -734,6 +740,7 @@ fn a_silent_clip_exports_as_silence_over_its_own_span() { | |||
| 734 | fade_out: 0, | 740 | fade_out: 0, |
| 735 | transition_out: 0, | 741 | transition_out: 0, |
| 736 | visualizer: 0, | 742 | visualizer: 0, |
| 743 | + viz_paint: 0, | ||
| 737 | start, | 744 | start, |
| 738 | in_frame: 0, | 745 | in_frame: 0, |
| 739 | out_frame: 30, | 746 | out_frame: 30, |
| @@ -832,6 +839,7 @@ fn a_51_ac3_source_round_trips_through_a_wav() { | |||
| 832 | fade_out: 0, | 839 | fade_out: 0, |
| 833 | transition_out: 0, | 840 | transition_out: 0, |
| 834 | visualizer: 0, | 841 | visualizer: 0, |
| 842 | + viz_paint: 0, | ||
| 835 | start: 0, | 843 | start: 0, |
| 836 | in_frame: 0, | 844 | in_frame: 0, |
| 837 | out_frame: 30, | 845 | out_frame: 30, |
| @@ -966,6 +974,7 @@ fn a_fade_in_reaches_the_exported_audio() { | |||
| 966 | fade_out: 0, | 974 | fade_out: 0, |
| 967 | transition_out: 0, | 975 | transition_out: 0, |
| 968 | visualizer: 0, | 976 | visualizer: 0, |
| 977 | + viz_paint: 0, | ||
| 969 | start: 0, | 978 | start: 0, |
| 970 | in_frame: 0, | 979 | in_frame: 0, |
| 971 | out_frame: 90, // 3.0 s at 30 fps | 980 | out_frame: 90, // 3.0 s at 30 fps |
| @@ -1052,6 +1061,7 @@ fn a_split_and_crossfaded_clip_has_no_muted_interior() { | |||
| 1052 | fade_out: 0, | 1061 | fade_out: 0, |
| 1053 | transition_out: 0, | 1062 | transition_out: 0, |
| 1054 | visualizer: 0, | 1063 | visualizer: 0, |
| 1064 | + viz_paint: 0, | ||
| 1055 | start, | 1065 | start, |
| 1056 | in_frame, | 1066 | in_frame, |
| 1057 | out_frame, | 1067 | out_frame, |
| @@ -1159,6 +1169,7 @@ fn a_mono_timeline_exports_as_dual_mono_ogg() { | |||
| 1159 | fade_out: 0, | 1169 | fade_out: 0, |
| 1160 | transition_out: 0, | 1170 | transition_out: 0, |
| 1161 | visualizer: 0, | 1171 | visualizer: 0, |
| 1172 | + viz_paint: 0, | ||
| 1162 | start: 0, | 1173 | start: 0, |
| 1163 | in_frame: 0, | 1174 | in_frame: 0, |
| 1164 | out_frame: 30, | 1175 | out_frame: 30, |
crates/engine/tests/audio_files.rsmodified+1 -0
| @@ -421,6 +421,7 @@ fn a_silent_first_source_does_not_stop_the_scan_for_one_with_sound() { | |||
| 421 | fade_out: 0, | 421 | fade_out: 0, |
| 422 | transition_out: 0, | 422 | transition_out: 0, |
| 423 | visualizer: 0, | 423 | visualizer: 0, |
| 424 | + viz_paint: 0, | ||
| 424 | start: 0, | 425 | start: 0, |
| 425 | in_frame: 0, | 426 | in_frame: 0, |
| 426 | out_frame: meta1.frame_count, | 427 | out_frame: meta1.frame_count, |
crates/engine/tests/eq_audio.rsmodified+1 -0
| @@ -58,6 +58,7 @@ fn clip(start: u32, source: usize, frames: u32) -> Clip { | |||
| 58 | fade_out: 0, | 58 | fade_out: 0, |
| 59 | transition_out: 0, | 59 | transition_out: 0, |
| 60 | visualizer: 0, | 60 | visualizer: 0, |
| 61 | + viz_paint: 0, | ||
| 61 | start, | 62 | start, |
| 62 | in_frame: 0, | 63 | in_frame: 0, |
| 63 | out_frame: frames, | 64 | out_frame: frames, |
crates/engine/tests/export.rsmodified+2 -0
| @@ -241,6 +241,7 @@ fn exports_at_the_project_resolution_with_the_watched_geometry() { | |||
| 241 | fade_out: 0, | 241 | fade_out: 0, |
| 242 | transition_out: 0, | 242 | transition_out: 0, |
| 243 | visualizer: 0, | 243 | visualizer: 0, |
| 244 | + viz_paint: 0, | ||
| 244 | start, | 245 | start, |
| 245 | in_frame: 0, | 246 | in_frame: 0, |
| 246 | out_frame: 10, | 247 | out_frame: 10, |
| @@ -329,6 +330,7 @@ fn exports_the_audio_stream_the_timeline_plays() { | |||
| 329 | fade_out: 0, | 330 | fade_out: 0, |
| 330 | transition_out: 0, | 331 | transition_out: 0, |
| 331 | visualizer: 0, | 332 | visualizer: 0, |
| 333 | + viz_paint: 0, | ||
| 332 | start: 0, | 334 | start: 0, |
| 333 | in_frame: 0, | 335 | in_frame: 0, |
| 334 | out_frame: meta.frame_count, | 336 | out_frame: meta.frame_count, |
crates/engine/tests/lanes.rsmodified+2 -0
| @@ -238,6 +238,7 @@ fn the_mp4_copy_follows_the_lane_that_holds_the_sound() { | |||
| 238 | fade_in: 0, | 238 | fade_in: 0, |
| 239 | transition_out: 0, | 239 | transition_out: 0, |
| 240 | visualizer: 0, | 240 | visualizer: 0, |
| 241 | + viz_paint: 0, | ||
| 241 | fade_out: 0, | 242 | fade_out: 0, |
| 242 | start: 0, | 243 | start: 0, |
| 243 | in_frame: 0, | 244 | in_frame: 0, |
| @@ -306,6 +307,7 @@ fn two_audio_lanes_are_summed() { | |||
| 306 | fade_out: 0, | 307 | fade_out: 0, |
| 307 | transition_out: 0, | 308 | transition_out: 0, |
| 308 | visualizer: 0, | 309 | visualizer: 0, |
| 310 | + viz_paint: 0, | ||
| 309 | start: TOP_IN, | 311 | start: TOP_IN, |
| 310 | in_frame: TOP_IN, | 312 | in_frame: TOP_IN, |
| 311 | out_frame: TOP_OUT, | 313 | out_frame: TOP_OUT, |
crates/engine/tests/opus_export.rsmodified+2 -0
| @@ -86,6 +86,7 @@ fn project(video: &Path, sound: &Path, sound_in: u32) -> Project { | |||
| 86 | fade_out: 0, | 86 | fade_out: 0, |
| 87 | transition_out: 0, | 87 | transition_out: 0, |
| 88 | visualizer: 0, | 88 | visualizer: 0, |
| 89 | + viz_paint: 0, | ||
| 89 | start: 0, | 90 | start: 0, |
| 90 | in_frame, | 91 | in_frame, |
| 91 | out_frame, | 92 | out_frame, |
| @@ -471,6 +472,7 @@ fn a_copied_picture_names_the_sound_it_was_written_with() { | |||
| 471 | fade_out: 0, | 472 | fade_out: 0, |
| 472 | transition_out: 0, | 473 | transition_out: 0, |
| 473 | visualizer: 0, | 474 | visualizer: 0, |
| 475 | + viz_paint: 0, | ||
| 474 | start: 0, | 476 | start: 0, |
| 475 | in_frame: 0, | 477 | in_frame: 0, |
| 476 | out_frame, | 478 | out_frame, |
crates/engine/tests/silence.rsmodified+2 -0
| @@ -142,6 +142,7 @@ fn speed_mode_refuses_a_clip_that_laps_over_a_silence() { | |||
| 142 | fade_out: 0, | 142 | fade_out: 0, |
| 143 | transition_out: 0, | 143 | transition_out: 0, |
| 144 | visualizer: 0, | 144 | visualizer: 0, |
| 145 | + viz_paint: 0, | ||
| 145 | start: 0, | 146 | start: 0, |
| 146 | in_frame: 0, | 147 | in_frame: 0, |
| 147 | out_frame: 20, | 148 | out_frame: 20, |
| @@ -182,6 +183,7 @@ fn whole(source: usize, frames: u32) -> Clip { | |||
| 182 | fade_out: 0, | 183 | fade_out: 0, |
| 183 | transition_out: 0, | 184 | transition_out: 0, |
| 184 | visualizer: 0, | 185 | visualizer: 0, |
| 186 | + viz_paint: 0, | ||
| 185 | start: 0, | 187 | start: 0, |
| 186 | in_frame: 0, | 188 | in_frame: 0, |
| 187 | out_frame: frames, | 189 | out_frame: frames, |