edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! Where the transport is, how loud it is, and the seek rate limits. |
| 2 | |
| 3 | use crate::*; |
| 4 | |
| 5 | /// What the header says with no timeline open, and what the window title reads |
| 6 | /// as a program name rather than as a file name. |
| 7 | pub const NO_FILE: &str = "no file open"; |
| 8 | |
| 9 | /// What a press of play says when there is nothing to play: no timeline at all |
| 10 | /// and an emptied one are the same answer to the user, so they are one line. |
| 11 | pub const NOTHING_TO_PLAY: &str = "Nothing to play: the timeline is empty"; |
| 12 | |
| 13 | /// Whether a press of play would have anything to play. No timeline at all and |
| 14 | /// one every clip has been taken off are the same state to a transport, and the |
| 15 | /// button and the key both have to give the same answer to it -- so there is |
| 16 | /// one of them, and it is free of the window so it can be checked without one. |
| 17 | pub |
| 18 | |
| 19 | |
| 20 | |
| 21 | /// What the monitoring output is set to. Two things, not one: the level the |
| 22 | /// user picked, and whether it is being held silent -- so unmuting comes back |
| 23 | /// to the level rather than to a guess. |
| 24 | /// |
| 25 | /// The level counts steps rather than carrying an `f32`, because 5% at a time |
| 26 | /// down and back up again through a float would not land on the number it |
| 27 | /// started from, and the label would eventually read `79%`. |
| 28 | /// |
| 29 | /// Volume and mute stay independent on purpose: turning the level down while |
| 30 | /// muted must not be what makes sound come out. Only the mute key unmutes, and |
| 31 | /// the button says both things at once ("Muted 80%") so neither is a surprise. |
| 32 | |
| 33 | pub |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | /// Where the transport is. The one answer the button's glyph, its label, its |
| 111 | /// enablement, the play key and the repaint loop all read -- there is no play |
| 112 | /// flag anywhere else, because a second one is a second answer. |
| 113 | |
| 114 | pub |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | /// What a session's own two answers mean: the clock, unless the timeline has |
| 141 | /// been played out -- `played_out` is the engine's end of stream with no frame |
| 142 | /// still waiting on the pump, and it wins, because past the end a running clock |
| 143 | /// is measuring wall time and not a picture. |
| 144 | pub |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | /// Rate limit for scrub seeks: a video worker reopen costs 72-87 ms on the |
| 153 | /// hardware path for the small files it was measured on (215 ms in software), so |
| 154 | /// one seek per mouse move would only queue workers that are cancelled before |
| 155 | /// they decode anything. |
| 156 | /// |
| 157 | /// It is a *floor*, not a bound: the reopen is a demux open |
| 158 | /// ([`engine::decode::open_worker`]), and on a 25 GB film that is 550-750 ms -- |
| 159 | /// five to seven times this gap, which therefore gates nothing there. Where the |
| 160 | /// cost had to be bounded rather than thinned -- the colour and speed drags -- |
| 161 | /// the gate is the frame the worker delivers ([`Player::flush_drag`]) and no |
| 162 | /// timer at all. The ruler keeps this one: a scrub has no value to hold back, |
| 163 | /// only a position that the next mouse move replaces anyway. |
| 164 | pub const SCRUB_GAP: Duration = from_millis; |
| 165 | |
| 166 | pub |
| 167 | |
| 168 | |
| 169 | |
| 170 | /// How far the picture may fall behind the sound before it is restarted at the |
| 171 | /// clock instead of left to crawl after it. Past what an eye reads as lip sync |
| 172 | /// (a tenth of a second or so) and above what a single reopen costs to fix, so a |
| 173 | /// picture that is merely a reopen behind is not answered with another one. |
| 174 | pub const LATE_RESYNC: f64 = 0.4; |
| 175 | /// The least time between two such restarts: the decoder that cannot keep up is |
| 176 | /// the one this fires for, and it will still be behind straight afterwards. |
| 177 | pub const RESYNC_GAP: Duration = from_secs; |
| 178 | |
| 179 | /// Whether a picture `late` seconds behind the master clock is restarted at it, |
| 180 | /// given when the last restart was ([`Player::pump`]). |
| 181 | pub |
| 182 | |
| 183 | |
| 184 | |
| 185 | /// The gate a live drag sample goes through. With the worker still owing a |
| 186 | /// frame (`busy`), writing now would only cancel the open the picture is already |
| 187 | /// waiting for -- the sample is held in `stash` instead, and the frame that |
| 188 | /// lands writes it ([`Player::flush_drag`]). Returns what to write, if anything. |
| 189 | /// |
| 190 | /// The press (`first`) never waits: it is the undo step the whole gesture rolls |
| 191 | /// back to, so it has to be taken against the state the hand picked up. |
| 192 | pub |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | /// Which of a visualizer's two inks a look control acts on: the clip's own |
| 208 | /// colour, or the second half of a dual-strand ring. Zero -- the clip's own -- |
| 209 | /// is what every control meant before there was a second, so it is also what |
| 210 | /// the Clip tab opens on ([`Player::viz_slot`]). |
| 211 | /// |
| 212 | /// Both inks are read and written through the same three methods, so the |
| 213 | /// wheel, the hex field and the drag that holds a sample between them cannot |
| 214 | /// disagree about which one a gesture is on. |
| 215 | |
| 216 | pub |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | /// What the wheel draws: the clip's own ink, or the sample a drag is holding |
| 276 | /// while the worker is still behind ([`stash_or_write`]). The wheel is a |
| 277 | /// picker with no table of its own, so a held sample would otherwise be |
| 278 | /// invisible -- the clip carries the sample *before* it until the holding |
| 279 | /// frame lands -- and the mark would sit still under a moving hand. |
| 280 | /// [`Player::color_params`] holds exactly this rule for the card's sliders. |
| 281 | /// |
| 282 | /// The held sample carries its slot, so a drag on the strand colour draws the |
| 283 | /// strand colour even before the clip has one of its own. |
| 284 | pub |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | /// How long an open may stand before the window says so in words. Well past an |
| 292 | /// ordinary seek (a warm reopen is under a tenth of this) and well under what a |
| 293 | /// cold read of a big film takes, which is the only case worth a line. |
| 294 | pub const SEEK_STALL: Duration = from_secs; |
| 295 | |
| 296 | /// How long before the line counts the seconds. |
| 297 | pub const SEEK_COUNT: Duration = from_secs; |
| 298 | |
| 299 | /// How long a picture may stand unopened before the line stops saying it is opening and says |
| 300 | /// why it cannot be shown. A slow read still lands inside this; a compound or a missing file |
| 301 | /// never does, and a running timer over it would be a lie. |
| 302 | pub const SEEK_GIVE_UP: Duration = from_secs; |
| 303 | |
| 304 | /// What a seek that has stood past [`SEEK_STALL`] says, and nothing at all |
| 305 | /// before that: a line on every click of the ruler would be a flicker, and the |
| 306 | /// picture holding still for a tenth of a second is not something to explain. |
| 307 | /// Short and plain; the seconds only once they say something (a window that |
| 308 | /// cannot move and a window that has hung look identical, so this one counts). |
| 309 | /// A picture whose file is off the disk is the banner's to say (`missing_clip_note`), so this |
| 310 | /// line is only for a read that failed. |
| 311 | pub |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | /// Where along the preview's own seek bar a click landed, in seconds from |
| 323 | /// the start: [`frac_along`]'s fraction of `duration`, since the bar spans |
| 324 | /// the preview's whole length rather than a zoomed timeline `Scale` -- a |
| 325 | /// preview does not zoom, so there is no bed narrower than the file to map |
| 326 | /// into. |
| 327 | pub |
| 328 | |
| 329 | |
| 330 | |
| 331 | /// How full the preview's seek bar is drawn, 0..1: the played share of the |
| 332 | /// duration, clamped for the same reason [`frac_along`] clamps a click -- a |
| 333 | /// clock a frame past the end must not overhang the track it is drawn on. |
| 334 | /// Zero for a duration of nothing, rather than a NaN from dividing by it. |
| 335 | pub |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | /// Where the ruler draws the playhead, given whether *the timeline's own* |
| 343 | /// session ([`Player::session`]) has played out. `ended` must answer for |
| 344 | /// `session` specifically, never for [`Player::active_session`] -- a preview |
| 345 | /// reaching *its* end is not the timeline's own playhead running out, and |
| 346 | /// must not snap the ruler to `duration` while the timeline sits wherever it |
| 347 | /// was left (a seek, mid-scrub, anywhere). `now` is `session`'s own clock, |
| 348 | /// which a preview never touches. |
| 349 | pub |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 |