diff --git a/sdk/drafts/midi-nrpn/CHANGELOG.json b/sdk/drafts/midi-nrpn/CHANGELOG.json new file mode 100644 index 0000000000..9996fbd992 --- /dev/null +++ b/sdk/drafts/midi-nrpn/CHANGELOG.json @@ -0,0 +1,19 @@ +[ + { + "version": "0.1.1-experimental", + "date": "2026-12-05", + "changes": [ + "Add a host-tested NRPN message and per-knob range core.", + "The module is not yet connected to the base or usable on an Octatrack.", + "Check a possible four-field page layout on paper; no page has been built.", + "Prepare resending NRPN selection after playback starts or a project loads." + ] + }, + { + "version": "0.1.0-experimental", + "date": "2026-12-05", + "changes": [ + "Draft design for NRPN on MIDI track controls; not built or tested yet." + ] + } +] diff --git a/sdk/drafts/midi-nrpn/LICENSE b/sdk/drafts/midi-nrpn/LICENSE new file mode 100644 index 0000000000..126ae6ecab --- /dev/null +++ b/sdk/drafts/midi-nrpn/LICENSE @@ -0,0 +1,30 @@ +MIT License + +Copyright (c) 2026 huupsel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- + +This licence covers this module's own source code and documentation only. It +does not extend to any Elektron Music Machines firmware, which is not +distributed here and remains the property of its copyright holder. Nothing in +this module is endorsed by, supported by, or affiliated with Elektron. +Octatrack and Elektron are trademarks of Elektron Music Machines MAV AB, used +only to identify the hardware this module targets. diff --git a/sdk/drafts/midi-nrpn/README.md b/sdk/drafts/midi-nrpn/README.md new file mode 100644 index 0000000000..59e0992f72 --- /dev/null +++ b/sdk/drafts/midi-nrpn/README.md @@ -0,0 +1,89 @@ +# MIDI NRPN + +Version 0.1.1-experimental · by @huupsel · a draft, not tested on a unit. + +## Overview + +A MIDI track's CTRL1 and CTRL2 knobs send only CC 0-127. This module adds NRPN: past CC 127 in a knob's SETUP list comes NRPN, and pressing the knob there opens a small page for the NRPN number (MSB, LSB), value size and maximum. A knob set to NRPN sends and receives that parameter instead of a CC. + +**Development draft:** the NRPN core has host tests. It is not connected to the instrument or installable. + +## Controls + +Per MIDI track and knob (CTRL1 CC1-CC4, CTRL2 CC5-CC10): +- Number: CC 0-127 (stock), then NRPN. Default: stock's. +- NRPN MSB and LSB: 0-127 each. Default 0 and 0. +- Maximum value: set per knob, default 127. Map the Octatrack's 0-127 knob to the parameter's 0-maximum range, + rounding to the nearest value (0-127 for 7-bit format; 0-16383 for 14-bit format); + for example, 128 positions span 0-164 for NRPN 34, so 37 values cannot be selected. +- Value format: choose 7-bit or 14-bit interpretation for the receiving device. The Octatrack knob itself remains 7-bit. + +## Usage + +Planned: on a MIDI track open CTRL1 SETUP or CTRL2 SETUP, turn a knob's number past CC 127 until it reads NRPN, press the knob for the NRPN page. + +### Page fit (paper check) + +A candidate page has four columns: `MSB`, `LSB`, `BITS` and `MAX`, with a value under each. Using a 4-pixel +character pitch (as used by the Octatrack Repitch widget), the longest values are `127`, `127`, `14` and `16383`: +12, 12, 8 and 20 pixels. Four 26-pixel cells starting at x=7, 35, 63 and 91 fit inside x=6–121, with gaps between +them; `BITS` is 16 pixels wide. With labels at y=12 and values at y=22, rows up to 7 pixels high also fit the +64-pixel screen without overlapping. This is a calculation, not a rendered page. Whether the agreed text hook can +provide that area, the actual font and spacing, encoder mapping and legibility still need an integrated build and +unit test. + +### Messages (planned) + +| Message | What the module does | +|---|---| +| Knob turn on an NRPN knob | The core sends CC 99 and 98 for a changed number, then CC 6 for a 7-bit value; 14-bit format splits the scaled value over CC 6 and CC 38. Choose 14-bit for a receiver that commits only on CC 38, even when its range ends at 127. Integration must serialize output and invalidate the selection cache when another sender changes it or a send fails. | +| Incoming CC 99, 98, 6, 38 | The core parses each channel separately: CC 6 yields a 7-bit value, and CC 38 completes a 14-bit value. It maps a matching value to the nearest knob position and clamps values above the configured maximum. The instrument's auto channel, both CC DIRECT CONNECT modes, routing and consumption still need integration and testing. | +| CC 101, 100 (RPN) | Passed through to stock. An incoming RPN select ends a pending NRPN select. | +| Every other CC, note, clock, start, stop, SysEx | Unchanged, as stock. | + +A knob set to a CC number between 0 and 127 behaves exactly as stock. + +## Quick tutorial + +1. Set it up. +2. Change a control and hear what it does. +3. Get back to where you started. + +## Compatibility and limitations + +Not known yet. It needs base hooks that do not exist: the CTRL SETUP knob and draw, the outgoing knob value and the incoming CC. They are proposed on the cumulative Octatrack base draft, together with the shared CC-in hook of #2436, so it shares those sites with CC Map and the Midi Mode 2 draft instead of patching them. Its NRPN settings need the base's module-settings storage, because stock clamps the Part's CC bytes to 0-127. + +The per-knob maximum and scaled values are implemented in the host-tested core only. Parameters with more than 128 +possible values cannot all be selected individually with one 7-bit knob; MIDI receive feedback also rounds them. +The four-field page has only a paper fit check; the page, persistence, send and receive hooks have not been +implemented or tested on the instrument. + +The proposed `project.work` format stores each configured knob as a versioned `#MODWERK_NRPN=` comment line with +bank, Part, track, slot, parameter number, size and maximum: for example, `#MODWERK_NRPN=1:0:0:0:0:34:14:164`. +Bank, Part, track and slot are zero-based. The core validates lines and rejects duplicate slots; the integration +must stage the full list and refuse to overwrite a malformed or newer-format project. + +The sender's selection cache is per output stream and channel. Integration must serialize each complete packet and +lifecycle event, invoke `nrpn_tx_playback_start` at playback start and `nrpn_tx_project_load` on project load for +every output stream, and invalidate the affected stream on other senders' NRPN/RPN selections or failed sends. +These callbacks are host-tested but not connected to the instrument. Integration must also reset receive state on +Part or project changes so a partial message cannot set a knob in the new context. + +## Tests and measurements + +See [TESTING.md](TESTING.md). + +## Authorship and licences + +Your own code under the licence in LICENSE. Name anyone whose work it builds on. + +## Screens and audio + +None yet. + +## Develop + +- Hear it: `npm run module:dev -- midi-nrpn` builds it and tries it on your unit over USB; `--watch` does that again on every save. +- Check it: `npm run module:doctor -- --draft midi-nrpn`. Its experimental lines must be green to share the draft; its release lines say what listing it needs. +- Before you write any code: no heavy ColdFire design. Audio work goes on the DSP, and nothing runs every frame that could run less often (docs/module-guides/README.md, Keep the ColdFire cheap). Measure the first build that plays with npm run device:price. +- Before you write ColdFire code: the traps in sdk/octabam/AGENTS.md, and docs/OCTATRACK_API.md for the hooks a module can use. diff --git a/sdk/drafts/midi-nrpn/TESTING.md b/sdk/drafts/midi-nrpn/TESTING.md new file mode 100644 index 0000000000..0e62d6d492 --- /dev/null +++ b/sdk/drafts/midi-nrpn/TESTING.md @@ -0,0 +1,28 @@ +# Midi Nrpn testing + +0.1.1-experimental: the protocol core runs on the host; the Octatrack module is not built. + +Record what you ran, on which build and which unit, and what you saw. "Not tested" is a valid answer; never write a result you did not observe, and keep emulator runs apart from hardware ones. + +## On the unit + +Not tested. No NRPN send, receive, persistence or UI has run on a unit. + +## Host + +`python3 -B sdk/drafts/midi-nrpn/test_nrpn.py`: passed on the host. Exercises the C core's 7/14-bit messages, +per-channel selection, playback-start and project-load cache resets, RPN cancellation, scaling and project-line +validation. It does not test the +instrument's routing, wire timing, storage integration or panel. + +The candidate four-column page was checked by calculation using a 4-pixel character pitch and all permitted field +values. Each fits its 26-pixel cell; this does not verify the actual font, available hook drawing area or legibility. +No NRPN page was rendered or run on a unit. + +## Stock flows + +Not tested. List the stock flows you compared with and without the module (docs/module-guides/README.md, Leave stock flows alone). + +## Performance + +Not measured. Listing it needs evidence/performance.json: npm run perf:audit -- template coldfire (docs/MODULE_PERFORMANCE.md). diff --git a/sdk/drafts/midi-nrpn/manifest.py b/sdk/drafts/midi-nrpn/manifest.py new file mode 100644 index 0000000000..7bf30edfb9 --- /dev/null +++ b/sdk/drafts/midi-nrpn/manifest.py @@ -0,0 +1,78 @@ +""" -- one line on what it changes in the firmware. + +THE SKELETON OF A COLDFIRE MODULE: code the build links and places for +you, reached from stock code by detours you name by SYMBOL. +`npm run module:new` made this draft under sdk/drafts/. It builds as it is: +`npm run module:dev -- ` tries it on your unit over USB, and +`npm run module:doctor -- --draft ` checks it. + +sdk/octatrack/modules/repitch/ is a finished one (one linked unit, detours, +pokes); sdk/octatrack/modules/quantizer/ another (units built from the +author's source, kept under upstream/). sdk/octabam/docs/remixer/MODULES.md +"Declaring a ColdFire module" is the guide; sdk/octabam/docs/remixer/PLACEMENT.md +says where the bytes go; docs/OCTATRACK_API.md lists the hooks. + +Say what the module is, which stock routines it changes, what is measured +and what is inferred. Delete every comment below once answered. +""" + +from remix.schema import Category, Proof, Gate, Detour, Kind, Linked, Module, Poke +from remix.stock_guard import stock_guard + +MODULE = Module( + # `name` MUST equal the directory name. `key` is the build identifier and + # appears in the build report, which other tools parse -- so it is API. + name="midi-nrpn", + key="MIDI NRPN", + kind=Kind.CF_PATCH, # no DSP code, no chooser row + doc="One line, shown in the build report.", + category=Category.TRACK, author="huupsel", author_url="https://github.com/huupsel", + proof=Proof.UNTESTED, proof_note="Development scaffold; no module behavior has been verified.", + + # ---- the code: GNU-as units, linked by the build ---------------------- + # ORDER IS LINK ORDER: a unit may reference symbols of units before it. + # `dram=True` puts the unit in the platform runtime (linked with every + # other DRAM unit in the remix, appended behind the loader, depacked at + # boot into the platform's 10 MB reserve at the bottom of the audio + # page arena -- where anything bigger than a few hundred bytes + # belongs; the unit gives up 10 MB of sample memory). `dram=False` places + # it in one of the OS image's free zero runs (~8 KB, shared by everyone) + # for code that must be ROM-resident. Sources are `.s` for m68k-elf-as; + # `cpu="5407"` and "5475" encode this ISA subset identically. + linked=( + Linked("unit", "modules/midi-nrpn/unit.s", dram=True), + # Building from someone else's repository? Add it as a submodule + # under modules//upstream and point `source` into it; the + # sources stay theirs and an update is a submodule bump. + # `reference=(addr, sha256)` re-links the unit at the AUTHOR'S own + # address on every build and compares, so a drift from the bytes + # they ratified fails loudly. + ), + + # ---- how stock code reaches it: detours, wired by symbol -------------- + # `site` is a stock instruction; `expect` its bytes (whole instructions, + # asserted before anything is written -- a site that has moved stops + # the build). `kind`: "jmp" for a stub that replays what it displaced + # and jumps on (the common case), "jsr" for a callable that returns, + # "lea" to rewrite a six-byte `lea abs.l,An`'s operand. `pad_to` nops + # the rest of a displaced span longer than six bytes. + detours=( + # Detour(0x400xxxxx, stock_guard(0x400xxxxx, 8, ""), "unit", "my_hook", + # "what this hook is for", kind="jsr", pad_to=None), + ), + + # ---- plain asserted rewrites ------------------------------------------ + pokes=( + # Poke(0x400xxxxx, expect=stock_guard(0x400xxxxx, 2, ""), + # write=bytes.fromhex("6012"), note="bne -> bra: never re-apply"), + ), + + gates=(Gate("modules/midi-nrpn/verify.py", remix_arg=False),), + + # A stock pointer array that needs more entries: TableGrow relocates it + # into free space with your symbols appended and repoints every + # reference. + # tables=(TableGrow("...", old=0x400xxxxx, count=16, + # symbols=(("unit", "my_row"),), + # refs=((0x400xxxxx, 0x400xxxxx),)),), +) diff --git a/sdk/drafts/midi-nrpn/nrpn.c b/sdk/drafts/midi-nrpn/nrpn.c new file mode 100644 index 0000000000..7a9ee4a4d0 --- /dev/null +++ b/sdk/drafts/midi-nrpn/nrpn.c @@ -0,0 +1,190 @@ +/* SPDX-License-Identifier: MIT */ +#include "nrpn.h" +#include + +int nrpn_config_valid(const NrpnConfig *c) { + return c && c->bank < 16 && c->part < 4 && c->track < 8 && c->slot < 10 && + c->number <= NRPN_MAX_NUMBER && + ((c->bits == 7 && c->maximum <= 127) || + (c->bits == 14 && c->maximum <= NRPN_MAX_VALUE)); +} + +NrpnResult nrpn_scale_out(const NrpnConfig *c, unsigned knob, uint16_t *value) { + if (!nrpn_config_valid(c) || knob > 127 || !value) return NRPN_INVALID; + *value = (uint16_t)((knob * (uint32_t)c->maximum + 63u) / 127u); + return NRPN_OK; +} + +NrpnResult nrpn_scale_in(const NrpnConfig *c, unsigned value, uint8_t *knob) { + if (!nrpn_config_valid(c) || value > (c->bits == 7 ? 127u : NRPN_MAX_VALUE) || !knob) + return NRPN_INVALID; + if (value > c->maximum) value = c->maximum; + *knob = c->maximum ? (uint8_t)((value * 127u + c->maximum / 2u) / c->maximum) : 0; + return NRPN_OK; +} + +void nrpn_tx_reset(NrpnTx *state) { + memset(state, 0, sizeof(*state)); +} + +void nrpn_tx_playback_start(NrpnTx *state) { + nrpn_tx_reset(state); +} + +void nrpn_tx_project_load(NrpnTx *state) { + nrpn_tx_reset(state); +} + +NrpnResult nrpn_tx_observe(NrpnTx *state, unsigned channel, unsigned controller) { + if (!state || channel >= NRPN_CHANNELS || controller > 127) return NRPN_INVALID; + if (controller == 98 || controller == 99 || controller == 100 || + controller == 101 || controller == 121) state->valid[channel] = 0; + return NRPN_OK; +} + +NrpnResult nrpn_tx_prepare(const NrpnTx *state, unsigned channel, const NrpnConfig *c, + unsigned knob, NrpnPacket *packet) { + uint16_t value; + if (!state || !packet || channel >= NRPN_CHANNELS || + nrpn_scale_out(c, knob, &value) != NRPN_OK) return NRPN_INVALID; + NrpnPacket p = { .number = c->number, .channel = (uint8_t)channel }; + if (!state->valid[channel] || state->selected[channel] != c->number) { + p.cc[p.count++] = (NrpnCc){ 99, (uint8_t)(c->number >> 7) }; + p.cc[p.count++] = (NrpnCc){ 98, (uint8_t)(c->number & 127) }; + } + if (c->bits == 14) { + p.cc[p.count++] = (NrpnCc){ 6, (uint8_t)(value >> 7) }; + p.cc[p.count++] = (NrpnCc){ 38, (uint8_t)(value & 127) }; + } else { + p.cc[p.count++] = (NrpnCc){ 6, (uint8_t)value }; + } + *packet = p; + return NRPN_OK; +} + +NrpnResult nrpn_tx_finish(NrpnTx *state, const NrpnPacket *packet, int accepted) { + if (!state || !packet || packet->channel >= NRPN_CHANNELS || + packet->number > NRPN_MAX_NUMBER || packet->count == 0 || packet->count > 4 || + (accepted != 0 && accepted != 1)) return NRPN_INVALID; + state->valid[packet->channel] = accepted != 0; + if (accepted) state->selected[packet->channel] = packet->number; + return NRPN_OK; +} + +void nrpn_rx_reset(NrpnRx *state) { + memset(state, 0, sizeof(*state)); +} + +NrpnResult nrpn_rx_cc(NrpnRx *state, unsigned channel, unsigned controller, unsigned value, + NrpnValue *result) { + if (!state || !result || channel >= NRPN_CHANNELS || controller > 127 || value > 127) + return NRPN_INVALID; + NrpnRxChannel *c = &state->channel[channel]; + if (controller == 100 || controller == 101 || controller == 121) { + memset(c, 0, sizeof(*c)); + return NRPN_IGNORED; + } + if (controller == 99 || controller == 98) { + if (controller == 99) { c->msb = (uint8_t)value; c->selected |= 1; } + else { c->lsb = (uint8_t)value; c->selected |= 2; } + c->has_data = 0; + if (c->selected == 3 && c->msb == 127 && c->lsb == 127) + memset(c, 0, sizeof(*c)); + return NRPN_IGNORED; + } + if (c->selected != 3) return NRPN_IGNORED; + NrpnValue output = { .number = (uint16_t)((c->msb << 7) | c->lsb) }; + if (controller == 6) { + c->data_msb = (uint8_t)value; + c->has_data = 1; + output.bits = 7; + output.value = (uint16_t)value; + } else if (controller == 38 && c->has_data) { + output.bits = 14; + output.value = (uint16_t)((c->data_msb << 7) | value); + } else return NRPN_IGNORED; + *result = output; + return NRPN_OK; +} + +NrpnResult nrpn_rx_value(const NrpnConfig *config, const NrpnValue *value, uint8_t *knob) { + if (!nrpn_config_valid(config) || !value || !knob || value->number > NRPN_MAX_NUMBER || + (value->bits != 7 && value->bits != 14) || + value->value > (value->bits == 7 ? 127u : NRPN_MAX_VALUE)) return NRPN_INVALID; + if (config->number != value->number || config->bits != value->bits) return NRPN_IGNORED; + return nrpn_scale_in(config, value->value, knob); +} + +static int same_slot(const NrpnConfig *a, const NrpnConfig *b) { + return a->bank == b->bank && a->part == b->part && a->track == b->track && a->slot == b->slot; +} + +NrpnResult nrpn_list_add(NrpnConfig *list, size_t *count, size_t capacity, const NrpnConfig *c) { + if (!list || !count || !nrpn_config_valid(c) || capacity > NRPN_MAX_ENTRIES || + *count > capacity) return NRPN_INVALID; + for (size_t i = 0; i < *count; ++i) + if (same_slot(&list[i], c)) return NRPN_INVALID; + if (*count == capacity) return NRPN_INVALID; + list[(*count)++] = *c; + return NRPN_OK; +} + +static const char prefix[] = "#MODWERK_NRPN="; + +static void decimal(char *out, size_t *n, unsigned value) { + char digits[5]; + unsigned count = 0; + do { digits[count++] = (char)('0' + value % 10); value /= 10; } while (value); + while (count) out[(*n)++] = digits[--count]; +} + +NrpnResult nrpn_line_format(const NrpnConfig *c, char *out, size_t capacity, size_t *length) { + if (!nrpn_config_valid(c) || !out || !length) return NRPN_INVALID; + char line[NRPN_LINE_SIZE]; + size_t n = 0; + for (size_t i = 0; i < sizeof(prefix) - 1; ++i) line[n++] = prefix[i]; + const unsigned fields[] = { 1, c->bank, c->part, c->track, c->slot, + c->number, c->bits, c->maximum }; + for (size_t i = 0; i < sizeof(fields) / sizeof(fields[0]); ++i) { + if (i) line[n++] = ':'; + decimal(line, &n, fields[i]); + } + line[n++] = '\r'; line[n++] = '\n'; + if (capacity <= n) return NRPN_INVALID; + line[n] = '\0'; + memcpy(out, line, n + 1); + *length = n; + return NRPN_OK; +} + +NrpnResult nrpn_line_parse(const char *line, size_t length, NrpnConfig *config) { + if (!line || !config) return NRPN_INVALID; + size_t prefix_len = sizeof(prefix) - 1; + if (length < prefix_len - 1 || memcmp(line, prefix, prefix_len - 1)) return NRPN_IGNORED; + if (length < prefix_len || line[prefix_len - 1] != '=') return NRPN_INVALID; + unsigned fields[8]; + size_t pos = prefix_len; + for (unsigned i = 0; i < 8; ++i) { + unsigned value = 0, digits = 0; + while (pos < length && line[pos] >= '0' && line[pos] <= '9') { + unsigned digit = (unsigned)(line[pos++] - '0'); + if (++digits > 5 || value > (NRPN_MAX_VALUE - digit) / 10u) return NRPN_INVALID; + value = value * 10u + digit; + } + if (!digits) return NRPN_INVALID; + fields[i] = value; + if (i < 7 && (pos == length || line[pos++] != ':')) return NRPN_INVALID; + } + if (pos < length && line[pos] == '\r') ++pos; + if (pos < length && line[pos] == '\n') ++pos; + if (pos != length || fields[0] != 1 || fields[1] >= 16 || fields[2] >= 4 || + fields[3] >= 8 || fields[4] >= 10 || fields[5] > NRPN_MAX_NUMBER || + (fields[6] != 7 && fields[6] != 14) || fields[7] > NRPN_MAX_VALUE) + return NRPN_INVALID; + NrpnConfig parsed = { (uint8_t)fields[1], (uint8_t)fields[2], (uint8_t)fields[3], + (uint8_t)fields[4], (uint16_t)fields[5], (uint16_t)fields[7], + (uint8_t)fields[6] }; + if (!nrpn_config_valid(&parsed)) return NRPN_INVALID; + *config = parsed; + return NRPN_OK; +} diff --git a/sdk/drafts/midi-nrpn/nrpn.h b/sdk/drafts/midi-nrpn/nrpn.h new file mode 100644 index 0000000000..4e6ee659b5 --- /dev/null +++ b/sdk/drafts/midi-nrpn/nrpn.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef MIDI_NRPN_H +#define MIDI_NRPN_H + +#include +#include + +enum { NRPN_CHANNELS = 16, NRPN_MAX_NUMBER = 16382, NRPN_MAX_VALUE = 16383, + NRPN_MAX_ENTRIES = 16 * 4 * 8 * 10, NRPN_LINE_SIZE = 80 }; + +typedef struct { + uint8_t bank, part, track, slot; + uint16_t number, maximum; + uint8_t bits; +} NrpnConfig; + +typedef struct { uint8_t controller, value; } NrpnCc; + +typedef struct { + uint16_t selected[NRPN_CHANNELS]; + uint8_t valid[NRPN_CHANNELS]; +} NrpnTx; + +typedef struct { + NrpnCc cc[4]; + uint16_t number; + uint8_t channel, count; +} NrpnPacket; + +typedef struct { + uint8_t msb, lsb, data_msb, selected, has_data; +} NrpnRxChannel; + +typedef struct { NrpnRxChannel channel[NRPN_CHANNELS]; } NrpnRx; + +typedef struct { + uint16_t number, value; + uint8_t bits; +} NrpnValue; + +typedef enum { NRPN_INVALID = -1, NRPN_IGNORED = 0, NRPN_OK = 1 } NrpnResult; + +int nrpn_config_valid(const NrpnConfig *config); +NrpnResult nrpn_scale_out(const NrpnConfig *config, unsigned knob, uint16_t *value); +NrpnResult nrpn_scale_in(const NrpnConfig *config, unsigned value, uint8_t *knob); + +void nrpn_tx_reset(NrpnTx *state); +void nrpn_tx_playback_start(NrpnTx *state); +void nrpn_tx_project_load(NrpnTx *state); +NrpnResult nrpn_tx_observe(NrpnTx *state, unsigned channel, unsigned controller); +/* One state per output stream: serialize lifecycle events, prepare, atomic enqueue and finish. + * Observe other senders' selectors, and finish with accepted=0 after any failed enqueue. */ +NrpnResult nrpn_tx_prepare(const NrpnTx *state, unsigned channel, const NrpnConfig *config, + unsigned knob, NrpnPacket *packet); +NrpnResult nrpn_tx_finish(NrpnTx *state, const NrpnPacket *packet, int accepted); + +void nrpn_rx_reset(NrpnRx *state); +NrpnResult nrpn_rx_cc(NrpnRx *state, unsigned channel, unsigned controller, unsigned value, + NrpnValue *result); +/* A CC 6 result is 7-bit; a CC 38 result is 14-bit. Only the matching size updates a knob. */ +NrpnResult nrpn_rx_value(const NrpnConfig *config, const NrpnValue *value, uint8_t *knob); + +NrpnResult nrpn_line_format(const NrpnConfig *config, char *out, size_t capacity, size_t *length); +NrpnResult nrpn_line_parse(const char *line, size_t length, NrpnConfig *config); +NrpnResult nrpn_list_add(NrpnConfig *list, size_t *count, size_t capacity, const NrpnConfig *config); + +#endif diff --git a/sdk/drafts/midi-nrpn/octamod.module.json b/sdk/drafts/midi-nrpn/octamod.module.json new file mode 100644 index 0000000000..57956b5765 --- /dev/null +++ b/sdk/drafts/midi-nrpn/octamod.module.json @@ -0,0 +1,95 @@ +{ + "schemaVersion": 2, + "id": "midi-nrpn", + "key": "MIDI NRPN", + "name": "Midi Nrpn", + "version": "0.1.1-experimental", + "category": "midi-usb", + "author": { + "github": "huupsel", + "credits": [ + "huupsel" + ] + }, + "nativeManifest": "manifest.py", + "presentation": { + "label": "MIDI NRPN", + "family": "MIDI", + "summary": "Planned NRPN control from MIDI track knobs.", + "overview": "An unconnected, host-tested protocol core for MIDI track NRPN control.", + "highlights": [ + "Scale a 7-bit knob across a parameter's own range." + ], + "usage": [ + "The planned controls are not yet available on the Octatrack." + ] + }, + "controls": [], + "compatibility": { + "firmware": "1.40C", + "location": "MIDI tracks", + "conflicts": [], + "uiClaims": [ + "key:PUSHC@CTRL1 SETUP", + "key:PUSHD@CTRL1 SETUP", + "key:PUSHE@CTRL1 SETUP", + "key:PUSHF@CTRL1 SETUP", + "key:PUSHA@CTRL2 SETUP", + "key:PUSHB@CTRL2 SETUP", + "key:PUSHC@CTRL2 SETUP", + "key:PUSHD@CTRL2 SETUP", + "key:PUSHE@CTRL2 SETUP", + "key:PUSHF@CTRL2 SETUP", + "screen:MIDI NRPN" + ], + "limitations": [ + "The NRPN core is host-tested only; instrument integration and hardware operation have not been tested." + ], + "effectId": null + }, + "resources": { + "recorded": "Not measured", + "storage": { + "label": "Storage", + "display": "Not measured", + "value": null, + "unit": "unknown", + "method": "unmeasured", + "conditions": "No measurements exist yet. Add exact conditions and source evidence when available.", + "source": "TESTING.md" + }, + "processing": { + "label": "CPU / DSP load", + "display": "Not measured", + "value": null, + "unit": "unknown", + "method": "unmeasured", + "conditions": "No measurements exist yet. Add exact conditions and source evidence when available.", + "source": "TESTING.md" + } + }, + "tests": { + "report": "TESTING.md", + "summary": "The standalone protocol core has host tests; integration and hardware are not tested. Add qualification with worst-case cycles, exact memory and attributed owner-reviewed hardware evidence before submitting.", + "hardwareStatus": "untested", + "evidenceRevision": "b8deefc88b2c3e5f3c6158e364eb741df1924e1d", + "gates": [ + "Worst-case cycles under parameter modulation and maximum load", + "Exact memory region and maximum-instance totals", + "Owner-reviewed real-hardware evidence with actual coverage and limitations" + ] + }, + "license": { + "spdx": "MIT", + "file": "LICENSE", + "declaration": "Replace with accurate authorship, attribution and original/licensed source and media rights. Never include Elektron firmware, extracted routines or tables." + }, + "media": [], + "access": { + "location": "Describe the exact OT page or menu where the module is selected or enabled.", + "steps": [ + "Describe prerequisites, track/machine selection and the exact button/menu sequence." + ], + "screenshots": [] + } +} diff --git a/sdk/drafts/midi-nrpn/qualification.example.json b/sdk/drafts/midi-nrpn/qualification.example.json new file mode 100644 index 0000000000..6eba9986b7 --- /dev/null +++ b/sdk/drafts/midi-nrpn/qualification.example.json @@ -0,0 +1,84 @@ +{ + "moduleVersion": "0.1.1-experimental", + "sourceSha256": "REPLACE_WITH_NATIVE_SOURCE_SHA256", + "imageSha256": "REPLACE_WITH_LOCAL_TESTED_IMAGE_SHA256", + "cycles": [ + { + "processor": "dsp", + "worstCase": null, + "maxConfiguration": null, + "maxInstances": null, + "budget": null, + "unit": "cycles/sample", + "method": "emulator", + "conditions": { + "parameterExtremes": "Describe every minimum, maximum and branch boundary tested.", + "parameterModulation": "Describe simultaneous LFOs, p-locks, MIDI CC and scene sweeps; justify each inapplicable mechanism.", + "modeSwitching": "Describe repeated/interrupted mode, bypass and Part changes.", + "maxLoad": "Describe maximum voices/instances, both cores, FX slots, streaming and USB/MIDI load.", + "inputConditions": "Describe silence, impulses, full-scale inputs, feedback and other worst-case signal conditions." + }, + "report": "TESTING.md" + } + ], + "memory": { + "regions": [ + { + "name": "Replace with each code, state, table, buffer, stack/heap and padding allocation", + "space": "dsp-p", + "words": null, + "wordBits": 24, + "bytes": null, + "scope": "shared" + } + ], + "perInstanceBytes": null, + "sharedBytes": null, + "maxInstances": null, + "totalBytes": null, + "conditions": "State exact build options, alignment, accounting convention, allocator/stack bounds and reused stock/shared memory; justify every absent allocation class.", + "report": "TESTING.md" + }, + "hardware": { + "status": "pending", + "model": "MKII", + "testedOn": "YYYY-MM-DD", + "tester": "Your credited tester handle; no email", + "project": { + "name": "Your local stress project", + "sha256": "REPLACE_WITH_PROJECT_FINGERPRINT", + "recipe": "Record generator/tool revision and command, local source template fingerprint, sample recipe, all settings and modifications needed to reproduce this stress project. Keep the project/card/firmware local." + }, + "durationMinutes": null, + "audioTracks": 8, + "midiTracks": null, + "conditions": { + "parameterExtremes": "Describe every minimum, maximum and branch boundary tested.", + "parameterModulation": "Describe simultaneous LFOs, p-locks, MIDI CC and scene sweeps; justify each inapplicable mechanism.", + "modeSwitching": "Describe repeated/interrupted mode, bypass and Part changes.", + "maxLoad": "Describe maximum voices/instances, both cores, FX slots, streaming and USB/MIDI load.", + "inputConditions": "Describe silence, impulses, full-scale inputs, feedback and other worst-case signal conditions." + }, + "checks": { + "audioContinuity": "failed", + "transport": "failed", + "controls": "failed", + "memoryIntegrity": "failed", + "recovery": "failed" + }, + "report": "TESTING.md", + "maxInstances": null + }, + "documentation": { + "tutorial": { + "title": "Quick tutorial", + "steps": [ + "Explain setup and exactly where to select or enable the module.", + "Demonstrate the main controls with a useful example setting.", + "Explain what to hear/observe and how to stop, reset or bypass." + ] + }, + "screenshots": [], + "screenshotStyle": "black-and-white" + } +} diff --git a/sdk/drafts/midi-nrpn/resource-impact.example.json b/sdk/drafts/midi-nrpn/resource-impact.example.json new file mode 100644 index 0000000000..8f7457a054 --- /dev/null +++ b/sdk/drafts/midi-nrpn/resource-impact.example.json @@ -0,0 +1,21 @@ +{ + "conditions": "Describe the active workload, expensive modes, changing controls, instance count, and whether shared/stock allocations are included.", + "cpu": { + "level": null, + "basis": "source-estimate", + "rationale": "Choose minimal, low, moderate or high from source inspection or a documented workload comparison. Explain the ColdFire work and cite the record; do not invent a utilization percentage.", + "source": "TESTING.md" + }, + "dsp": { + "level": null, + "basis": "source-estimate", + "rationale": "Choose a relative demand tier covering the expensive DSP modes and modulation. Minimal needs an explanation of the small or absent added DSP path.", + "source": "TESTING.md" + }, + "memory": { + "level": null, + "basis": "source-estimate", + "rationale": "Choose a relative footprint tier covering code, state, tables and buffers. Distinguish shared reservations and reused stock buffers from extra per-instance memory.", + "source": "TESTING.md" + } +} diff --git a/sdk/drafts/midi-nrpn/test_nrpn.c b/sdk/drafts/midi-nrpn/test_nrpn.c new file mode 100644 index 0000000000..e124c878ed --- /dev/null +++ b/sdk/drafts/midi-nrpn/test_nrpn.c @@ -0,0 +1,212 @@ +/* SPDX-License-Identifier: MIT */ +#include "nrpn.h" +#include +#include +#include + +static void scaling(void) { + NrpnConfig c = {0, 0, 0, 0, 34, 164, 14}; + uint16_t value; + uint8_t knob; + unsigned seen[165] = {0}; + for (unsigned i = 0; i < 128; ++i) { + assert(nrpn_scale_out(&c, i, &value) == NRPN_OK && value <= 164); + ++seen[value]; + assert(nrpn_scale_in(&c, value, &knob) == NRPN_OK && knob == i); + } + unsigned count = 0; + for (unsigned i = 0; i <= 164; ++i) count += seen[i] != 0; + assert(count == 128 && seen[0] && seen[164]); + assert(nrpn_scale_in(&c, 165, &knob) == NRPN_OK && knob == 127); + c.maximum = 16383; + for (unsigned i = 0; i < 128; ++i) { + assert(nrpn_scale_out(&c, i, &value) == NRPN_OK && value == i * 129); + assert(nrpn_scale_in(&c, value, &knob) == NRPN_OK && knob == i); + } + c.maximum = 4; + assert(nrpn_scale_out(&c, 0, &value) == NRPN_OK && value == 0); + assert(nrpn_scale_out(&c, 127, &value) == NRPN_OK && value == 4); + c.maximum = 0; + assert(nrpn_scale_out(&c, 127, &value) == NRPN_OK && value == 0); + assert(nrpn_scale_in(&c, 100, &knob) == NRPN_OK && knob == 0); + assert(nrpn_scale_out(&c, 128, &value) == NRPN_INVALID); + for (unsigned maximum = 127; maximum <= NRPN_MAX_VALUE; ++maximum) { + c.maximum = (uint16_t)maximum; + for (unsigned i = 0; i < 128; ++i) { + assert(nrpn_scale_out(&c, i, &value) == NRPN_OK); + assert(nrpn_scale_in(&c, value, &knob) == NRPN_OK && knob == i); + } + } + c.bits = 7; c.maximum = 128; + assert(!nrpn_config_valid(&c)); +} + +static void sending(void) { + NrpnTx tx; + NrpnPacket p; + NrpnConfig c = {0, 0, 0, 0, 34, 164, 14}; + nrpn_tx_reset(&tx); + assert(nrpn_tx_prepare(&tx, 2, &c, 127, &p) == NRPN_OK); + assert(p.count == 4 && p.cc[0].controller == 99 && p.cc[0].value == 0 && + p.cc[1].controller == 98 && p.cc[1].value == 34 && + p.cc[2].controller == 6 && p.cc[2].value == 1 && + p.cc[3].controller == 38 && p.cc[3].value == 36); + assert(nrpn_tx_finish(&tx, &p, 1) == NRPN_OK); + assert(nrpn_tx_prepare(&tx, 2, &c, 0, &p) == NRPN_OK && p.count == 2); + assert(p.cc[0].controller == 6 && p.cc[0].value == 0 && + p.cc[1].controller == 38 && p.cc[1].value == 0); + assert(nrpn_tx_prepare(&tx, 3, &c, 0, &p) == NRPN_OK && p.count == 4); + c.number = 156; + assert(nrpn_tx_prepare(&tx, 2, &c, 0, &p) == NRPN_OK && p.count == 4 && + p.cc[0].value == 1 && p.cc[1].value == 28); + assert(nrpn_tx_finish(&tx, &p, 0) == NRPN_OK); + assert(nrpn_tx_prepare(&tx, 2, &c, 0, &p) == NRPN_OK && p.count == 4); + assert(nrpn_tx_finish(&tx, &p, 1) == NRPN_OK); + assert(nrpn_tx_observe(&tx, 2, 6) == NRPN_OK); + assert(nrpn_tx_prepare(&tx, 2, &c, 0, &p) == NRPN_OK && p.count == 2); + assert(nrpn_tx_observe(&tx, 2, 98) == NRPN_OK); + assert(nrpn_tx_prepare(&tx, 2, &c, 0, &p) == NRPN_OK && p.count == 4); + assert(nrpn_tx_finish(&tx, &p, 1) == NRPN_OK); + assert(nrpn_tx_observe(&tx, 2, 101) == NRPN_OK); + assert(nrpn_tx_prepare(&tx, 2, &c, 0, &p) == NRPN_OK && p.count == 4); + c.bits = 7; c.maximum = 127; + assert(nrpn_tx_prepare(&tx, 4, &c, 100, &p) == NRPN_OK && p.count == 3 && + p.cc[2].controller == 6 && p.cc[2].value == 100); + assert(nrpn_tx_prepare(&tx, 16, &c, 0, &p) == NRPN_INVALID); + c.bits = 14; c.maximum = 127; c.number = 128; + assert(nrpn_tx_prepare(&tx, 4, &c, 127, &p) == NRPN_OK && p.count == 4 && + p.cc[0].value == 1 && p.cc[1].value == 0 && + p.cc[2].value == 0 && p.cc[3].value == 127); + c.number = 16382; + assert(nrpn_tx_prepare(&tx, 4, &c, 0, &p) == NRPN_OK && + p.cc[0].value == 127 && p.cc[1].value == 126); + c.number = 16383; + assert(nrpn_tx_prepare(&tx, 0, &c, 0, &p) == NRPN_INVALID); +} + +static void sending_lifecycle(void) { + void (*events[])(NrpnTx *) = {nrpn_tx_playback_start, nrpn_tx_project_load}; + for (unsigned event = 0; event < sizeof(events) / sizeof(events[0]); ++event) { + for (unsigned bits = 7; bits <= 14; bits += 7) { + NrpnTx tx; + NrpnPacket p; + NrpnConfig c = {0, 0, 0, 0, 156, 127, (uint8_t)bits}; + nrpn_tx_reset(&tx); + for (unsigned channel = 0; channel < NRPN_CHANNELS; ++channel) { + assert(nrpn_tx_prepare(&tx, channel, &c, 127, &p) == NRPN_OK); + assert(nrpn_tx_finish(&tx, &p, 1) == NRPN_OK); + assert(nrpn_tx_prepare(&tx, channel, &c, 127, &p) == NRPN_OK && + p.count == (bits == 7 ? 1 : 2)); + } + events[event](&tx); + for (unsigned channel = 0; channel < NRPN_CHANNELS; ++channel) { + assert(nrpn_tx_prepare(&tx, channel, &c, 127, &p) == NRPN_OK && + p.count == (bits == 7 ? 3 : 4) && + p.cc[0].controller == 99 && p.cc[0].value == 1 && + p.cc[1].controller == 98 && p.cc[1].value == 28); + assert(nrpn_tx_finish(&tx, &p, 1) == NRPN_OK); + assert(nrpn_tx_prepare(&tx, channel, &c, 127, &p) == NRPN_OK && + p.count == (bits == 7 ? 1 : 2)); + } + } + } +} + +static void receiving(void) { + NrpnRx rx; + NrpnValue v = {0}; + NrpnConfig c = {0, 0, 0, 0, 34, 164, 14}; + uint8_t knob = 42; + nrpn_rx_reset(&rx); + assert(nrpn_rx_cc(&rx, 0, 38, 36, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 99, 0, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 6, 1, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 98, 34, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 1, 6, 1, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 6, 1, &v) == NRPN_OK && + v.number == 34 && v.bits == 7 && v.value == 1); + assert(nrpn_rx_value(&c, &v, &knob) == NRPN_IGNORED && knob == 42); + assert(nrpn_rx_cc(&rx, 0, 38, 36, &v) == NRPN_OK && + v.number == 34 && v.bits == 14 && v.value == 164); + assert(nrpn_rx_value(&c, &v, &knob) == NRPN_OK && knob == 127); + c.number = 35; + assert(nrpn_rx_value(&c, &v, &knob) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 38, 37, &v) == NRPN_OK && v.value == 165); + assert(nrpn_rx_cc(&rx, 0, 98, 35, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 38, 37, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 101, 0, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 98, 34, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 6, 1, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 99, 127, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 98, 127, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 6, 1, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 99, 0, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 6, 1, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 98, 34, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 121, 0, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 0, 6, 1, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 1, 99, 0, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 1, 98, 34, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 1, 6, 1, &v) == NRPN_OK); + assert(nrpn_rx_cc(&rx, 0, 101, 0, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 1, 38, 36, &v) == NRPN_OK && v.value == 164); + nrpn_rx_reset(&rx); + assert(nrpn_rx_cc(&rx, 1, 38, 36, &v) == NRPN_IGNORED); + assert(nrpn_rx_cc(&rx, 16, 6, 1, &v) == NRPN_INVALID); + assert(nrpn_rx_cc(&rx, 0, 6, 128, &v) == NRPN_INVALID); +} + +static void storage(void) { + NrpnConfig c = {15, 3, 7, 9, 156, 463, 14}, parsed = {0}; + NrpnConfig list[2]; + char line[NRPN_LINE_SIZE]; + size_t length = 0, count = 0; + assert(nrpn_line_format(&c, line, sizeof(line), &length) == NRPN_OK); + assert(!strcmp(line, "#MODWERK_NRPN=1:15:3:7:9:156:14:463\r\n")); + assert(nrpn_line_parse(line, length, &parsed) == NRPN_OK); + assert(parsed.bank == c.bank && parsed.part == c.part && parsed.track == c.track && + parsed.slot == c.slot && parsed.number == c.number && + parsed.maximum == c.maximum && parsed.bits == c.bits); + assert(nrpn_list_add(list, &count, 2, &parsed) == NRPN_OK && count == 1); + assert(nrpn_list_add(list, &count, 2, &parsed) == NRPN_INVALID && count == 1); + parsed.slot = 8; + assert(nrpn_list_add(list, &count, 2, &parsed) == NRPN_OK && count == 2); + parsed.slot = 7; + assert(nrpn_list_add(list, &count, 2, &parsed) == NRPN_INVALID && count == 2); + assert(nrpn_line_parse("#OTHER=1", 8, &parsed) == NRPN_IGNORED); + const char *bad[] = { + "#MODWERK_NRPN", + "#MODWERK_NRPN:1:0:0:0:0:34:14:164", + "#MODWERK_NRPN=2:0:0:0:0:34:14:164", + "#MODWERK_NRPN=1:16:0:0:0:34:14:164", + "#MODWERK_NRPN=1:0:0:0:0:16383:14:1", + "#MODWERK_NRPN=1:0:0:0:0:34:7:164", + "#MODWERK_NRPN=1:0:0:0:0:34:14:999999999999", + "#MODWERK_NRPN=1:0:0:0:0:34:14:", + "#MODWERK_NRPN=1:0:0:0:0:34:14:164:1", + }; + for (unsigned i = 0; i < sizeof(bad) / sizeof(bad[0]); ++i) + assert(nrpn_line_parse(bad[i], strlen(bad[i]), &parsed) == NRPN_INVALID); + memset(line, 'x', sizeof(line)); + length = 99; + assert(nrpn_line_format(&c, line, 3, &length) == NRPN_INVALID); + assert(line[0] == 'x' && length == 99); + + static NrpnConfig full[NRPN_MAX_ENTRIES]; + count = 0; + for (unsigned bank = 0; bank < 16; ++bank) + for (unsigned part = 0; part < 4; ++part) + for (unsigned track = 0; track < 8; ++track) + for (unsigned slot = 0; slot < 10; ++slot) { + NrpnConfig entry = {(uint8_t)bank, (uint8_t)part, (uint8_t)track, + (uint8_t)slot, 34, 164, 14}; + assert(nrpn_list_add(full, &count, NRPN_MAX_ENTRIES, &entry) == NRPN_OK); + } + assert(count == NRPN_MAX_ENTRIES); +} + +int main(void) { + scaling(); sending(); sending_lifecycle(); receiving(); storage(); + puts("NRPN core host checks passed"); + return 0; +} diff --git a/sdk/drafts/midi-nrpn/test_nrpn.py b/sdk/drafts/midi-nrpn/test_nrpn.py new file mode 100644 index 0000000000..130bf996bf --- /dev/null +++ b/sdk/drafts/midi-nrpn/test_nrpn.py @@ -0,0 +1,27 @@ +"""Exercise the actual NRPN core on the host without firmware or hardware.""" +from pathlib import Path +import shutil +import subprocess +import tempfile +import unittest + +HERE = Path(__file__).resolve().parent +CC = shutil.which("cc") + + +@unittest.skipUnless(CC, "host C compiler unavailable") +class NrpnCore(unittest.TestCase): + def test_core(self): + with tempfile.TemporaryDirectory() as folder: + executable = Path(folder) / "nrpn-test" + subprocess.run( + [CC, "-std=c99", "-Wall", "-Wextra", "-Werror", "-O2", + str(HERE / "nrpn.c"), str(HERE / "test_nrpn.c"), "-o", str(executable)], + check=True, + ) + result = subprocess.run([str(executable)], check=True, capture_output=True, text=True) + self.assertIn("NRPN core host checks passed", result.stdout) + + +if __name__ == "__main__": + unittest.main() diff --git a/sdk/drafts/midi-nrpn/unit.s b/sdk/drafts/midi-nrpn/unit.s new file mode 100644 index 0000000000..886cafcc85 --- /dev/null +++ b/sdk/drafts/midi-nrpn/unit.s @@ -0,0 +1,17 @@ +| -- one linked unit. GNU as, ColdFire ISA A+ (m68k-elf-as). +| +| Symbols you `.global` here are what the manifest's Detours name. Absolute +| references to stock code are fine (`jsr (0x40001e50).l`); references to +| your own labels are resolved by the link wherever the build places this, +| so write `lea SYM:l,%a0` for a same-unit address you need as a pointer +| (a bare `lea SYM,%a0` assembles pc-relative -- correct, but four bytes +| shorter than a hand-assembled original if you are matching one). + .text + .global my_hook + +| A "jsr" detour lands here and expects an rts. A "jmp" detour's target +| must first REPLAY the instructions the six-byte jmp displaced, then jump +| back to site+6 (or wherever those instructions would have continued). +my_hook: + nop + rts diff --git a/sdk/drafts/midi-nrpn/verify.py b/sdk/drafts/midi-nrpn/verify.py new file mode 100644 index 0000000000..b993d5b46c --- /dev/null +++ b/sdk/drafts/midi-nrpn/verify.py @@ -0,0 +1,2 @@ +"""Replace with module-specific, meaningful behavior and resource gates.""" +raise SystemExit("[FAIL] Untested development scaffold: implement verification before qualification.")