forge
Explore
Log in

Don't you dare go Hollow

✨ 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 commit

5a58c77a33ca1111ec6b9e475576e04d4aa9f9d9Ahmet Kaan GümüşParent: ba1e370
crates/app/src/audio_cards.rsmodified+1 -3
@@ -290,9 +290,7 @@ pub(crate) const EQ_W_MAX: f32 = 720.;
290290 /// rather than as a second window: it takes the width it can get inside that.
291291 pub(crate) const EQ_W_MARGIN: f32 = 32.;
292292
293-/// How many bands one clip's equalizer may carry from this card: a digit picks
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;
293+pub(crate) const EQ_BANDS_MAX: usize = engine::eq::MAX_BANDS;
296294
297295 /// One press of the frequency keys, as a factor: a sixth of an octave, so a
298296 /// 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(||
15981598 // its own: a band nothing but a drag can reach is a band half the users of
15991599 // this editor cannot move at all. Card-local, so none of them is bindable.
16001600 Fixed {
1601- chord: "1–9, 0".into(),
1601+ chord: "Tab, Shift+Tab".into(),
16021602 label: "Select an equalizer band",
16031603 category: Category::Audio,
16041604 reach: Reach::Click("eq-graph"),
crates/app/src/player/cards.rsmodified+3 -13
@@ -4059,19 +4059,9 @@ impl Player {
40594059 // the card *shows*, so it survives no further than this
40604060 // window.
40614061 self.eq_spectrum = !self.eq_spectrum;
4062- } else if let Some((digit, shifted)) = key
4063- .parse::<usize>()
4064- .ok()
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- }
4062+ } else if key == "tab" {
4063+ let n = self.eq_params.bands.len().max(1);
4064+ self.eq_band = if shift { (self.eq_band + n - 1) % n } else { (self.eq_band + 1) % n };
40754065 } else {
40764066 return false;
40774067 }
crates/app/src/tests/cards.rsmodified+0 -6
@@ -679,12 +679,6 @@ fn a_band_can_be_moved_added_and_reached() {
679679 "landed at {between:?}, not between 100 and 4000"
680680 );
681681
682- const {
683- assert!(
684- EQ_BANDS_MAX <= 20,
685- "a band past the twentieth has no key that picks it"
686- );
687- }
688682 assert!(EQ_BANDS_MAX > EqParams::default_layout().bands.len());
689683 // The Q range holds the default, so a file's band never opens out of
690684 // 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() {
11591159 }
11601160 // ...and the strokes the cards' own branch list claims stay theirs:
11611161 // 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.
11631163 for action in [
11641164 ActionId::Deselect,
11651165 ActionId::Cut,
crates/app/src/ui/cards/eq.rsmodified+1 -1
@@ -307,7 +307,7 @@ impl Player {
307307 d.child(dark_card_head_reset(
308308 "Equalizer",
309309 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()),
311311 Some(self.card_maximized),
312312 Some(reset_eq_layout),
313313 cx,
crates/app/src/ui/stance.rsmodified+1 -1
@@ -73,7 +73,7 @@ pub(crate) fn is_focus_exit_key(key: &str) -> bool {
7373 /// The room-wide chords an open card does not take.
7474 ///
7575 /// 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
7777 /// ([`Player::param_card_key`]'s branch list) -- and every one of those is a
7878 /// *bare* stroke its own branch claims. These five are not: each acts on the
7979 /// 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 {
121121 /// mixing console offers. Clamped, not refused: the struct's contract is that
122122 /// a deserializer may hand this over unchecked, and a project that says
123123 /// +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+
124127 pub const MAX_BAND_GAIN_DB: f32 = 40.0;
125128 /// ...and the floor, the same distance the other way. Symmetric because a
126129 /// 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> {
12421242 let arr = list
12431243 .as_array()
12441244 .ok_or_else(|| format!("{who}: bands must be a list of {{f, db, q, kind}}, got {}", kind_of(list)))?;
1245- if arr.len() > 20 {
1246- return Err(format!("{who}: at most 20 bands, got {}", arr.len()));
1245+ if arr.len() > engine::eq::MAX_BANDS {
1246+ return Err(format!("{who}: at most {} bands, got {}", engine::eq::MAX_BANDS, arr.len()));
12471247 }
12481248 let mut bands = Vec::with_capacity(arr.len());
12491249 for (i, b) in arr.iter().enumerate() {
@@ -3196,7 +3196,7 @@ mod tests {
31963196 assert_eq!(eq.bands.len(), 1);
31973197 assert!(close(eq.bands[0].gain_db, 3.0));
31983198 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();
32003200 assert!(run(&mut s, json!({"op": "eq", "clip": "A1#0", "bands": too_many}))
32013201 .unwrap_err()
32023202 .contains("at most 20"));