✨ Tab and shift+tab pick the equalizer band in place of the digits, so the band cap is one engine constant the card and MCP share
Browse files at this commit5a58c77a33ca1111ec6b9e475576e04d4aa9f9d9Parent: ba1e3709 changed files +14 -29
- crates/app/src/audio_cards.rs +1 -3
- crates/app/src/keymap.rs +1 -1
- crates/app/src/player/cards.rs +3 -13
- crates/app/src/tests/cards.rs +0 -6
- crates/app/src/tests/view.rs +1 -1
- crates/app/src/ui/cards/eq.rs +1 -1
- crates/app/src/ui/stance.rs +1 -1
- crates/engine/src/eq.rs +3 -0
- crates/mcp/src/tools/edit_fx.rs +3 -3
crates/app/src/audio_cards.rsmodified+1 -3
| @@ -290,9 +290,7 @@ pub(crate) const EQ_W_MAX: f32 = 720.; | |||
| 290 | /// rather than as a second window: it takes the width it can get inside that. | 290 | /// rather than as a second window: it takes the width it can get inside that. |
| 291 | pub(crate) const EQ_W_MARGIN: f32 = 32.; | 291 | pub(crate) const EQ_W_MARGIN: f32 = 32.; |
| 292 | 292 | ||
| 293 | -/// How many bands one clip's equalizer may carry from this card: a digit picks | 293 | +pub(crate) const EQ_BANDS_MAX: usize = engine::eq::MAX_BANDS; |
| 294 | -/// bands 1-10 and shift+digit 11-20, the same cap as the MCP `eq` op. | ||
| 295 | -pub(crate) const EQ_BANDS_MAX: usize = 20; | ||
| 296 | 294 | ||
| 297 | /// One press of the frequency keys, as a factor: a sixth of an octave, so a | 295 | /// One press of the frequency keys, as a factor: a sixth of an octave, so a |
| 298 | /// band walks the whole axis in about sixty presses and still lands close | 296 | /// band walks the whole axis in about sixty presses and still lands close |
crates/app/src/keymap.rsmodified+1 -1
| @@ -1598,7 +1598,7 @@ pub static FIXED:std::sync::LazyLock<[Fixed; 36]> = std::sync::LazyLock::new(|| | |||
| 1598 | // its own: a band nothing but a drag can reach is a band half the users of | 1598 | // its own: a band nothing but a drag can reach is a band half the users of |
| 1599 | // this editor cannot move at all. Card-local, so none of them is bindable. | 1599 | // this editor cannot move at all. Card-local, so none of them is bindable. |
| 1600 | Fixed { | 1600 | Fixed { |
| 1601 | - chord: "1–9, 0".into(), | 1601 | + chord: "Tab, Shift+Tab".into(), |
| 1602 | label: "Select an equalizer band", | 1602 | label: "Select an equalizer band", |
| 1603 | category: Category::Audio, | 1603 | category: Category::Audio, |
| 1604 | reach: Reach::Click("eq-graph"), | 1604 | reach: Reach::Click("eq-graph"), |
crates/app/src/player/cards.rsmodified+3 -13
| @@ -4059,19 +4059,9 @@ impl Player { | |||
| 4059 | // the card *shows*, so it survives no further than this | 4059 | // the card *shows*, so it survives no further than this |
| 4060 | // window. | 4060 | // window. |
| 4061 | self.eq_spectrum = !self.eq_spectrum; | 4061 | self.eq_spectrum = !self.eq_spectrum; |
| 4062 | - } else if let Some((digit, shifted)) = key | 4062 | + } else if key == "tab" { |
| 4063 | - .parse::<usize>() | 4063 | + let n = self.eq_params.bands.len().max(1); |
| 4064 | - .ok() | 4064 | + self.eq_band = if shift { (self.eq_band + n - 1) % n } else { (self.eq_band + 1) % n }; |
| 4065 | - .map(|d| (d, shift)) | ||
| 4066 | - .or_else(|| ")!@#$%^&*(".find(key).filter(|_| key.len() == 1).map(|d| (d, true))) | ||
| 4067 | - { | ||
| 4068 | - let band = match digit { | ||
| 4069 | - 0 => 9, | ||
| 4070 | - n => n - 1, | ||
| 4071 | - } + if shifted { 10 } else { 0 }; | ||
| 4072 | - if band < self.eq_params.bands.len() { | ||
| 4073 | - self.eq_band = band; | ||
| 4074 | - } | ||
| 4075 | } else { | 4065 | } else { |
| 4076 | return false; | 4066 | return false; |
| 4077 | } | 4067 | } |
crates/app/src/tests/cards.rsmodified+0 -6
| @@ -679,12 +679,6 @@ fn a_band_can_be_moved_added_and_reached() { | |||
| 679 | "landed at {between:?}, not between 100 and 4000" | 679 | "landed at {between:?}, not between 100 and 4000" |
| 680 | ); | 680 | ); |
| 681 | 681 | ||
| 682 | - const { | ||
| 683 | - assert!( | ||
| 684 | - EQ_BANDS_MAX <= 20, | ||
| 685 | - "a band past the twentieth has no key that picks it" | ||
| 686 | - ); | ||
| 687 | - } | ||
| 688 | assert!(EQ_BANDS_MAX > EqParams::default_layout().bands.len()); | 682 | assert!(EQ_BANDS_MAX > EqParams::default_layout().bands.len()); |
| 689 | // The Q range holds the default, so a file's band never opens out of | 683 | // The Q range holds the default, so a file's band never opens out of |
| 690 | // range and needs dragging back in before it can be edited. | 684 | // range and needs dragging back in before it can be edited. |
crates/app/src/tests/view.rsmodified+1 -1
| @@ -1159,7 +1159,7 @@ fn an_open_card_does_not_swallow_the_document_chords() { | |||
| 1159 | } | 1159 | } |
| 1160 | // ...and the strokes the cards' own branch list claims stay theirs: | 1160 | // ...and the strokes the cards' own branch list claims stay theirs: |
| 1161 | // escape is every card's way out, `s` is the equalizer's spectrum, `x` its | 1161 | // escape is every card's way out, `s` is the equalizer's spectrum, `x` its |
| 1162 | - // band removal, `m` every card's maximize, and the digits pick a band. | 1162 | + // band removal, `m` every card's maximize, and tab picks a band. |
| 1163 | for action in [ | 1163 | for action in [ |
| 1164 | ActionId::Deselect, | 1164 | ActionId::Deselect, |
| 1165 | ActionId::Cut, | 1165 | ActionId::Cut, |
crates/app/src/ui/cards/eq.rsmodified+1 -1
| @@ -307,7 +307,7 @@ impl Player { | |||
| 307 | d.child(dark_card_head_reset( | 307 | d.child(dark_card_head_reset( |
| 308 | "Equalizer", | 308 | "Equalizer", |
| 309 | Some(format!("{} clip {}", lane.label(), idx + 1).into()), | 309 | Some(format!("{} clip {}", lane.label(), idx + 1).into()), |
| 310 | - Some("drag a handle, or a digit picks a band (shift+digit 11–20) — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum, m fills the room".into()), | 310 | + Some("drag a handle, or tab/shift+tab picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum, m fills the room".into()), |
| 311 | Some(self.card_maximized), | 311 | Some(self.card_maximized), |
| 312 | Some(reset_eq_layout), | 312 | Some(reset_eq_layout), |
| 313 | cx, | 313 | cx, |
crates/app/src/ui/stance.rsmodified+1 -1
| @@ -73,7 +73,7 @@ pub(crate) fn is_focus_exit_key(key: &str) -> bool { | |||
| 73 | /// The room-wide chords an open card does not take. | 73 | /// The room-wide chords an open card does not take. |
| 74 | /// | 74 | /// |
| 75 | /// A card owns the keyboard for its own *values* -- the arrows on a slider, `r` | 75 | /// A card owns the keyboard for its own *values* -- the arrows on a slider, `r` |
| 76 | -/// for reset, `m` for maximize, the digits on the equalizer, `enter` to apply | 76 | +/// for reset, `m` for maximize, tab on the equalizer, `enter` to apply |
| 77 | /// ([`Player::param_card_key`]'s branch list) -- and every one of those is a | 77 | /// ([`Player::param_card_key`]'s branch list) -- and every one of those is a |
| 78 | /// *bare* stroke its own branch claims. These five are not: each acts on the | 78 | /// *bare* stroke its own branch claims. These five are not: each acts on the |
| 79 | /// document rather than on the card the hand is looking at, and while a card is | 79 | /// document rather than on the card the hand is looking at, and while a card is |
crates/engine/src/eq.rsmodified+3 -0
| @@ -121,6 +121,9 @@ struct Coeffs { | |||
| 121 | /// mixing console offers. Clamped, not refused: the struct's contract is that | 121 | /// mixing console offers. Clamped, not refused: the struct's contract is that |
| 122 | /// a deserializer may hand this over unchecked, and a project that says | 122 | /// a deserializer may hand this over unchecked, and a project that says |
| 123 | /// +400 dB gets +40 dB rather than a project that will not open. | 123 | /// +400 dB gets +40 dB rather than a project that will not open. |
| 124 | +/// The most bands one equalizer takes from the GUI or MCP. | ||
| 125 | +pub const MAX_BANDS: usize = 20; | ||
| 126 | + | ||
| 124 | pub const MAX_BAND_GAIN_DB: f32 = 40.0; | 127 | pub const MAX_BAND_GAIN_DB: f32 = 40.0; |
| 125 | /// ...and the floor, the same distance the other way. Symmetric because a | 128 | /// ...and the floor, the same distance the other way. Symmetric because a |
| 126 | /// wide cut and a wide boost are the same filter run at two gains. | 129 | /// wide cut and a wide boost are the same filter run at two gains. |
crates/mcp/src/tools/edit_fx.rsmodified+3 -3
| @@ -1242,8 +1242,8 @@ fn eq(s: &mut PlaybackSession, op: &Value) -> Result<Applied, String> { | |||
| 1242 | let arr = list | 1242 | let arr = list |
| 1243 | .as_array() | 1243 | .as_array() |
| 1244 | .ok_or_else(|| format!("{who}: bands must be a list of {{f, db, q, kind}}, got {}", kind_of(list)))?; | 1244 | .ok_or_else(|| format!("{who}: bands must be a list of {{f, db, q, kind}}, got {}", kind_of(list)))?; |
| 1245 | - if arr.len() > 20 { | 1245 | + if arr.len() > engine::eq::MAX_BANDS { |
| 1246 | - return Err(format!("{who}: at most 20 bands, got {}", arr.len())); | 1246 | + return Err(format!("{who}: at most {} bands, got {}", engine::eq::MAX_BANDS, arr.len())); |
| 1247 | } | 1247 | } |
| 1248 | let mut bands = Vec::with_capacity(arr.len()); | 1248 | let mut bands = Vec::with_capacity(arr.len()); |
| 1249 | for (i, b) in arr.iter().enumerate() { | 1249 | for (i, b) in arr.iter().enumerate() { |
| @@ -3196,7 +3196,7 @@ mod tests { | |||
| 3196 | assert_eq!(eq.bands.len(), 1); | 3196 | assert_eq!(eq.bands.len(), 1); |
| 3197 | assert!(close(eq.bands[0].gain_db, 3.0)); | 3197 | assert!(close(eq.bands[0].gain_db, 3.0)); |
| 3198 | assert_eq!(eq.bands[0].kind, BandKind::Peak); | 3198 | assert_eq!(eq.bands[0].kind, BandKind::Peak); |
| 3199 | - let too_many: Vec<Value> = (0..21).map(|_| json!({"f": 100, "db": 0})).collect(); | 3199 | + let too_many: Vec<Value> = (0..=engine::eq::MAX_BANDS).map(|_| json!({"f": 100, "db": 0})).collect(); |
| 3200 | assert!(run(&mut s, json!({"op": "eq", "clip": "A1#0", "bands": too_many})) | 3200 | assert!(run(&mut s, json!({"op": "eq", "clip": "A1#0", "bands": too_many})) |
| 3201 | .unwrap_err() | 3201 | .unwrap_err() |
| 3202 | .contains("at most 20")); | 3202 | .contains("at most 20")); |