edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! The equalizer, speed, silence and mixer cards' numbers. |
| 2 | |
| 3 | use crate::*; |
| 4 | |
| 5 | /// How far a band may be pushed either way, in dB. The engine clamps nothing |
| 6 | /// here -- it will filter whatever it is given -- so this is a UI decision: |
| 7 | /// past about this a peaking band stops sounding like tone and starts sounding |
| 8 | /// like a fault. |
| 9 | pub const EQ_GAIN_LIMIT: f32 = 12.; |
| 10 | |
| 11 | /// One dB per keystroke, which is roughly the smallest step anyone hears on a |
| 12 | /// single band. |
| 13 | pub const EQ_STEP: f32 = 1.; |
| 14 | |
| 15 | /// A twentieth of real time per keystroke, in the thousandths a [`Speed`] is |
| 16 | /// held in: fine enough to creep up on a rate, coarse enough that the whole |
| 17 | /// range is eighty presses and not eight hundred -- and it divides 1000, so |
| 18 | /// stepping from anywhere lands on exactly 1.00x on the way past. |
| 19 | pub const SPEED_STEP: i32 = 50; |
| 20 | |
| 21 | /// The rates the card's buttons offer, so the ones people actually name are one |
| 22 | /// click and not a drag. Real time is among them: it is the reset. |
| 23 | pub const SPEED_PRESETS: = ; |
| 24 | |
| 25 | /// A rate from a number of thousandths that may have run off either end -- what |
| 26 | /// a keystroke and a drag both produce. Clamped, not refused: a hand pushing |
| 27 | /// past the limit means "as far as it goes", exactly as a trim does. |
| 28 | pub |
| 29 | |
| 30 | |
| 31 | |
| 32 | /// How far a ramp key's speed moves per press of its stepper: a quarter of real |
| 33 | /// time, the same quarter the bar's lowest rate is. |
| 34 | pub const RAMP_KEY_STEP: i32 = 250; |
| 35 | |
| 36 | /// The ramp shapes the speed card and the palette offer, each laid across the clip's |
| 37 | /// own length on the timeline. |
| 38 | |
| 39 | pub |
| 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 | /// `keys` with a key of `speed` at clip frame `at`: one already there is replaced, |
| 87 | /// else the new one is slotted in order. `None` when the ramp is full |
| 88 | /// ([`engine::project::MAX_SPEED_KEYS`]) and `at` is a new frame. |
| 89 | pub |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | /// `keys` without the `i`th; the last key out leaves no ramp at all. |
| 105 | pub |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | /// `keys` with the `i`th key's speed moved by `steps` of [`RAMP_KEY_STEP`], clamped to |
| 117 | /// what a [`Speed`] holds. |
| 118 | pub |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | /// The speed curve of a ramp as the card draws it: `n + 1` points across the clip's |
| 131 | /// `frames`, x the fraction of the way along and y the speed's place on the speed bar |
| 132 | /// (log scale, real time mid-height), so the card's curve and its bar read alike. A |
| 133 | /// clip without a ramp draws its constant speed as a level line. |
| 134 | pub |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | /// A clip's speed as its box wears it: `2×` for a constant one, the ramp's keys joined |
| 155 | /// by arrows (`1×→2×→1×`) for a ramp, and only its two ends and a count once it has more |
| 156 | /// than three keys. `None` for a clip at real time with no ramp. |
| 157 | pub |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | /// The silence card's rows, in the order it lists them: how wide the apply |
| 173 | /// reaches, the threshold and the unit it is read in, the three durations a |
| 174 | /// scan is told, and the rate the speed-up plays at. What `silence_field` |
| 175 | /// indexes and what [`Player::nudge_silence`] moves. |
| 176 | pub const SILENCE_ROWS: usize = 7; |
| 177 | |
| 178 | /// How wide a jumpcut reaches. A ripple used to be the whole timeline's |
| 179 | /// business and nothing else; it is a *choice* now, because a podcast track's |
| 180 | /// silences are not the music track's business -- and the choice has to be on |
| 181 | /// screen, because "everything after this moved" is not a thing to discover |
| 182 | /// afterwards. |
| 183 | |
| 184 | pub |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | /// The order the card cycles them in. |
| 198 | pub const SCOPES: = ; |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | /// One press of a nudge key on each kind of row: a dB on the threshold, a |
| 218 | /// twentieth of a second on the three durations, and the speed card's own step |
| 219 | /// on the rate. |
| 220 | pub const SILENCE_DB_STEP: f32 = 1.; |
| 221 | pub const SILENCE_SECS_STEP: f64 = 0.05; |
| 222 | |
| 223 | /// How far each of them may be pushed. UI decisions, all of them: the engine |
| 224 | /// takes any finite number, but a forgiveness of ten seconds finds nothing in a |
| 225 | /// talking head. The threshold reaches full scale, which calls a whole take |
| 226 | /// silent -- that is a thing someone may want to ask for (the preview on the |
| 227 | /// lane says what it would cost before anything is cut), so the top is 0 rather |
| 228 | /// than a number this card picked for them. |
| 229 | pub const SILENCE_DB_RANGE: = ; |
| 230 | pub const SILENCE_SECS_RANGE: = ; |
| 231 | |
| 232 | /// One press of a nudge key on the mix card, in dB: the step every fader and |
| 233 | /// the limiter's ceiling moves by. A whole decibel, the smallest move anyone |
| 234 | /// hears as a move -- and it lands on round numbers, so a track set by ear |
| 235 | /// still reads as a number a person would say. |
| 236 | pub const MIX_DB_STEP: f32 = 1.; |
| 237 | |
| 238 | /// The mix card's rows below the faders: the limiter's ceiling and its switch. |
| 239 | /// One fader per audio track comes first, however many there are. |
| 240 | pub const MIX_MASTER_ROWS: usize = 2; |
| 241 | |
| 242 | /// The speed-up rate is bounded *below* by real time: a "speed-up" that slows |
| 243 | /// the silence down would make the timeline longer, which is the one thing |
| 244 | /// neither button may do. The top is [`Speed::MAX`]. |
| 245 | pub |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | /// The graph's frequency axis: the range an ear works in, and the range every |
| 253 | /// band a file can carry sits inside. Log-spaced, so an octave is an octave |
| 254 | /// wherever it falls. |
| 255 | pub const EQ_FREQ_LOW: f32 = 20.; |
| 256 | pub const EQ_FREQ_HIGH: f32 = 20_000.; |
| 257 | |
| 258 | /// The curve box, docked: a 140 px plot with the knob room above and below it |
| 259 | /// (the strip for "Play to see sound" over the plot, the frequency labels under). |
| 260 | /// Tall enough that 1 dB is a visible move at the ±12 dB axis, and the card scrolls |
| 261 | /// in a 360 px window. |
| 262 | pub const EQ_GRAPH_H: f32 = 182.; |
| 263 | |
| 264 | /// The curve box maximized: 1 dB and a semitone-ish band of frequency both |
| 265 | /// read as more pixels than the docked floor spends on them -- the same |
| 266 | /// curve, the same ±12 dB axis and the same 20 Hz-20 kHz sweep, just spread |
| 267 | /// over more of the vertical resolution a maximized card borrows from the |
| 268 | /// bench/ledger rows below the picture ([`crate::ui::stance::below_picture_floor`]). |
| 269 | pub const EQ_GRAPH_MAX_H: f32 = 320.; |
| 270 | |
| 271 | /// The graph's own height for the card's current size: the docked floor, or |
| 272 | /// the maximized card's own taller box -- never a CSS scale of the same |
| 273 | /// pixels, an actually taller curve with more room per decibel and per |
| 274 | /// decade. |
| 275 | pub |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | /// How wide the equalizer card is allowed to get. It is the one card that is a |
| 284 | /// *graph*: every pixel across is frequency resolution, and at the 320 px the |
| 285 | /// other cards use, a third of an octave was a couple of pixels. Past this the |
| 286 | /// curve stops gaining anything and the card starts reading as a wall. |
| 287 | pub const EQ_W_MAX: f32 = 720.; |
| 288 | |
| 289 | /// The gap the card leaves either side of it, so it reads as a card on a scrim |
| 290 | /// rather than as a second window: it takes the width it can get inside that. |
| 291 | pub const EQ_W_MARGIN: f32 = 32.; |
| 292 | |
| 293 | pub const EQ_BANDS_MAX: usize = MAX_BANDS; |
| 294 | |
| 295 | /// One press of the frequency keys, as a factor: a sixth of an octave, so a |
| 296 | /// band walks the whole axis in about sixty presses and still lands close |
| 297 | /// enough to a named frequency to aim at one. |
| 298 | pub const EQ_FREQ_STEP: f32 = 1.122_462; |
| 299 | |
| 300 | /// One press of the Q keys, as a factor, and the range they move in. Below the |
| 301 | /// bottom a peak is barely a peak any more; above the top it is a whistle on |
| 302 | /// one frequency. 0.707 -- the flat-shelf value, and the default -- sits inside |
| 303 | /// them, so nothing a file carries has to be dragged into range first. |
| 304 | pub const EQ_Q_STEP: f32 = 1.25; |
| 305 | pub const EQ_Q_LOW: f32 = 0.3; |
| 306 | pub const EQ_Q_HIGH: f32 = 12.; |
| 307 | |
| 308 | /// How many points the curve is drawn from. One per ~3 px across the card: |
| 309 | /// past that the line is smooth and the extra biquad evaluations are wasted. |
| 310 | pub const EQ_CURVE_STEPS: usize = 96; |
| 311 | |
| 312 | /// A band's handle on the curve. Only the dot -- what is *grabbed* is the whole |
| 313 | /// graph (the nearest band along the frequency axis), so the target is the box. |
| 314 | pub const EQ_HANDLE: f32 = 10.; |
| 315 | |
| 316 | /// A band's hit area on the curve: 24 px ([`crate::layout::HIT_MIN`], WCAG |
| 317 | /// 2.5.8) centred on the dot, so the point is found by aim alone. The dot is |
| 318 | /// drawn [`EQ_HANDLE`] wide inside it; the rest is a target, not a drawing. |
| 319 | pub const EQ_HIT: f32 = crateHIT_MIN; |
| 320 | |
| 321 | /// The frequencies the graph names, so the curve can be read as a curve *of |
| 322 | /// something*. The two ends label themselves at the edges. |
| 323 | pub const EQ_TICKS: = |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | ; |
| 330 | |
| 331 | /// The gains the graph rules a line across, besides the 0 dB one it already |
| 332 | /// had: half way to each limit, so a boost can be read as "about six" without |
| 333 | /// counting pixels. The limits themselves are the box's own edges and are |
| 334 | /// named at the corners instead. |
| 335 | pub const EQ_DB_GRID: = ; |
| 336 | |
| 337 | /// How wide an end tick's own label box has to be so "20 Hz" reads as one |
| 338 | /// line rather than wrapping onto two ("20" over "Hz") -- driven live and |
| 339 | /// found doing exactly that at a fixed 24 px box once the end ticks were |
| 340 | /// anchored to the graph's edge instead of centred on it (the anchor alone |
| 341 | /// was not the whole fix). Sized off the label's own character count at the |
| 342 | /// size it is actually drawn, using the list-truncation ladder's already |
| 343 | /// -calibrated characters-to-pixels ratio ([`crate::layout::LIST_CHAR_W`] at |
| 344 | /// [`crate::ui::type_scale::CHORD_METADATA_MIN_PX`]) rather than a second |
| 345 | /// magic pixel count -- so a future type-scale bump (this one already moved |
| 346 | /// once this session) widens the box along with the text instead of |
| 347 | /// re-wrapping it. |
| 348 | pub |
| 349 | |
| 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 | /// How many played samples one spectrum frame is transformed from. A power of |
| 401 | /// two ([`fft`] is radix-2) and the whole of the engine's tap: 1024 at 48 kHz |
| 402 | /// is a 47 Hz bin, fine enough that the bass end is a shape and short enough |
| 403 | /// (21 ms) that the analyser moves with the music. |
| 404 | pub const EQ_FFT: usize = 1024; |
| 405 | |
| 406 | /// The level range the analyser is drawn across, floor to ceiling in dBFS: the |
| 407 | /// bottom of the box is silence and the top is a bin at -12 dBFS, which is |
| 408 | /// about where a mixed track's loudest band sits. A look, not a measurement -- |
| 409 | /// the numbers on the axis are the curve's dB, never the analyser's. |
| 410 | pub const EQ_SPECTRUM_DB: = ; |