From d3fd7407cc0c7c7a872af9591bab24e362a02f79 Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Wed, 2 Dec 2026 16:19:28 +0100 Subject: [PATCH 1/9] Docs: propose base hooks for NRPN on a MIDI track's CTRL knobs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...-12-02-octatrack-midi-ctrl-hooks-design.md | 1 + docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 66 +++++++++++++++++++ docs/README.md | 1 + 3 files changed, 68 insertions(+) create mode 100644 changelog/2026-12-02-octatrack-midi-ctrl-hooks-design.md create mode 100644 docs/OCTATRACK_MIDI_CTRL_HOOKS.md diff --git a/changelog/2026-12-02-octatrack-midi-ctrl-hooks-design.md b/changelog/2026-12-02-octatrack-midi-ctrl-hooks-design.md new file mode 100644 index 0000000000..583baff63d --- /dev/null +++ b/changelog/2026-12-02-octatrack-midi-ctrl-hooks-design.md @@ -0,0 +1 @@ +Octatrack: a design for NRPN on a MIDI track's CTRL knobs. It proposes the base hooks first; nothing is built and nothing changes on the unit. diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md new file mode 100644 index 0000000000..15bb65acca --- /dev/null +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -0,0 +1,66 @@ +# MIDI track CTRL SETUP hooks and NRPN (design, for owner review) + +Status, 2 December 2026: a proposal for the Octatrack's cumulative base. Nothing is built and nothing ran on a unit. +Every address comes from the reading of the 1.40C image in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md), +which was not run on a unit. Sites marked *not located* have no address yet: the entries, lengths and guards in +`events.json` are added once the base is rebuilt against a real OS file (CI has no firmware). + +## Why + +A MIDI track's CTRL1 and CTRL2 pages send CC 0-127 only. The first module, **MIDI NRPN** (draft #2538), adds NRPN +to those knobs: past CC 127 in a knob's SETUP list the value reads `NRPN`, and pressing the knob there opens a page for +the NRPN number (MSB, LSB) and the value size (7 or 14 bit). A knob set to NRPN sends and receives that parameter. + +Stock offers no way to do this without patching its sites, and those sites are shared with other work: CC Map patches +the CC handler, and the Midi Mode 2 draft (`sdk/drafts/midi-cc-slots`) reuses CTRL1 SETUP's hidden bytes. Brain-style +modules that rename CTRL knobs reach the same page. So the sites belong in the base, and the NRPN module is the first +subscriber. It builds and works as the only module chosen. + +## What is proposed + +| Hook | Kind | Stock site | When | Why the base, not the module | +| --- | --- | --- | --- | --- | +| `ev_midi_cc` | call | 0x4000e79c (proposed in #2436) | an incoming CC reaches stock's CC handler | NRPN is the second subscriber after the post-FX2 filter: it **reuses** #2436's hook and adds none | +| `ev_ctrl_setup_knob` | take | *not located*: the encoder callbacks that call the writers 0x4003fd34 (CC1-4) and 0x4003f80c (CC5-10) | an encoder turns on CTRL1 or CTRL2 SETUP, before the writer's `cc <= 127` check | stock clamps at 127, so the number cannot go on without taking the turn | +| `ev_ctrl_setup_text` | take | the value-name lookups 0x4003fb32 (CTRL1 draw 0x4003f9ac) and 0x4003f60c (CTRL2 draw 0x4003f490) | SETUP is about to print a slot's value text (the CC name table 0x400be882, `%.8s`) | the row must read `NRPN` and, on its page, the MSB, LSB and size | +| `ev_ctrl_setup_press` | take | *not located*: the knob-press code near 0x4004ed74..0x4004ef24 handles the page-1 enable bits; SETUP's press is another path | a knob is pressed on CTRL1 or CTRL2 SETUP | opens the NRPN page; stock's press on SETUP does nothing the module needs to keep | +| `ev_ctrl_value_send` | take | 0x4009eec8 (sends one page-1 value: `t`, `flat` 18 PB, 19 AT, 20-29 CC, `value`, `force`) | stock is about to send a MIDI track's knob value | one site covers a knob turn, an LFO, a p-lock and a scene, so an NRPN knob sends the same way in each | + +The three SETUP hooks follow the precedent of `ev_arp_setup_knob` and `ev_arp_setup_text`: a take hook that gives one +subscriber the turn or the draw, with `claims` limited to the slot it owns, and that replays stock for everything else. +Their prototypes mirror those two, with the slot (0-9) and the track as arguments. The order bands: 10-29 for a module +that owns a slot's number, 40-69 for one that only observes. + +## How NRPN uses them + +- **Storage.** Stock clamps every Part byte of a MIDI track to its page's range, so an NRPN number cannot live there. + The module keeps a sparse list in the project's `project.work` (`ev_project_load`, `ev_project_write`), keyed by + bank, Part, track and slot, with the MSB, LSB and size. The stock CC byte of an NRPN knob holds 127, so with the + module removed the knob falls back to a plain CC 127 and nothing breaks. A list entry marks the knob as NRPN. +- **Sending.** At `ev_ctrl_value_send` the module takes a value on an NRPN knob and sends CC 99 and CC 98 (only when + the number differs from the last one sent on that channel), then CC 6 and, in 14 bit, CC 38, through stock's send + primitive 0x40010bc8. Everything else returns to stock. +- **14 bit.** The knob's value is one byte (0-127), so 14 bit gives the full parameter range, not finer steps: the + module sends `value * 16383 / 127`. Finer steps would need the encoder's own resolution, which this does not propose. +- **Receiving.** At `ev_midi_cc` the module takes CC 99, 98, 6 and 38, and only while an NRPN knob is set on that + channel. A complete NRPN sets the knob's value through the page-1 writer 0x40054cd8 (`8 + t`, `20 + slot`), which + calls 0x4009eec8; the module marks that write so `ev_ctrl_value_send` does not send it straight back out. +- **RPN and the rest.** CC 101 and 100 pass to stock, and an RPN select ends a pending NRPN select. Notes, clock, + start, stop and SysEx are not touched. + +## Open questions for the owner + +1. Are these four SETUP and send hooks worth the base's ABI, given three users (NRPN, Midi Mode 2, CTRL knob labels)? + If not, NRPN stays a module that patches these sites and declares them as `uiClaims`. +2. Does a MIDI track's incoming CC change its knobs today, or does stock ignore it? NRPN receive assumes it does not; + to be read from the image before any build. +3. One page for the NRPN fields drawn through `ev_ctrl_setup_text`, or a base-owned module page? +4. NRPN in `project.work` per Part (as proposed), or per project? +5. 14 bit as a scaled 7-bit knob, or wait for finer encoder steps? + +## What comes next + +After the owner answers: trace the three *not located* sites in the 1.40C image, add the entries to `events.json` +with their guards, regenerate with `python3 -B sdk/machines/octatrack/events.py --write`, and give each hook its +subscriber in the MIDI NRPN module (so `test_hook_coverage.py` passes). Test on a unit: the send, the receive and a +module removed while an NRPN knob is set. CC Map moves to `ev_midi_cc` as #2436 describes. diff --git a/docs/README.md b/docs/README.md index 3d736814df..ea4e7934c3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -48,6 +48,7 @@ Every document in `docs/`, one line each. [AGENTS.md](../AGENTS.md) says which t - [OCTATRACK_HARDWARE_TRAPS.md](OCTATRACK_HARDWARE_TRAPS.md): what fails on a real unit: the base, the USB link, RAM boot, the DSP loader. - [OCTATRACK_LFO_PMTR_EXTENSION.md](OCTATRACK_LFO_PMTR_EXTENSION.md): base-owned audio LFO SETUP destinations past stock 0–29 (`ot_lfo_pmtr_dest`). +- [OCTATRACK_MIDI_CTRL_HOOKS.md](OCTATRACK_MIDI_CTRL_HOOKS.md): proposed hooks on a MIDI track's CTRL SETUP and knob send, for NRPN (design). - [OCTATRACK_CARD_WRITES.md](OCTATRACK_CARD_WRITES.md): cold starts, card-write interrupts and every path that writes the card. - [OCTATRACK_TWO_SLOT_BASE.md](OCTATRACK_TWO_SLOT_BASE.md): base updates a power cut can't brick: two slots, a boot stub, the update on the unit's screen. - [OCTATRACK_DRIVING.md](OCTATRACK_DRIVING.md): working a unit over USB from an agent. From a82ab747d18e8198202149fe45c17e5c3ec9df0f Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Wed, 2 Dec 2026 16:59:32 +0100 Subject: [PATCH 2/9] Docs: add the CTRL SETUP sites read in the 1.40C image Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md index 15bb65acca..836eccaa64 100644 --- a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -2,8 +2,9 @@ Status, 2 December 2026: a proposal for the Octatrack's cumulative base. Nothing is built and nothing ran on a unit. Every address comes from the reading of the 1.40C image in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md), -which was not run on a unit. Sites marked *not located* have no address yet: the entries, lengths and guards in -`events.json` are added once the base is rebuilt against a real OS file (CI has no firmware). +which was not run on a unit, and from a second reading of the same image on 2 December 2026 (below). Neither reading +ran on a unit. The entries, lengths and guards in `events.json` are added after the owner's answers, built against a +real OS file (CI has no firmware). ## Why @@ -21,9 +22,9 @@ subscriber. It builds and works as the only module chosen. | Hook | Kind | Stock site | When | Why the base, not the module | | --- | --- | --- | --- | --- | | `ev_midi_cc` | call | 0x4000e79c (proposed in #2436) | an incoming CC reaches stock's CC handler | NRPN is the second subscriber after the post-FX2 filter: it **reuses** #2436's hook and adds none | -| `ev_ctrl_setup_knob` | take | *not located*: the encoder callbacks that call the writers 0x4003fd34 (CC1-4) and 0x4003f80c (CC5-10) | an encoder turns on CTRL1 or CTRL2 SETUP, before the writer's `cc <= 127` check | stock clamps at 127, so the number cannot go on without taking the turn | +| `ev_ctrl_setup_knob` | take | the value callback 0x4004ae08 (see below); the clamp itself is in the setup writers 0x4003fd34 (CC1-4) and 0x4003f80c (CC5-10) | an encoder turns on CTRL1 or CTRL2 SETUP, before the writer's `cc <= 127` check | stock clamps at 127, so the number cannot go on without taking the turn | | `ev_ctrl_setup_text` | take | the value-name lookups 0x4003fb32 (CTRL1 draw 0x4003f9ac) and 0x4003f60c (CTRL2 draw 0x4003f490) | SETUP is about to print a slot's value text (the CC name table 0x400be882, `%.8s`) | the row must read `NRPN` and, on its page, the MSB, LSB and size | -| `ev_ctrl_setup_press` | take | *not located*: the knob-press code near 0x4004ed74..0x4004ef24 handles the page-1 enable bits; SETUP's press is another path | a knob is pressed on CTRL1 or CTRL2 SETUP | opens the NRPN page; stock's press on SETUP does nothing the module needs to keep | +| `ev_ctrl_setup_press` | take | the per-slot event callbacks 0x4004acf8, 0x4004ad80 and their siblings, on event 1 (see below) | a knob is pressed on CTRL1 or CTRL2 SETUP | opens the NRPN page; stock's press on SETUP does nothing the module needs to keep | | `ev_ctrl_value_send` | take | 0x4009eec8 (sends one page-1 value: `t`, `flat` 18 PB, 19 AT, 20-29 CC, `value`, `force`) | stock is about to send a MIDI track's knob value | one site covers a knob turn, an LFO, a p-lock and a scene, so an NRPN knob sends the same way in each | The three SETUP hooks follow the precedent of `ev_arp_setup_knob` and `ev_arp_setup_text`: a take hook that gives one @@ -31,6 +32,24 @@ subscriber the turn or the draw, with `claims` limited to the slot it owns, and Their prototypes mirror those two, with the slot (0-9) and the track as arguments. The order bands: 10-29 for a module that owns a slot's number, 40-69 for one that only observes. +## Sites found in the 1.40C image (2 December 2026) + +Read with `m68k-elf-objdump -m m68k:cfv4e` from the main OS section, `address = 0x40000400 + file offset`. Not run on a unit. + +- **The page.** CTRL1 SETUP is a window. 0x40059620 builds it (or jumps to its destroy function when it exists) and + keeps it at 0x400bc9ba; its descriptor holds the destroy function 0x400567e0 and the draw 0x4003f9ac. CTRL2 has the + same layout: build 0x4005948c, destroy 0x400567b8, draw 0x4003f490 (its window address is not read yet). +- **Per-slot rows.** The window's element table (from 0x400bc9de, one 0x20-byte entry a row, ids 0x38, 0x39, 0x3a, ...) + points every row at 0x4004acf8 or its siblings (0x4004ad80, ...). On event 1 such a callback sets the 0x46104cb4 + flag, redraws through 0x4003f9ac, stores the row's slot in 0x46c7d23c and opens an edit overlay through 0x4006d57c. + This is the best candidate for `ev_ctrl_setup_press`. +- **The value write.** 0x4004ae08 receives a row and its new value, writes the byte into the setup record + (`+0x8f262`) and its live copy, sets the dirty bits, calls 0x40027e00 and 0x40036548 and ends in the program and bank + send 0x4009ec70. This is the candidate for `ev_ctrl_setup_knob`. +- **Not yet confirmed.** That 0x4004ae08 is the path for every CTRL1 and CTRL2 row and not for some only; where the + encoder reaches it; and the CTRL2 siblings of the row callbacks. `ev_ctrl_setup_text` stays on the 0x4003fb32 and + 0x4003f60c lookups from MIDI_TRACKS.md. + ## How NRPN uses them - **Storage.** Stock clamps every Part byte of a MIDI track to its page's range, so an NRPN number cannot live there. @@ -60,7 +79,7 @@ that owns a slot's number, 40-69 for one that only observes. ## What comes next -After the owner answers: trace the three *not located* sites in the 1.40C image, add the entries to `events.json` +After the owner answers: confirm the sites above on a unit (and the unconfirmed ones in the image), add the entries to `events.json` with their guards, regenerate with `python3 -B sdk/machines/octatrack/events.py --write`, and give each hook its subscriber in the MIDI NRPN module (so `test_hook_coverage.py` passes). Test on a unit: the send, the receive and a module removed while an NRPN knob is set. CC Map moves to `ev_midi_cc` as #2436 describes. From d6babfa1a827f3f233c9e45392c3226a87e465a4 Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Thu, 3 Dec 2026 19:34:52 +0100 Subject: [PATCH 3/9] Docs: record NRPN hook decisions and correct setup site Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 62 +++++++++++++++++-------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md index 836eccaa64..d3eb8bc5cf 100644 --- a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -1,10 +1,11 @@ # MIDI track CTRL SETUP hooks and NRPN (design, for owner review) -Status, 2 December 2026: a proposal for the Octatrack's cumulative base. Nothing is built and nothing ran on a unit. +Status, 3 December 2026: the owner agreed to the proposed hooks, subject to the unit checks below. The proposed hooks +and module are not built; no site checks ran on a unit. Every address comes from the reading of the 1.40C image in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md), which was not run on a unit, and from a second reading of the same image on 2 December 2026 (below). Neither reading -ran on a unit. The entries, lengths and guards in `events.json` are added after the owner's answers, built against a -real OS file (CI has no firmware). +ran on a unit. Hook indices must not be claimed before those checks. Entries, lengths and guards in `events.json` +need a real OS file (CI has no firmware). ## Why @@ -22,9 +23,9 @@ subscriber. It builds and works as the only module chosen. | Hook | Kind | Stock site | When | Why the base, not the module | | --- | --- | --- | --- | --- | | `ev_midi_cc` | call | 0x4000e79c (proposed in #2436) | an incoming CC reaches stock's CC handler | NRPN is the second subscriber after the post-FX2 filter: it **reuses** #2436's hook and adds none | -| `ev_ctrl_setup_knob` | take | the value callback 0x4004ae08 (see below); the clamp itself is in the setup writers 0x4003fd34 (CC1-4) and 0x4003f80c (CC5-10) | an encoder turns on CTRL1 or CTRL2 SETUP, before the writer's `cc <= 127` check | stock clamps at 127, so the number cannot go on without taking the turn | +| `ev_ctrl_setup_knob` | take | *not located*: the encoder path to the CTRL1 and CTRL2 writers; 0x4004ae08 is a NOTE SETUP writer, not a confirmed CTRL writer (see below) | an encoder turns on CTRL1 or CTRL2 SETUP, before the writer's `cc <= 127` check | stock clamps at 127, so the number cannot go on without taking the turn | | `ev_ctrl_setup_text` | take | the value-name lookups 0x4003fb32 (CTRL1 draw 0x4003f9ac) and 0x4003f60c (CTRL2 draw 0x4003f490) | SETUP is about to print a slot's value text (the CC name table 0x400be882, `%.8s`) | the row must read `NRPN` and, on its page, the MSB, LSB and size | -| `ev_ctrl_setup_press` | take | the per-slot event callbacks 0x4004acf8, 0x4004ad80 and their siblings, on event 1 (see below) | a knob is pressed on CTRL1 or CTRL2 SETUP | opens the NRPN page; stock's press on SETUP does nothing the module needs to keep | +| `ev_ctrl_setup_press` | take | *not confirmed*: 0x4004acf8 and 0x4004ad80 redraw CTRL1, but their triggering panel event still needs tracing | a knob is pressed on CTRL1 or CTRL2 SETUP | opens the NRPN page; stock's press on SETUP does nothing the module needs to keep | | `ev_ctrl_value_send` | take | 0x4009eec8 (sends one page-1 value: `t`, `flat` 18 PB, 19 AT, 20-29 CC, `value`, `force`) | stock is about to send a MIDI track's knob value | one site covers a knob turn, an LFO, a p-lock and a scene, so an NRPN knob sends the same way in each | The three SETUP hooks follow the precedent of `ev_arp_setup_knob` and `ev_arp_setup_text`: a take hook that gives one @@ -39,16 +40,22 @@ Read with `m68k-elf-objdump -m m68k:cfv4e` from the main OS section, `address = - **The page.** CTRL1 SETUP is a window. 0x40059620 builds it (or jumps to its destroy function when it exists) and keeps it at 0x400bc9ba; its descriptor holds the destroy function 0x400567e0 and the draw 0x4003f9ac. CTRL2 has the same layout: build 0x4005948c, destroy 0x400567b8, draw 0x4003f490 (its window address is not read yet). -- **Per-slot rows.** The window's element table (from 0x400bc9de, one 0x20-byte entry a row, ids 0x38, 0x39, 0x3a, ...) - points every row at 0x4004acf8 or its siblings (0x4004ad80, ...). On event 1 such a callback sets the 0x46104cb4 - flag, redraws through 0x4003f9ac, stores the row's slot in 0x46c7d23c and opens an edit overlay through 0x4006d57c. - This is the best candidate for `ev_ctrl_setup_press`. -- **The value write.** 0x4004ae08 receives a row and its new value, writes the byte into the setup record - (`+0x8f262`) and its live copy, sets the dirty bits, calls 0x40027e00 and 0x40036548 and ends in the program and bank - send 0x4009ec70. This is the candidate for `ev_ctrl_setup_knob`. -- **Not yet confirmed.** That 0x4004ae08 is the path for every CTRL1 and CTRL2 row and not for some only; where the - encoder reaches it; and the CTRL2 siblings of the row callbacks. `ev_ctrl_setup_text` stays on the 0x4003fb32 and - 0x4003f60c lookups from MIDI_TRACKS.md. +- **CTRL1 callbacks.** 0x4004acf8 and 0x4004ad80 redraw CTRL1 on event 1 and open an edit overlay through + 0x4006d57c. The panel event that reaches them has not been confirmed. +- **Correction: 0x4004ae08.** An earlier revision called this the CTRL value writer. It writes NOTE SETUP, redraws + through 0x40036548 and sends bank and program changes. The CTRL writers and the CTRL2 row callback are instead + listed in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md): 0x4003fd34, 0x4003f80c and + 0x4003f71c. Their encoder paths and the CTRL2 row callbacks still need confirmation on the unit. + +## Sites already in use + +- **0x4004ae08.** Midi Mode 2 detours this NOTE SETUP writer for its track-name editor. Leave its existing detour + alone unless a shared NOTE SETUP hook is separately designed; do not attach the CTRL hook here on the assumption + that it writes CTRL values. Confirm the actual shared sites and migration with its author before implementation. +- **0x4009eec8.** Midi Mode 2 calls this emitter, and MIDI Scenes calls it when a scene value changes. Neither call + needs changing if the base owns the entry. A take for an NRPN-configured track and slot translates MIDI Scenes' + value to NRPN instead of sending its stock CC; all other sends continue through stock. Verify both modules together + on a unit before release, including a scene with and without an NRPN assignment. ## How NRPN uses them @@ -67,19 +74,20 @@ Read with `m68k-elf-objdump -m m68k:cfv4e` from the main OS section, `address = - **RPN and the rest.** CC 101 and 100 pass to stock, and an RPN select ends a pending NRPN select. Notes, clock, start, stop and SysEx are not touched. -## Open questions for the owner +## Owner's decisions and required checks -1. Are these four SETUP and send hooks worth the base's ABI, given three users (NRPN, Midi Mode 2, CTRL knob labels)? - If not, NRPN stays a module that patches these sites and declares them as `uiClaims`. -2. Does a MIDI track's incoming CC change its knobs today, or does stock ignore it? NRPN receive assumes it does not; - to be read from the image before any build. -3. One page for the NRPN fields drawn through `ev_ctrl_setup_text`, or a base-owned module page? -4. NRPN in `project.work` per Part (as proposed), or per project? -5. 14 bit as a scaled 7-bit knob, or wait for finer encoder steps? +The owner agreed to the four SETUP and send hooks, conditional on confirming the sites on the unit before claiming +any hook index. Add them after the FM hooks (#2352) and scale hooks (#2415), with guards and NRPN as first subscriber. +Draw the NRPN page through `ev_ctrl_setup_text`, store settings per Part in `project.work`, and use the scaled 7-bit +knob for the full 14-bit range. + +Still to check on a named unit build: whether incoming CC moves a MIDI track's knobs, the actual CTRL1 and CTRL2 +encoder paths and row callbacks, and how they relate to 0x4004ae08. The earlier reading of 0x4004ae08 as a CTRL +writer contradicts MIDI_TRACKS.md; do not treat it as confirmed. ## What comes next -After the owner answers: confirm the sites above on a unit (and the unconfirmed ones in the image), add the entries to `events.json` -with their guards, regenerate with `python3 -B sdk/machines/octatrack/events.py --write`, and give each hook its -subscriber in the MIDI NRPN module (so `test_hook_coverage.py` passes). Test on a unit: the send, the receive and a -module removed while an NRPN knob is set. CC Map moves to `ev_midi_cc` as #2436 describes. +After the unit checks and the FM and scale hooks: add the entries to `events.json` with their guards, regenerate with +`python3 -B sdk/machines/octatrack/events.py --write`, and give each hook its subscriber in the MIDI NRPN module +(so `test_hook_coverage.py` passes). Test on a unit: the send, the receive and a module removed while an NRPN knob +is set. CC Map moves to `ev_midi_cc` as #2436 describes. From 89d5c8162c4aa39554e4d87fa39cd5f8b9e8bdf3 Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Thu, 3 Dec 2026 20:15:22 +0100 Subject: [PATCH 4/9] Docs: record inconclusive MIDI input test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md index d3eb8bc5cf..02ef0dc1e2 100644 --- a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -85,6 +85,12 @@ Still to check on a named unit build: whether incoming CC moves a MIDI track's k encoder paths and row callbacks, and how they relate to 0x4004ae08. The earlier reading of 0x4004ae08 as a CTRL writer contradicts MIDI_TRACKS.md; do not treat it as confirmed. +On an MKII running temporary development base `ebc820ab7123f0ef4f9f59c36f9703009e2454ae676f866dab5a1c890462bfde`, +MIDI track 1's enabled CC7 knob remained at 107 after the host MIDI bridge sent channel 1 CC7 value 23. The bridge +reported sending it, but receipt and MIDI input routing were not independently confirmed, so this does **not** answer +whether incoming CC moves the knob. No callback execution was traced. The test Part was restored and checked against +its original bytes before restarting; the release base does not permit the same memory check after restarting. + ## What comes next After the unit checks and the FM and scale hooks: add the entries to `events.json` with their guards, regenerate with From dd76799d55182ad7eba363d865c93cb13ea48a66 Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Thu, 3 Dec 2026 20:28:49 +0100 Subject: [PATCH 5/9] Docs: record MIDI track input on unit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md index 02ef0dc1e2..8499fad574 100644 --- a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -1,7 +1,7 @@ # MIDI track CTRL SETUP hooks and NRPN (design, for owner review) Status, 3 December 2026: the owner agreed to the proposed hooks, subject to the unit checks below. The proposed hooks -and module are not built; no site checks ran on a unit. +and module are not built; no callback sites have been traced on a unit. Every address comes from the reading of the 1.40C image in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md), which was not run on a unit, and from a second reading of the same image on 2 December 2026 (below). Neither reading ran on a unit. Hook indices must not be claimed before those checks. Entries, lengths and guards in `events.json` @@ -81,15 +81,20 @@ any hook index. Add them after the FM hooks (#2352) and scale hooks (#2415), wit Draw the NRPN page through `ev_ctrl_setup_text`, store settings per Part in `project.work`, and use the scaled 7-bit knob for the full 14-bit range. -Still to check on a named unit build: whether incoming CC moves a MIDI track's knobs, the actual CTRL1 and CTRL2 -encoder paths and row callbacks, and how they relate to 0x4004ae08. The earlier reading of 0x4004ae08 as a CTRL -writer contradicts MIDI_TRACKS.md; do not treat it as confirmed. - -On an MKII running temporary development base `ebc820ab7123f0ef4f9f59c36f9703009e2454ae676f866dab5a1c890462bfde`, -MIDI track 1's enabled CC7 knob remained at 107 after the host MIDI bridge sent channel 1 CC7 value 23. The bridge -reported sending it, but receipt and MIDI input routing were not independently confirmed, so this does **not** answer -whether incoming CC moves the knob. No callback execution was traced. The test Part was restored and checked against -its original bytes before restarting; the release base does not permit the same memory check after restarting. +Still to check on a named unit build: the actual CTRL1 and CTRL2 encoder paths and row callbacks, and how they relate +to 0x4004ae08. The earlier reading of 0x4004ae08 as a CTRL writer contradicts MIDI_TRACKS.md; do not treat it as +confirmed. + +**Incoming CC, MKII, 3 December 2026.** On temporary development base +`ebc820ab7123f0ef4f9f59c36f9703009e2454ae676f866dab5a1c890462bfde`, with no modules loaded, MIDI track 1's +enabled CC1 was assigned CC7, its output channel was 1, and the project's auto channel was 11. With CC DIRECT +CONNECT enabled, channel 11 CC7 values 23, 96, 0 and 127 moved the knob to those values; channel 1 CC7 did not +move it from 107. With CC DIRECT CONNECT disabled, channel 11 CC7 did not move the knob, but CC36 values 96 and +32 did. This checks one knob, not all tracks or slots. Each message advanced the MIDI receive FIFO by three bytes; +as a separate positive control, channel 1 CC16 moved audio track 1's pitch with AUDIO CC IN enabled. The project's +direct-connect setting was restored, and the test Part matched its original bytes before restarting. The release base +does not permit the same memory check after restarting. The receive design must account for the auto channel and both +direct-connect modes; matching only the MIDI track's output channel would miss this observed input. ## What comes next From 90cde82ca55a3048d14d6fbd291d378eabcc5a4b Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Fri, 4 Dec 2026 20:57:34 +0100 Subject: [PATCH 6/9] Docs: decide NRPN receive routing requirements Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md index 8499fad574..5a8dc77f93 100644 --- a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -68,9 +68,12 @@ Read with `m68k-elf-objdump -m m68k:cfv4e` from the main OS section, `address = primitive 0x40010bc8. Everything else returns to stock. - **14 bit.** The knob's value is one byte (0-127), so 14 bit gives the full parameter range, not finer steps: the module sends `value * 16383 / 127`. Finer steps would need the encoder's own resolution, which this does not propose. -- **Receiving.** At `ev_midi_cc` the module takes CC 99, 98, 6 and 38, and only while an NRPN knob is set on that - channel. A complete NRPN sets the knob's value through the page-1 writer 0x40054cd8 (`8 + t`, `20 + slot`), which - calls 0x4009eec8; the module marks that write so `ev_ctrl_value_send` does not send it straight back out. +- **Receiving.** At `ev_midi_cc` the module handles CC 99, 98, 6 and 38 for configured NRPN knobs, accounting for + the project's auto channel and both CC DIRECT CONNECT modes, rather than matching only the track's output channel. + Preserve stock handling for unrelated messages and mappings. A complete NRPN sets the knob's value through the + page-1 writer 0x40054cd8 (`8 + t`, `20 + slot`), which calls 0x4009eec8; the module marks that write so + `ev_ctrl_value_send` does not send it straight back out. The exact routing and consumption rules still need design + and testing for both modes. - **RPN and the rest.** CC 101 and 100 pass to stock, and an RPN select ends a pending NRPN select. Notes, clock, start, stop and SysEx are not touched. From 846c2195db339af6325d9192affbc880cb55dbf2 Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Fri, 4 Dec 2026 21:25:00 +0100 Subject: [PATCH 7/9] Docs: record CTRL setup callback traces Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 40 ++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md index 5a8dc77f93..ce9f844456 100644 --- a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -1,7 +1,7 @@ # MIDI track CTRL SETUP hooks and NRPN (design, for owner review) -Status, 3 December 2026: the owner agreed to the proposed hooks, subject to the unit checks below. The proposed hooks -and module are not built; no callback sites have been traced on a unit. +Status, 4 December 2026: the owner agreed to the proposed hooks, subject to the unit checks below. The proposed hooks +and module are not built; the row and encoder callbacks were traced on a unit, but the CTRL2 MIDI-learn siblings remain open. Every address comes from the reading of the 1.40C image in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md), which was not run on a unit, and from a second reading of the same image on 2 December 2026 (below). Neither reading ran on a unit. Hook indices must not be claimed before those checks. Entries, lengths and guards in `events.json` @@ -23,9 +23,9 @@ subscriber. It builds and works as the only module chosen. | Hook | Kind | Stock site | When | Why the base, not the module | | --- | --- | --- | --- | --- | | `ev_midi_cc` | call | 0x4000e79c (proposed in #2436) | an incoming CC reaches stock's CC handler | NRPN is the second subscriber after the post-FX2 filter: it **reuses** #2436's hook and adds none | -| `ev_ctrl_setup_knob` | take | *not located*: the encoder path to the CTRL1 and CTRL2 writers; 0x4004ae08 is a NOTE SETUP writer, not a confirmed CTRL writer (see below) | an encoder turns on CTRL1 or CTRL2 SETUP, before the writer's `cc <= 127` check | stock clamps at 127, so the number cannot go on without taking the turn | +| `ev_ctrl_setup_knob` | take | candidates 0x4003a7f4 (CTRL1) and 0x4003a700 (CTRL2), reached by encoder turns on the unit; hook placement and writer route still need confirmation | an encoder turns on CTRL1 or CTRL2 SETUP, before the writer's `cc <= 127` check | stock clamps at 127, so the number cannot go on without taking the turn | | `ev_ctrl_setup_text` | take | the value-name lookups 0x4003fb32 (CTRL1 draw 0x4003f9ac) and 0x4003f60c (CTRL2 draw 0x4003f490) | SETUP is about to print a slot's value text (the CC name table 0x400be882, `%.8s`) | the row must read `NRPN` and, on its page, the MSB, LSB and size | -| `ev_ctrl_setup_press` | take | *not confirmed*: 0x4004acf8 and 0x4004ad80 redraw CTRL1, but their triggering panel event still needs tracing | a knob is pressed on CTRL1 or CTRL2 SETUP | opens the NRPN page; stock's press on SETUP does nothing the module needs to keep | +| `ev_ctrl_setup_press` | take | candidates 0x4003fc44 (CTRL1) and 0x4003f71c (CTRL2), reached by presses on the unit; hook placement still needs confirmation | a knob is pressed on CTRL1 or CTRL2 SETUP | opens the NRPN page; stock's press on SETUP does nothing the module needs to keep | | `ev_ctrl_value_send` | take | 0x4009eec8 (sends one page-1 value: `t`, `flat` 18 PB, 19 AT, 20-29 CC, `value`, `force`) | stock is about to send a MIDI track's knob value | one site covers a knob turn, an LFO, a p-lock and a scene, so an NRPN knob sends the same way in each | The three SETUP hooks follow the precedent of `ev_arp_setup_knob` and `ev_arp_setup_text`: a take hook that gives one @@ -45,7 +45,7 @@ Read with `m68k-elf-objdump -m m68k:cfv4e` from the main OS section, `address = - **Correction: 0x4004ae08.** An earlier revision called this the CTRL value writer. It writes NOTE SETUP, redraws through 0x40036548 and sends bank and program changes. The CTRL writers and the CTRL2 row callback are instead listed in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md): 0x4003fd34, 0x4003f80c and - 0x4003f71c. Their encoder paths and the CTRL2 row callbacks still need confirmation on the unit. + 0x4003f71c. The unit traces below locate encoder and press callbacks, but do not establish the full route to the writers. ## Sites already in use @@ -84,9 +84,9 @@ any hook index. Add them after the FM hooks (#2352) and scale hooks (#2415), wit Draw the NRPN page through `ev_ctrl_setup_text`, store settings per Part in `project.work`, and use the scaled 7-bit knob for the full 14-bit range. -Still to check on a named unit build: the actual CTRL1 and CTRL2 encoder paths and row callbacks, and how they relate -to 0x4004ae08. The earlier reading of 0x4004ae08 as a CTRL writer contradicts MIDI_TRACKS.md; do not treat it as -confirmed. +Still to check on a named unit build: the CTRL2 MIDI-learn callback siblings and the full route from the encoder +callbacks to the writers. The earlier reading of 0x4004ae08 as a CTRL writer contradicts MIDI_TRACKS.md; +do not treat it as confirmed. **Incoming CC, MKII, 3 December 2026.** On temporary development base `ebc820ab7123f0ef4f9f59c36f9703009e2454ae676f866dab5a1c890462bfde`, with no modules loaded, MIDI track 1's @@ -99,6 +99,30 @@ direct-connect setting was restored, and the test Part matched its original byte does not permit the same memory check after restarting. The receive design must account for the auto channel and both direct-connect modes; matching only the MIDI track's output channel would miss this observed input. +**Row trace, MKII, 4 December 2026.** On the same development base, a private, unkept probe +(`081b84b43ed1c76c99bdf883862c70c9856f3d8b55cfd50ba3d5a80c53faf8f4`) counted candidate entries and replayed the +displaced instructions. With no other modules loaded, pressing each CTRL1 SETUP CC1-4 knob advanced the counter at +0x4003fc44 by two per press; pressing each CTRL2 SETUP CC5-10 knob advanced 0x4003f71c by two. During those presses, +0x4004acf8, 0x4004ad80, 0x4003fd34, 0x4003f80c and 0x4004ae08 did not count. Turning each of those ten encoders +changed the displayed setup values but did not advance any of the seven counters. These observations identify the +tested press callbacks, not the encoder's route or every possible event. The probe rolled back without a logged crash, +stall, freeze or skipped track. The test Part matched its original bytes before restarting; after restart the installed +base reported zero saved and live modules. + +**Encoder trace, MKII, 4 December 2026.** On the same development base, an expanded private, unkept probe +(`2ef58b0be602d572fec90e38307f60e2ddf671627622b022b39c59a694b2bf63`) counted nine candidate entries, with no +other modules loaded. One turn of each CTRL1 SETUP encoder C-F advanced 0x4003a7f4 once; one turn of each CTRL2 +encoder A-F advanced 0x4003a700 once. Each corresponding press again advanced 0x4003fc44 or 0x4003f71c twice. +The counters at 0x4004acf8, 0x4004ad80, 0x4003fd34, 0x4003f80c and 0x4004ae08 stayed at zero during these actions; +that does not rule out other contexts. Static disassembly indicates that the two encoder routines stage and clamp +values; the counters alone do not prove their full route to the writers. The trial was deliberately interrupted and +reported a clean rollback, with no logged crash, stall, freeze or skipped track. The test Part matched its original +bytes before restarting; the installed base then reported zero saved and live modules. + +An earlier expanded-probe attempt ended prematurely after USB suspension and could not confirm rollback. After a +restart, the installed base and empty set were verified. The successful retry kept the Mac awake, but does not prove +what caused the interruption. + ## What comes next After the unit checks and the FM and scale hooks: add the entries to `events.json` with their guards, regenerate with From a0dcbc2da68508ddf0287cb95f304a37b39cd87e Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Fri, 4 Dec 2026 21:25:31 +0100 Subject: [PATCH 8/9] Docs: identify MIDI learn callback candidates Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md index ce9f844456..e6d64b1e5e 100644 --- a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -40,8 +40,9 @@ Read with `m68k-elf-objdump -m m68k:cfv4e` from the main OS section, `address = - **The page.** CTRL1 SETUP is a window. 0x40059620 builds it (or jumps to its destroy function when it exists) and keeps it at 0x400bc9ba; its descriptor holds the destroy function 0x400567e0 and the draw 0x4003f9ac. CTRL2 has the same layout: build 0x4005948c, destroy 0x400567b8, draw 0x4003f490 (its window address is not read yet). -- **CTRL1 callbacks.** 0x4004acf8 and 0x4004ad80 redraw CTRL1 on event 1 and open an edit overlay through - 0x4006d57c. The panel event that reaches them has not been confirmed. +- **MIDI-learn candidates.** The four records at 0x400bc6ec use 0x4004ad80, and the six at 0x400bc9e6 use + 0x4004acf8. On event 1, these set the learn index to 0-3 and 4-9 respectively and open an edit overlay through + 0x4006d57c; both call the CTRL1 redraw. This is a static reading, not a unit trace of the event that reaches them. - **Correction: 0x4004ae08.** An earlier revision called this the CTRL value writer. It writes NOTE SETUP, redraws through 0x40036548 and sends bank and program changes. The CTRL writers and the CTRL2 row callback are instead listed in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md): 0x4003fd34, 0x4003f80c and From dfe7779382d25792e31e5a746649946b685c4409 Mon Sep 17 00:00:00 2001 From: Hugo Hermans Date: Sat, 5 Dec 2026 08:34:10 +0100 Subject: [PATCH 9/9] Docs: finalize MIDI CTRL hook design Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/OCTATRACK_MIDI_CTRL_HOOKS.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md index e6d64b1e5e..4d7d852888 100644 --- a/docs/OCTATRACK_MIDI_CTRL_HOOKS.md +++ b/docs/OCTATRACK_MIDI_CTRL_HOOKS.md @@ -1,11 +1,10 @@ # MIDI track CTRL SETUP hooks and NRPN (design, for owner review) -Status, 4 December 2026: the owner agreed to the proposed hooks, subject to the unit checks below. The proposed hooks -and module are not built; the row and encoder callbacks were traced on a unit, but the CTRL2 MIDI-learn siblings remain open. -Every address comes from the reading of the 1.40C image in [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md), -which was not run on a unit, and from a second reading of the same image on 2 December 2026 (below). Neither reading -ran on a unit. Hook indices must not be claimed before those checks. Entries, lengths and guards in `events.json` -need a real OS file (CI has no firmware). +Status, 5 December 2026: the owner agreed to the proposed hooks and confirmed that the unit traces below answer the +checks required for this design. The proposed hooks and module are not built. The addresses were first identified by +static readings of the 1.40C image, including [MIDI_TRACKS.md](../sdk/octabam/docs/MIDI_TRACKS.md); the unit traces +confirm the specific encoder and press callbacks described below, not every address or route. Entries, lengths and +guards in `events.json` need a real OS file (CI has no firmware). ## Why @@ -35,7 +34,8 @@ that owns a slot's number, 40-69 for one that only observes. ## Sites found in the 1.40C image (2 December 2026) -Read with `m68k-elf-objdump -m m68k:cfv4e` from the main OS section, `address = 0x40000400 + file offset`. Not run on a unit. +The static reading used `m68k-elf-objdump -m m68k:cfv4e` on the main OS section, with +`address = 0x40000400 + file offset`. The later unit traces confirm the callbacks specifically identified below. - **The page.** CTRL1 SETUP is a window. 0x40059620 builds it (or jumps to its destroy function when it exists) and keeps it at 0x400bc9ba; its descriptor holds the destroy function 0x400567e0 and the draw 0x4003f9ac. CTRL2 has the @@ -85,10 +85,6 @@ any hook index. Add them after the FM hooks (#2352) and scale hooks (#2415), wit Draw the NRPN page through `ev_ctrl_setup_text`, store settings per Part in `project.work`, and use the scaled 7-bit knob for the full 14-bit range. -Still to check on a named unit build: the CTRL2 MIDI-learn callback siblings and the full route from the encoder -callbacks to the writers. The earlier reading of 0x4004ae08 as a CTRL writer contradicts MIDI_TRACKS.md; -do not treat it as confirmed. - **Incoming CC, MKII, 3 December 2026.** On temporary development base `ebc820ab7123f0ef4f9f59c36f9703009e2454ae676f866dab5a1c890462bfde`, with no modules loaded, MIDI track 1's enabled CC1 was assigned CC7, its output channel was 1, and the project's auto channel was 11. With CC DIRECT @@ -126,7 +122,10 @@ what caused the interruption. ## What comes next -After the unit checks and the FM and scale hooks: add the entries to `events.json` with their guards, regenerate with -`python3 -B sdk/machines/octatrack/events.py --write`, and give each hook its subscriber in the MIDI NRPN module -(so `test_hook_coverage.py` passes). Test on a unit: the send, the receive and a module removed while an NRPN knob -is set. CC Map moves to `ev_midi_cc` as #2436 describes. +After the FM and scale hooks: check the MIDI-learn siblings, the exact take point before the clamp and the route from +the encoder callbacks to the writers while adding the guarded entries to `events.json`. Regenerate with +`python3 -B sdk/machines/octatrack/events.py --write` and give each hook its subscriber in the MIDI NRPN module +(so `test_hook_coverage.py` passes). MIDI LEARN on an NRPN knob writes a plain CC number through the stock writers; +decide whether the module drops or keeps that knob's NRPN entry, and test the chosen behavior. Test the first +subscriber on a unit, including send, receive and removing the module while an NRPN knob is set. CC Map moves to +`ev_midi_cc` as #2436 describes.