From 3b9263b87331930a78b82489b54d347d44d09024 Mon Sep 17 00:00:00 2001 From: funkymog <17906650+funkymog@users.noreply.github.com> Date: Sun, 6 Dec 2026 01:33:01 +0100 Subject: [PATCH] LFO Learn: draft scaffold and plan An empty LFO's first PMTR turn lands on the track's last-turned parameter. Waits on two base hooks asked of the owner on the agent board. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/lfo-learn/LICENSE | 30 ++++++ sdk/drafts/lfo-learn/README.md | 51 +++++++++++ sdk/drafts/lfo-learn/TESTING.md | 15 +++ sdk/drafts/lfo-learn/manifest.py | 78 ++++++++++++++++ sdk/drafts/lfo-learn/octamod.module.json | 91 +++++++++++++++++++ .../lfo-learn/qualification.example.json | 84 +++++++++++++++++ .../lfo-learn/resource-impact.example.json | 21 +++++ sdk/drafts/lfo-learn/unit.s | 17 ++++ sdk/drafts/lfo-learn/verify.py | 2 + 9 files changed, 389 insertions(+) create mode 100644 sdk/drafts/lfo-learn/LICENSE create mode 100644 sdk/drafts/lfo-learn/README.md create mode 100644 sdk/drafts/lfo-learn/TESTING.md create mode 100644 sdk/drafts/lfo-learn/manifest.py create mode 100644 sdk/drafts/lfo-learn/octamod.module.json create mode 100644 sdk/drafts/lfo-learn/qualification.example.json create mode 100644 sdk/drafts/lfo-learn/resource-impact.example.json create mode 100644 sdk/drafts/lfo-learn/unit.s create mode 100644 sdk/drafts/lfo-learn/verify.py diff --git a/sdk/drafts/lfo-learn/LICENSE b/sdk/drafts/lfo-learn/LICENSE new file mode 100644 index 0000000000..786113d6bc --- /dev/null +++ b/sdk/drafts/lfo-learn/LICENSE @@ -0,0 +1,30 @@ +MIT License + +Copyright (c) 2026 funkymog + +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/lfo-learn/README.md b/sdk/drafts/lfo-learn/README.md new file mode 100644 index 0000000000..b93733da33 --- /dev/null +++ b/sdk/drafts/lfo-learn/README.md @@ -0,0 +1,51 @@ +# LFO Learn + +Version 0.1.0-experimental · by @funkymog · a draft, not built or tested yet. + +## Overview + +LFO Learn remembers the last parameter you turned on an audio track. When you open LFO SETUP and turn PMTR on an LFO that is not modulating anything yet (DEPTH 0), the first turn lands on that parameter, so the LFO you are setting up starts at the thing you were just playing with. + +## Controls + +None. LFO Learn adds no knob, page or setting: it changes where the first PMTR turn of an empty LFO lands. + +## Usage + +1. On an audio track, turn a knob on the SRC, AMP, FX1 or FX2 page, for example the filter cutoff on FX1. +2. Press [FUNC]+[LFO] to open LFO SETUP. +3. Turn the PMTR knob of an LFO whose DEPTH is 0. The first turn lands on the parameter from step 1; further turns step through the list as on stock. + +## Quick tutorial + +1. Put a filter on FX1 of track 1 and turn its cutoff a little. +2. [FUNC]+[LFO], turn LFO 1's PMTR one detent: it shows the cutoff. +3. On the LFO page, raise DEPTH 1 to hear the cutoff move. + +## Compatibility and limitations + +- What counts as "turned": a knob turn that stores a Part value on the SRC, AMP, FX1 or FX2 page of an audio track. Turns on the LFO page, on setup pages (FUNC+page) or with a trig held do not count. +- An LFO with DEPTH above 0 behaves exactly as stock. +- The remembered parameter lives in RAM, one per track, and is forgotten at a power cycle. Nothing new is written to the Part or the project: the PMTR value you pick is stock's own byte, so projects load the same without the module. +- MIDI tracks keep stock behaviour. +- Waits on the base: it needs a notify-only knob-turn hook and a take hook on the LFO SETUP editor's PMTR edit, which the owner has been asked about (agent board). The existing `ev_knob_store` take hook is not used, because taking it would take knob turns away from Scale Quantizer and Midiverb. +- Takes no key and no screen (`uiClaims` is empty). + +## 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 -- lfo-learn` builds it and tries it on your unit over USB; `--watch` does that again on every save. +- Check it: `npm run module:doctor -- --draft lfo-learn`. 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/lfo-learn/TESTING.md b/sdk/drafts/lfo-learn/TESTING.md new file mode 100644 index 0000000000..e914904b7e --- /dev/null +++ b/sdk/drafts/lfo-learn/TESTING.md @@ -0,0 +1,15 @@ +# Lfo Learn testing + +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. + +## 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/lfo-learn/manifest.py b/sdk/drafts/lfo-learn/manifest.py new file mode 100644 index 0000000000..78210ea3e5 --- /dev/null +++ b/sdk/drafts/lfo-learn/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="lfo-learn", + key="LFO LEARN", + kind=Kind.CF_PATCH, # no DSP code, no chooser row + doc="The first PMTR turn of an LFO at DEPTH 0 lands on the track's last-turned parameter.", + category=Category.TRACK, author="funkymog", author_url="https://github.com/funkymog", + 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/lfo-learn/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/lfo-learn/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/lfo-learn/octamod.module.json b/sdk/drafts/lfo-learn/octamod.module.json new file mode 100644 index 0000000000..d08434d71a --- /dev/null +++ b/sdk/drafts/lfo-learn/octamod.module.json @@ -0,0 +1,91 @@ +{ + "schemaVersion": 2, + "id": "lfo-learn", + "key": "LFO LEARN", + "name": "LFO Learn", + "version": "0.1.0-experimental", + "category": "system", + "author": { + "github": "funkymog", + "credits": [ + "funkymog" + ] + }, + "nativeManifest": "manifest.py", + "presentation": { + "label": "LFO LEARN", + "family": "Modulation", + "summary": "An empty LFO starts its destination list at the parameter you last turned.", + "overview": "Turn a knob on SRC, AMP, FX1 or FX2, then open LFO SETUP: the first PMTR turn of an LFO whose DEPTH is 0 lands on that parameter. LFOs that already modulate something behave as stock. Nothing new is saved in the project.", + "highlights": [ + "The first PMTR turn of an empty LFO jumps to the parameter you last turned on that track.", + "LFOs with a DEPTH above 0 behave exactly as stock.", + "Nothing new is stored: projects save, reload and open on stock unchanged." + ], + "usage": [ + "On an audio track, turn the parameter you want to modulate, for example FILTER cutoff on FX1.", + "Press [FUNC]+[LFO] for LFO SETUP and turn PMTR of an LFO at DEPTH 0: it lands on that parameter.", + "Set DEPTH on the LFO page." + ] + }, + "controls": [], + "compatibility": { + "firmware": "1.40C", + "location": "Audio tracks", + "conflicts": [], + "uiClaims": [], + "limitations": [ + "Prototype: waits on two new base hooks the owner has not yet reviewed; not built or tested.", + "Audio tracks only; MIDI tracks keep stock behaviour.", + "The remembered parameter is kept in RAM only and is forgotten at a power cycle." + ], + "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": "No tests have been run. Add tests.qualification with worst-case cycles, exact memory and attributed owner-reviewed hardware evidence before submitting. This scaffold cannot pass publication checks.", + "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": "LFO SETUP ([FUNC]+[LFO]) on any audio track; PMTR knobs of LFOs at DEPTH 0.", + "steps": [ + "Select an audio track and turn a knob on its SRC, AMP, FX1 or FX2 page.", + "Press [FUNC]+[LFO] to open LFO SETUP.", + "Turn the PMTR knob of an LFO whose DEPTH is 0: the first turn lands on the parameter you turned." + ], + "screenshots": [] + } +} diff --git a/sdk/drafts/lfo-learn/qualification.example.json b/sdk/drafts/lfo-learn/qualification.example.json new file mode 100644 index 0000000000..f24ba06cd4 --- /dev/null +++ b/sdk/drafts/lfo-learn/qualification.example.json @@ -0,0 +1,84 @@ +{ + "moduleVersion": "0.1.0", + "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/lfo-learn/resource-impact.example.json b/sdk/drafts/lfo-learn/resource-impact.example.json new file mode 100644 index 0000000000..8f7457a054 --- /dev/null +++ b/sdk/drafts/lfo-learn/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/lfo-learn/unit.s b/sdk/drafts/lfo-learn/unit.s new file mode 100644 index 0000000000..886cafcc85 --- /dev/null +++ b/sdk/drafts/lfo-learn/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/lfo-learn/verify.py b/sdk/drafts/lfo-learn/verify.py new file mode 100644 index 0000000000..b993d5b46c --- /dev/null +++ b/sdk/drafts/lfo-learn/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.")