diff --git a/crates/app/src/audio_cards.rs b/crates/app/src/audio_cards.rs index 5716b8a..76436eb 100644 --- a/crates/app/src/audio_cards.rs +++ b/crates/app/src/audio_cards.rs @@ -290,9 +290,7 @@ pub(crate) const EQ_W_MAX: f32 = 720.; /// rather than as a second window: it takes the width it can get inside that. pub(crate) const EQ_W_MARGIN: f32 = 32.; -/// How many bands one clip's equalizer may carry from this card: a digit picks -/// bands 1-10 and shift+digit 11-20, the same cap as the MCP `eq` op. -pub(crate) const EQ_BANDS_MAX: usize = 20; +pub(crate) const EQ_BANDS_MAX: usize = engine::eq::MAX_BANDS; /// One press of the frequency keys, as a factor: a sixth of an octave, so a /// band walks the whole axis in about sixty presses and still lands close diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index a3574ed..6cc4083 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -1598,7 +1598,7 @@ pub static FIXED:std::sync::LazyLock<[Fixed; 36]> = std::sync::LazyLock::new(|| // its own: a band nothing but a drag can reach is a band half the users of // this editor cannot move at all. Card-local, so none of them is bindable. Fixed { - chord: "1–9, 0".into(), + chord: "Tab, Shift+Tab".into(), label: "Select an equalizer band", category: Category::Audio, reach: Reach::Click("eq-graph"), diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index 22514ab..093bc78 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -4059,19 +4059,9 @@ impl Player { // the card *shows*, so it survives no further than this // window. self.eq_spectrum = !self.eq_spectrum; - } else if let Some((digit, shifted)) = key - .parse::() - .ok() - .map(|d| (d, shift)) - .or_else(|| ")!@#$%^&*(".find(key).filter(|_| key.len() == 1).map(|d| (d, true))) - { - let band = match digit { - 0 => 9, - n => n - 1, - } + if shifted { 10 } else { 0 }; - if band < self.eq_params.bands.len() { - self.eq_band = band; - } + } else if key == "tab" { + let n = self.eq_params.bands.len().max(1); + self.eq_band = if shift { (self.eq_band + n - 1) % n } else { (self.eq_band + 1) % n }; } else { return false; } diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index a9ed68b..7985229 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -679,12 +679,6 @@ fn a_band_can_be_moved_added_and_reached() { "landed at {between:?}, not between 100 and 4000" ); - const { - assert!( - EQ_BANDS_MAX <= 20, - "a band past the twentieth has no key that picks it" - ); - } assert!(EQ_BANDS_MAX > EqParams::default_layout().bands.len()); // The Q range holds the default, so a file's band never opens out of // range and needs dragging back in before it can be edited. diff --git a/crates/app/src/tests/view.rs b/crates/app/src/tests/view.rs index e4132a2..0bad2b6 100644 --- a/crates/app/src/tests/view.rs +++ b/crates/app/src/tests/view.rs @@ -1159,7 +1159,7 @@ fn an_open_card_does_not_swallow_the_document_chords() { } // ...and the strokes the cards' own branch list claims stay theirs: // escape is every card's way out, `s` is the equalizer's spectrum, `x` its - // band removal, `m` every card's maximize, and the digits pick a band. + // band removal, `m` every card's maximize, and tab picks a band. for action in [ ActionId::Deselect, ActionId::Cut, diff --git a/crates/app/src/ui/cards/eq.rs b/crates/app/src/ui/cards/eq.rs index 25837c2..4468871 100644 --- a/crates/app/src/ui/cards/eq.rs +++ b/crates/app/src/ui/cards/eq.rs @@ -307,7 +307,7 @@ impl Player { d.child(dark_card_head_reset( "Equalizer", Some(format!("{} clip {}", lane.label(), idx + 1).into()), - 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()), + 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()), Some(self.card_maximized), Some(reset_eq_layout), cx, diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 195ec73..0183a78 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -73,7 +73,7 @@ pub(crate) fn is_focus_exit_key(key: &str) -> bool { /// The room-wide chords an open card does not take. /// /// A card owns the keyboard for its own *values* -- the arrows on a slider, `r` -/// for reset, `m` for maximize, the digits on the equalizer, `enter` to apply +/// for reset, `m` for maximize, tab on the equalizer, `enter` to apply /// ([`Player::param_card_key`]'s branch list) -- and every one of those is a /// *bare* stroke its own branch claims. These five are not: each acts on the /// document rather than on the card the hand is looking at, and while a card is diff --git a/crates/engine/src/eq.rs b/crates/engine/src/eq.rs index 57bf41e..9e0d4e4 100644 --- a/crates/engine/src/eq.rs +++ b/crates/engine/src/eq.rs @@ -121,6 +121,9 @@ struct Coeffs { /// mixing console offers. Clamped, not refused: the struct's contract is that /// a deserializer may hand this over unchecked, and a project that says /// +400 dB gets +40 dB rather than a project that will not open. +/// The most bands one equalizer takes from the GUI or MCP. +pub const MAX_BANDS: usize = 20; + pub const MAX_BAND_GAIN_DB: f32 = 40.0; /// ...and the floor, the same distance the other way. Symmetric because a /// wide cut and a wide boost are the same filter run at two gains. diff --git a/crates/mcp/src/tools/edit_fx.rs b/crates/mcp/src/tools/edit_fx.rs index b0f6eff..be399e3 100644 --- a/crates/mcp/src/tools/edit_fx.rs +++ b/crates/mcp/src/tools/edit_fx.rs @@ -1242,8 +1242,8 @@ fn eq(s: &mut PlaybackSession, op: &Value) -> Result { let arr = list .as_array() .ok_or_else(|| format!("{who}: bands must be a list of {{f, db, q, kind}}, got {}", kind_of(list)))?; - if arr.len() > 20 { - return Err(format!("{who}: at most 20 bands, got {}", arr.len())); + if arr.len() > engine::eq::MAX_BANDS { + return Err(format!("{who}: at most {} bands, got {}", engine::eq::MAX_BANDS, arr.len())); } let mut bands = Vec::with_capacity(arr.len()); for (i, b) in arr.iter().enumerate() { @@ -3196,7 +3196,7 @@ mod tests { assert_eq!(eq.bands.len(), 1); assert!(close(eq.bands[0].gain_db, 3.0)); assert_eq!(eq.bands[0].kind, BandKind::Peak); - let too_many: Vec = (0..21).map(|_| json!({"f": 100, "db": 0})).collect(); + let too_many: Vec = (0..=engine::eq::MAX_BANDS).map(|_| json!({"f": 100, "db": 0})).collect(); assert!(run(&mut s, json!({"op": "eq", "clip": "A1#0", "bands": too_many})) .unwrap_err() .contains("at most 20"));