Repository navigation
Show the pitch bend and the modulation wheel on field keys' status line - #195
Conversation
The session remembers the last value it sent on CC 1, and the status line shows it as mod 0 to 127 after the velocity whenever the keymap has keys that set the wheel, or the wheel is not at 0. Notes stay last. musical-typing's 3 to 8 now show where the wheel is; tracker and fourths, which cannot set it, show nothing new.
The session remembers the bend it sent, from -1 to 1, back to 0 on release, and the status line shows it before the wheel as bend +0, -1, or +1. The sign is always there, so bending a held chord does not move the notes after it. Keymaps with no bend key show nothing new.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 6m 59s over 2 heads
This change shows the pitch bend and the modulation wheel on the field keys status line, so a player can see whether a bend key registered and where the wheel sits. KeysSession now records the bend it last sent, from -1 to 1, and the last value it sent on controller 1 (CC 1, the modulation wheel). That includes the 0 it sends when a hold key is released and when panic, a keymap reload, or quit turns off a toggled controller. statusText prints the two as bend +0 and mod 0 after the velocity and before the notes, but only when the keymap has keys that set them or their value is away from rest. The bend always carries its sign, so that bending a held chord does not move the notes along the line. A hardware controller's bender and wheel stay out of scope on purpose, because field keys never reads them.
2 finding threads: 0 resolved, 2 open
Covered 5 of 5 changed files; no generated files.
The head moved from 2c6b3d3 to 326d629 during this review, adding the bend readout. The review covers the whole pull request at 326d629. Two test files did not run:
src/keys/voicer.test.tsstarts the realsclang, which this review does not run. The change does not touch the voicer.src/keys/helper-native.test.tsskips its 8 tests without a nativefield-audiodbuild, which the review's checkout does not have. The change does not touch the helper.
Suggestions
docs/keys.md:58: step 3 says the line shows the bend and the wheel "when the keymap has keys that set them".statusTextalso shows each one while its value is away from rest. That happens after you save a keymap that drops those keys while a bend key is held or the wheel is up. Add that clause, as the pull request body says.docs/keys.md:62: write "a USB controller's bender and wheel", the term lines 86 and 106 use, because the keymap table at line 433 uses "Controller n" for a controller number.
What I checked
- Typecheck and tests pass.
pnpm typecheckexits 0.vitestonsrc/keysandsrc/commands/keys.test.ts, withoutvoicer.test.ts, passes 97 tests and skips 8. - Each value matches what the session sends. Every controller message goes through
KeysSession.cc, which records the value whenever the controller is 1. The bend is set beside the pitch-bend message on a press and cleared beside the center message on the release. A throwaway test at this head showed a toggle key on the wheel reading 0 after a reload, panic, and quit, a hold key reading 0 after a focus-out, and the bend reading 0 after panic, quit, and a focus-out. - The instrument hears the same wheel.
sc/voicer.scdkeeps onemodfor every channel, across a program reload and a server restart, so themodon the status line is the valuefield keys <instrument>plays with. - A narrow terminal keeps the notes. At widths 70, 40, and 20,
statusTextcut the text before the notes, the new fields included, and keptC4 E4. At width 5 it printed only the notes. - The examples match the code. The three status-line examples use
musical-typing, which binds both controls, so each showsbend +0 · mod 0. No other document shows the status line, andtrackerandfourthsshow neither field.
Step 3 of the Play steps in docs/keys.md had one line of 100 columns, where the rest of the list wraps at 72. The step now wraps at 72 too. It also says that the line shows the bend and the wheel while their value is away from rest, as statusText does, and names a USB controller's bender and wheel, the term the rest of the page uses.
statusText printed the bend as its sign and Math.abs(bend), so a keymap with a fractional bend widened the field while the bend key was held: `bend +0` at rest became `bend +0.25`, and the notes after it moved three columns. The keymap schema allows any bend from -1 to 1. The bend now prints with as many decimal places as the finest bend in the keymap needs, up to four, which is about as fine as a 14-bit pitch-bend message carries it. musical-typing still reads `bend +0` and `bend -1`; a keymap with a 0.25 bend reads `bend +0.00` at rest. KeysSession.bends() returns the keymap's bends in place of setsBend(), so the status line can size the field from them.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CLEAN · took 2m 02s
This change shows the pitch bend and the modulation wheel on the field keys status line, so a player can see whether a bend key registered and where the wheel sits. KeysSession records the bend it last sent and the last value it sent on controller 1 (CC 1, the modulation wheel). That includes the 0 it sends when a hold key is released and when panic, a keymap reload, or quit turns off a toggled controller. statusText prints the two as bend and mod after the velocity and before the notes, when the keymap has keys that set them or their value is away from rest. Since the last review, the bend prints with its sign and with as many decimal places as the finest bend in the keymap needs, up to four, so every bend the keymap can send takes one width. A hardware controller's bender and wheel stay out of scope on purpose, because field keys never reads them.
2 finding threads: 2 resolved, 0 open
Covered 5 of 5 changed files; no generated files.
Two test files did not run:
src/keys/voicer.test.tsstarts the realsclang, which this review does not run. The change does not touch the voicer.src/keys/helper-native.test.tsskips its 8 tests without a nativefield-audiodbuild, which the review's checkout does not have. The change does not touch the helper.
Both findings from the review of 326d629 are fixed at this head:
- The bend readout keeps one width (
src/commands/keys.ts).bendTextprints every bend with the decimal places of the finest bend in the keymap. With a keymap that binds -1, -0.25, 0, 0.5, and 1, the field readbend +0.00at rest and-1.00,-0.25,+0.00,+0.50, and+1.00while each key was held. A held chord stayed at column 59 throughout, and each release brought back the line at rest. - Step 3 of the Play steps wraps like the rest of the list (
docs/keys.md). Lines 57 to 68 now run 64 to 72 columns. The step also takes both suggestions from that review.
What I checked
- Typecheck and tests pass.
pnpm typecheckexits 0.vitestonsrc/keysandsrc/commands/keys.test.ts, withoutvoicer.test.ts, passes 98 tests and skips 8. - A keymap with finer bends also holds one width. With bends of 0.333333, -1, 0.00001, and 0.99999,
decimalPlacesstopped at four places. Every value printed seven characters wide, from+0.3333to-1.0000, and the notes did not move.musical-typing, whose bends are -1 and 1, still printsbend +0,-1, and+1, so the three status-line examples indocs/keys.mdstay right. - Each value matches what the session sends. Every controller message goes through
KeysSession.cc, which records the value whenever the controller is 1. The bend is set beside the pitch-bend message on a press and cleared beside the center message on the release. At326d629, a throwaway test showed the wheel and the bend back at 0 after a reload, panic, quit, and a focus-out. Since thensession.tshas changed only by replacingsetsBendwithbends, and nothing still callssetsBend. - The instrument hears the same wheel.
sc/voicer.scdkeeps onemodfor every channel, across a program reload and a server restart, so themodon the status line is the valuefield keys <instrument>plays with. - A narrow terminal keeps the notes. The new fields sit before the notes, so
statusTextcuts them first. Its cutting code is unchanged since326d629, where widths 70, 40, and 20 kept the notes and width 5 printed only the notes. - The docs match the code. Step 3 states the away-from-rest case, the decimal places, and the
+0.00reading at rest with a 0.25 bend, which the new test inkeys.test.tspins. Its comments inkeys.tsgive the reason for four places and for the shared width.
field keyssends pitch bend from keys1and2in the default keymap, and the modulation wheel from3to8. Since #188 the bloom instruments answer both: the bend moves every sounding voice up to two semitones, and the wheel adds vibrato onjunoand opens the filter onbass. But the status line said nothing about either, so you couldn't see whether a bend key had registered, or where the wheel sat after a few presses. Justin asked for both on screen while playing on 2026-10-11. The bend matters for a second reason: a laptop keyboard can drop a key pressed while three others are held, and the line is how you tell a key that never arrived from a bend that didn't sound.The session now remembers what it last sent. The bend runs from -1 to 1 and returns to 0 when its key is released or the terminal loses focus. The wheel is the last value sent on controller 1, including a hold-mode key's return to 0 and the resets at panic, reload, and quit. The status line shows both after the velocity, so the notes still come last:
Field Keys · musical-typing · transpose 0 · velocity 100 · bend -1 · mod 76 · C4 E4 F4The bend always carries its sign,
+0at rest, and prints with as many decimal places as the finest bend in the keymap needs, up to four, so bending a held chord does not shift the notes along the line. A keymap with a0.25bend reads+0.00at rest,+0.25, and-1.00, whilemusical-typingkeeps+0and-1. Each field appears only when the keymap has keys that set it, or when its value is away from rest.musical-typinggains both;trackerandfourths, which can set neither, show nothing new. The values are whatfield keyssent. A USB controller's bender and wheel go straight to the receiver and do not change them, anddocs/keys.mdsays so beside the updated examples.Testing
From the repository root of this branch, after
pnpm install:The typecheck passes, and the keys tests pass 100 with 8 skipped. Those 8 need a native build, which my worktree did not have. The full suite, run against a daemon built from
main's native code, passes 1029 with 3 skipped. These cases pin the change:session.test.ts:bendis -1 while1is held, 0 after the release, 1 while2is held, and 0 after a focus-out.modstarts at 0, is 76 after6and still 76 after its release, since set mode sends nothing on release, and is 0 after3. A hold-mode key on controller 1 sets 90 while held and 0 on release.keys.test.ts: the line readsvelocity 100 · bend +0 · mod 0 · –at the start. Holding1over C4 givesbend -1 · mod 0 · C4at the same length as the line at rest, and the release brings back the line at rest.mod 76shows after6, and thetrackerkeymap's line has neither field. A keymap with bends of -1 and 0.25 readsbend +0.00at rest,bend +0.25, andbend -1.00, and one with a0.333333bend readsbend +0.3333.By hand, after
pnpm build: inexamples/bloom, runfield keys juno. Holding1showsbend -1before the notes, and letting go showsbend +0. Pressing5showsmod 51. With a keymap of your own at~/keymaps/mine.yamlthat bindsDigit2: { bend: 0.25 }, run asfield keys juno --keymap ~/keymaps/mine.yaml, the line readsbend +0.00at rest andbend +0.25while2is held, at the same length. A field that does not change when you press its key, a line whose notes move as you bend, or a field after the notes would mean the change is wrong. I couldn't watch the line myself:field keysneeds a terminal that speaks the kitty keyboard protocol, and this session has none. Nothing is left behind.📽️ Projector summary of a5ae0a4: https://field.amnes.ac/reviews/195