edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! The equalizer graph: its geometry, its analyser and its curve. |
| 2 | |
| 3 | use crate::*; |
| 4 | |
| 5 | /// Where a frequency sits across the graph, 0..1. Log, because an octave is an |
| 6 | /// octave whether it is 40 Hz wide or 10 kHz wide -- a linear axis would spend |
| 7 | /// three quarters of the card on the top two octaves and squeeze the bass, the |
| 8 | /// half of the range people actually reach for, into nothing. |
| 9 | pub |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | /// The frequency at a fraction across the graph -- [`eq_x`] backwards, which is |
| 15 | /// how a drag and the curve's own sample points read one. Clamped to the axis |
| 16 | /// either way, so a pointer that leaves the box stops at 20 Hz or 20 kHz. |
| 17 | pub |
| 18 | |
| 19 | |
| 20 | |
| 21 | /// The band an "add" makes: a flat peak half way -- in octaves, which is what |
| 22 | /// the log axis draws -- between the picked band and whatever sits above it, so |
| 23 | /// a new band lands in the gap on screen rather than on top of its neighbour. |
| 24 | /// Above the topmost band the gap is the rest of the axis. |
| 25 | pub |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | /// Where a gain sits *down* the graph, 0..1 from the top: flat is the middle, |
| 45 | /// so a cut reads as a dip below the line it is a cut from. The inverse of |
| 46 | /// [`Player::drag_band`]'s reading of the pointer, and clamped like it, so a |
| 47 | /// curve loaded from a file with a gain past the card's limit paints on the |
| 48 | /// edge of the box rather than outside it. |
| 49 | pub |
| 50 | |
| 51 | |
| 52 | |
| 53 | /// A frequency as the card writes it. Two decimals of a kHz at most, with the |
| 54 | /// zeroes trimmed, so "1 kHz" stays "1 kHz" and a band nudged off it reads as |
| 55 | /// 1.12 kHz rather than as the same "1 kHz" it was before the keystroke -- a |
| 56 | /// number that does not move under an edit is worse than no number. |
| 57 | |
| 58 | pub |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | /// What a band row calls itself: the corner or centre frequency, and for a |
| 68 | /// shelf the fact that it tilts everything past it -- which is the difference |
| 69 | /// between "12 kHz" moving the last octave and moving one band inside it. |
| 70 | |
| 71 | pub |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | /// The five kinds a band can be, in the order their chips lay out: the cuts at |
| 83 | /// the ends and the shelves beside the bells. Each carries the sentence its |
| 84 | /// chip's tooltip says, so a name like "shelf" is explained where it is picked. |
| 85 | pub const EQ_KINDS: = |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | ; |
| 100 | |
| 101 | /// Whether a band's gain takes part in its response. A cut ignores it -- it has |
| 102 | /// a corner to put and no level to set -- so the card does not draw its field. |
| 103 | pub |
| 104 | |
| 105 | |
| 106 | |
| 107 | /// Which of a band's numbers have left the layout the clip opens on, as |
| 108 | /// (frequency, gain, Q): what makes a number read ink1 rather than ink3. A band |
| 109 | /// has no name but its place, so it is compared with the layout's band at the |
| 110 | /// same index; one past the layout's end has no default to have left, so its |
| 111 | /// frequency and Q count as moved. Every band's gain rests at flat. |
| 112 | |
| 113 | pub |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | /// In-place radix-2 FFT of `re`/`im`, whose length must be a power of two. |
| 123 | /// |
| 124 | /// Hand-written, and deliberately: a 1024-point transform once a frame is a |
| 125 | /// few tens of microseconds of plain arithmetic, and a dependency for it would |
| 126 | /// be a build cost this editor pays on every compile for one card's backdrop. |
| 127 | pub |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | /// The played signal as one height per curve point, 0 (silence) to 1 (the top |
| 164 | /// of the box) -- the analyser the response curve is drawn on top of. |
| 165 | /// |
| 166 | /// The newest [`EQ_FFT`] samples of the engine's tap, Hann-windowed so a tone |
| 167 | /// that does not land on a bin centre is one hump rather than a smear across |
| 168 | /// the axis. Each column takes the *loudest* bin between it and its |
| 169 | /// neighbours: the axis is logarithmic, so one column near 20 Hz is a fraction |
| 170 | /// of a bin while one near 20 kHz is hundreds, and averaging those would sink |
| 171 | /// every peak up there into the noise beside it. |
| 172 | /// |
| 173 | /// Empty -- nothing to draw -- for a tap too short to transform, which is what |
| 174 | /// a session has just after a seek. |
| 175 | /// |
| 176 | /// corner-cut: one transform length for the whole axis, so the bass end is a bin |
| 177 | /// (47 Hz at 48 kHz) wide however many columns are drawn across it -- a 60 Hz |
| 178 | /// hum and an 80 Hz one are the same hump down there. Upgrade path is the |
| 179 | /// analyser every mastering EQ uses: two or three transforms of different |
| 180 | /// lengths, each drawn over the octaves it resolves. |
| 181 | pub |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | /// The analyser drawn as one filled shape from the floor of the box. |
| 222 | pub |
| 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 | /// The cascade's frequency response, drawn as one line across the graph, with |
| 248 | /// each band's own response threaded dimly under it. |
| 249 | /// |
| 250 | /// Every point comes from `EqParams::response_db`, which reads the very |
| 251 | /// coefficients the samples are filtered through: the curve cannot drift from |
| 252 | /// what is heard, because there is no second copy of the maths. A single band's |
| 253 | /// thread is that same call on a cascade of one, so the two cannot disagree |
| 254 | /// either -- and it is what makes a boost sitting inside a cut visible at all, |
| 255 | /// where the sum alone would draw a flat line and say nothing. |
| 256 | /// |
| 257 | /// corner-cut: bands that overlap can sum past the ±`EQ_GAIN_LIMIT` axis and the |
| 258 | /// curve then rides the edge of the box; upgrade = a wider dB axis with the |
| 259 | /// handles and [`Player::drag_band`] rescaled to it. |
| 260 | pub |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 |