Skip to content

Show the pitch bend and the modulation wheel on field keys' status line - #195

Merged
ninjudd merged 4 commits into
mainfrom
keys/mod-display
Oct 11, 2026
Merged

ninjudd merged 4 commits into
mainfrom
keys/mod-display

Conversation

@ninjudd

@ninjudd ninjudd commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

field keys sends pitch bend from keys 1 and 2 in the default keymap, and the modulation wheel from 3 to 8. Since #188 the bloom instruments answer both: the bend moves every sounding voice up to two semitones, and the wheel adds vibrato on juno and opens the filter on bass. 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 F4

The bend always carries its sign, +0 at 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 a 0.25 bend reads +0.00 at rest, +0.25, and -1.00, while musical-typing keeps +0 and -1. Each field appears only when the keymap has keys that set it, or when its value is away from rest. musical-typing gains both; tracker and fourths, which can set neither, show nothing new. The values are what field keys sent. A USB controller's bender and wheel go straight to the receiver and do not change them, and docs/keys.md says so beside the updated examples.

Testing

From the repository root of this branch, after pnpm install:

pnpm typecheck
pnpm exec vitest run src/keys src/commands/keys.test.ts
FIELD_AUDIOD=$PWD/native/audiod/build/field-audiod_artefacts/Release/field-audiod pnpm test
project check

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: bend is -1 while 1 is held, 0 after the release, 1 while 2 is held, and 0 after a focus-out. mod starts at 0, is 76 after 6 and still 76 after its release, since set mode sends nothing on release, and is 0 after 3. A hold-mode key on controller 1 sets 90 while held and 0 on release.
  • keys.test.ts: the line reads velocity 100 · bend +0 · mod 0 · – at the start. Holding 1 over C4 gives bend -1 · mod 0 · C4 at the same length as the line at rest, and the release brings back the line at rest. mod 76 shows after 6, and the tracker keymap's line has neither field. A keymap with bends of -1 and 0.25 reads bend +0.00 at rest, bend +0.25, and bend -1.00, and one with a 0.333333 bend reads bend +0.3333.

By hand, after pnpm build: in examples/bloom, run field keys juno. Holding 1 shows bend -1 before the notes, and letting go shows bend +0. Pressing 5 shows mod 51. With a keymap of your own at ~/keymaps/mine.yaml that binds Digit2: { bend: 0.25 }, run as field keys juno --keymap ~/keymaps/mine.yaml, the line reads bend +0.00 at rest and bend +0.25 while 2 is 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 keys needs 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

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 ninjudd changed the title Show the modulation wheel on field keys' status line Show the pitch bend and the modulation wheel on field keys' status line Oct 11, 2026

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ 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.ts starts the real sclang, which this review does not run. The change does not touch the voicer.
  • src/keys/helper-native.test.ts skips its 8 tests without a native field-audiod build, 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". statusText also 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 typecheck exits 0. vitest on src/keys and src/commands/keys.test.ts, without voicer.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.scd keeps one mod for every channel, across a program reload and a server restart, so the mod on the status line is the value field keys <instrument> plays with.
  • A narrow terminal keeps the notes. At widths 70, 40, and 20, statusText cut the text before the notes, the new fields included, and kept C4 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 shows bend +0 · mod 0. No other document shows the status line, and tracker and fourths show neither field.

Comment thread src/commands/keys.ts Resolved
Comment thread docs/keys.md Resolved
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 ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ 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.ts starts the real sclang, which this review does not run. The change does not touch the voicer.
  • src/keys/helper-native.test.ts skips its 8 tests without a native field-audiod build, 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). bendText prints 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 read bend +0.00 at rest and -1.00, -0.25, +0.00, +0.50, and +1.00 while 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 typecheck exits 0. vitest on src/keys and src/commands/keys.test.ts, without voicer.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, decimalPlaces stopped at four places. Every value printed seven characters wide, from +0.3333 to -1.0000, and the notes did not move. musical-typing, whose bends are -1 and 1, still prints bend +0, -1, and +1, so the three status-line examples in docs/keys.md stay 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. At 326d629, a throwaway test showed the wheel and the bend back at 0 after a reload, panic, quit, and a focus-out. Since then session.ts has changed only by replacing setsBend with bends, and nothing still calls setsBend.
  • The instrument hears the same wheel. sc/voicer.scd keeps one mod for every channel, across a program reload and a server restart, so the mod on the status line is the value field keys <instrument> plays with.
  • A narrow terminal keeps the notes. The new fields sit before the notes, so statusText cuts them first. Its cutting code is unchanged since 326d629, 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.00 reading at rest with a 0.25 bend, which the new test in keys.test.ts pins. Its comments in keys.ts give the reason for four places and for the shared width.

@ninjudd
ninjudd marked this pull request as ready for review October 11, 2026 15:41
@ninjudd
ninjudd merged commit 4467d6f into main Oct 11, 2026
1 of 2 checks passed
@ninjudd
ninjudd deleted the keys/mod-display branch October 11, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant