Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions sdk/drafts/tapekeys/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
MIT License

Copyright (c) 2026 jrs1717

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.
62 changes: 62 additions & 0 deletions sdk/drafts/tapekeys/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Tapekeys

Version 0.1.0-experimental · by @jrs1717 · a draft: bit for bit against its model in `dsp_host`; heard in RAM trials and through the test procedure on the author's MKII (package fe5b9a6a).

## Overview

Tapekeys turns a track into a tape-replay keyboard, on FX1 or FX2. Each trig starts a note on its own strip of tape:
- **The get-up:** the note starts a little flat and rises to pitch as the pinch roller grabs (GTUP).
- **Its own tape:** every note plays slightly flat by its own amount and at its own level (SPRD), as if each key had its own worn tape.
- **The swell:** SWEL brings the note in, from instant to half a second.
- **The tape runs out:** TAPE seconds after the trig the note ends, cut or faded (END), however long you hold it.
- **The mechanics:** MECH adds the running machine under the note: a little hiss and rumble, the motor's faint hum, a soft tick and a slight level wobble at each turn of the capstan, the tape's sparse scrape, and a clunk when the tape runs out and springs back. CLIK, on the setup page, is the roller's thunk at each trig, with its own level.

TONE darkens it and MIX blends it with the dry track. It works best on held notes of strings, choirs, flutes or
organs played chromatically. Before the track's first trig it passes the track dry. For the deck's own drift, flutter
and hiss, put Cassettebox in the other slot.

## Controls

| Page | Knob | Name | Range | Default | What it does |
|---|---|---|---|---|---|
| Main | A | TAPE | 1s-12s | 8s | The tape's length: the note ends this long after its trig. |
| Main | B | SWEL | 0-127 | 30 | The swell: 0 comes in at once (2 ms), 127 over about half a second. |
| Main | C | GTUP | 0-127 | 40 | The get-up: how flat a note starts (up to 4 %) before rising to pitch over about 60 ms. |
| Main | D | SPRD | 0-127 | 50 | Each note's own tape: up to about 12 cents flat and 2 dB up or down, new on every trig. |
| Main | E | MECH | 0-127 | 30 | The running machine: a little hiss and rumble, the motor's hum, capstan ticks and wobble (about 5 a second), the tape's scrape, and a clunk when the tape runs out. |
| Main | F | MIX | 0-127 | 127 | Dry/tape blend. 127 is the tape alone. |
| Setup | A | END | CUT, FADE | CUT | How the tape runs out: CUT stops the note in 5 ms, FADE lets it die over a quarter second. |
| Setup | B | TONE | 0-127 | 90 | A low-pass from 1.5 kHz at 0 to 16 kHz at 127. |
| Setup | C | CLIK | 0-127 | 30 | The roller's thunk at each trig: it rises over about 3 ms (no click) and dies over 40 ms. 0 none. |

- The notes are always slightly flat (by up to SPRD's amount), never sharp: a tape can lag the key but not run ahead
of it. Tune the track a few cents up if you want SPRD's notes centred.
- On FX1 a long TAPE leaves less room for SPRD's pitch: at 8 s a note is at most about 7 cents flat, at 12 s about 5.

## Usage

On an audio track: hold FUNC and press FX1 (or FX2), turn LEVEL to TAPEKEYS and press YES.

## Quick tutorial

1. Load a held string or choir sample on a Flex track, pick TAPEKEYS on FX1 and play a few notes chromatically.
2. Turn SPRD up: each note comes out a little different. Turn GTUP up for a slower, wobblier start.
3. Set TAPE to 2s and hold a long note: it stops after two seconds. Set END to FADE, then TAPE back to 8s.

## Compatibility and limitations

- Works on FX1 or FX2 of any track; several at once.
- It follows each trig of its own track: a track with no trigs (a live input played by hand) passes dry.
- Draft: not yet heard or tested on a unit.

## Screens and audio

Captured from the author's MKII over USB, package fe5b9a6a in a RAM trial on the development twin:

![FX1 main page titled TAPEKEYS with knobs TAPE (8s), SWEL, GTUP, SPRD, MECH and MIX.](media/ot-controls.png)

![FX1 SETUP page with an effect list ending in Tapekeys, selected; controls CUT (END), TONE and CLIK.](media/ot-location.png)

## Tests and measurements

See [TESTING.md](TESTING.md).
109 changes: 109 additions & 0 deletions sdk/drafts/tapekeys/TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Tapekeys 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.

## The model and the engine

- `python3 test_reference.py`: 22 tests pass (5 December 2026): dry before the first trig, the trig at its exact
sample, a split block the same as an unsplit one, the tape running out to exact silence (CUT and FADE), FADE slower
than CUT, a retrig restarting the tape, the swell, the get-up starting flat and settling in tune, SPRD's notes flat
and different, the offset kept inside the ring for every TAPE, mechanics silent at 0 and before the first trig, the
thump then head noise, MIX 0 nearly dry, FX1 reading its own trig word and not FX2's.
- `python3 verify.py`: every gate passes. engine.asm is bit for bit the model in dsp_host: dry before any trig; one
note running out (CUT and FADE, with and without the split at its sample); a long note at the most spread; trigs
every 30 blocks with every knob swept (with and without the split); a trig every block; an FX1 slot reading its own
word and ignoring FX2's; a knob word with LFO fraction bits; garbage state; two seeds. Silence in with MECH 0 is
exact silence, a note's end is exact silence with MECH full, and on all four FX1 bases the guard sees no write
outside the slot's 3,072 words. dsp_host has no per-block trig word, so verify.py wraps the engine in a fixture that
writes the trig word on a schedule before each call; the engine's bytes are unchanged.
- Cost: 325 executed instructions a sample while notes play, 334 with a trig every block (about stock SPRING REV's worst; the record comes with the performance audit).
- The author's first trials (5 December 2026, package af219ba6, RAM twin 117eb07f): "The mechanics is cool, but the click at the beginning is a bit distracting". Changed: MECH is now only the running tape (head hiss plus a low rumble); the onset is CLIK, its own setup knob, a thunk through two low-passes that rises over about 3 ms instead of starting at its peak. Then (package 2252be8e): "Mech seems a bit noisy, I think thinking it would be a little noise with some more mechanical artifacts"; the author chose all four offered: the hiss 12 dB and the rumble about 8 dB down, and MECH now brings the motor's 48 Hz hum, a tick and a slight level wobble at each capstan turn, the tape's sparse scrape, and a clunk when the tape runs out. At MECH full the bed under a note is -42 dBFS RMS (was -34), its ticks peak about -30 dBFS, the clunk about -23 dBFS.
- Found while adding them: the engine's scrape test kept the noise word's sign in the accumulator's extension, so about half of all samples scraped (the model was right; verify.py caught it at 1 LSB); and the run-out cases rendered 0.54 s, shorter than their 1 s tape, so they never reached its end (now 2.2 s).
- Found while writing: MIX 127 let the dry through at -84 dB (now the tape alone), and the gate's fixtures shared one
image file name in dsp_gate, so one case ran another's fixture (each fixture now names its own image).

## On the unit

### Test procedure: tapekeys 0.1.0-experimental, 2026-12-06

Build: revision `0f3c46f806b5`, package `tapekeys.mwrm` SHA-256 `fe5b9a6a8d8aa80cbe1f2440fb0137d9c7649c5ffd22c2349a89a3fb7e483c7d`. `npm run test:procedure -- tapekeys --package <run>/../tapekeys.mwrm --share /tmp/modwerk-share.sock --no-emulator --soak-pc-channel 11 --soak-auto-channel 11 --out <run>`, 581 s. Emulator results are not hardware evidence; only what ran on the unit is.

| # | Step | Layer | Result | Command | Evidence |
|---|---|---|---|---|---|
| 1 | Software checks | host | passed | `npm run module:doctor -- --draft tapekeys` | logs/01-software.log |
| 2 | Beside every other module | contract | not run: a draft is judged beside every other module by module:doctor --draft (its compatibility line, step 1) | | |
| 3 | Name the build | host | passed | | logs/03-build.log |
| 4 | DSP cost model | contract | passed | `node scripts/cycle-scan.mjs check` | logs/04-cost-model.log |
| 5 | Emulator rehearsal | emulator | not run: no emulator session: left out with --no-emulator | | |
| 6 | Read the unit | unit | passed: Part 1 on A01: working = saved, saved once so that RELOAD works at the end | `node scripts/device.mjs status --socket /tmp/modwerk-share.sock`<br>`node scripts/octatrack-part-state.mjs read --socket /tmp/modwerk-share.sock --out <run>/part-start.json`<br>`node scripts/device.mjs do inventory --socket /tmp/modwerk-share.sock` | logs/06-unit-read.log |
| 7 | Scripted unit pass | unit | passed | `npm run device:test -- --share /tmp/modwerk-share.sock --testing-entry <run>/device-test.md <run>/../tapekeys.mwrm` | logs/07-unit-pass.log |
| 8 | Soak | unit | passed: Part 1 on A01: back on A01 from A02, Part 1 on A01 reloaded; working = saved | `node scripts/device.mjs try <run>/../tapekeys.mwrm --seconds 420 --socket /tmp/modwerk-share.sock`<br>`node scripts/octatrack-soak.mjs --seconds 120 --programs 0-3 --pc-channel 11 --auto-channel 11 --log <run>/soak.json`<br>`node scripts/octatrack-part-state.mjs restore --socket /tmp/modwerk-share.sock --start <run>/part-start.json` | logs/08-soak.log |
| 9 | Cost on the unit | unit | passed | `npm run device:price -- --share /tmp/modwerk-share.sock --out <run>/price.json --scene 'the bank, pattern and Part the unit was on, transport stopped (test:procedure)' --curve T1,T3,T6,T7 <run>/../tapekeys.mwrm` | logs/09-cost-unit.log |
| 10 | Put back | unit | passed: Part 1 on A01: nothing to put back; working = saved | `node scripts/device.mjs do inventory --socket /tmp/modwerk-share.sock`<br>`node scripts/octatrack-part-state.mjs restore --socket /tmp/modwerk-share.sock --start <run>/part-start.json` | logs/10-restore.log |
| 11 | Agent by hand | unit | passed: on fe5b9a6a, Tapekeys on T1 FX1, T2 FX2 and T5 FX1 at once (FX1 and FX2, both cores) while the pattern played: the defaults; END FADE, TONE 0, CLIK 127; TAPE 1s with SWEL, GTUP, SPRD and MECH at 127 and MIX 64 (notes running out every second); TAPE swept to 12s while playing. Health after each: 0 stalls, 0 errors, no crash, CPU 700-729. After STOP: stall none recorded, latest entry 44.7 us late (0 in the guard's window). The main and setup pages match the README; every label fits (TAPE, SWEL, GTUP, SPRD, MECH, MIX; CUT/FADE, TONE, CLIK). The sound not judged here (the author's stage; heard in four RAM trials). STOP, Part reloaded (working = saved), the trial rolled back | `device try`, `pick:`, `png:`, `health`, `stats`, `stall`, `late`, `reload` | media/ot-controls.png, media/ot-location.png, hand-setup.png, hand-main.png |
| 12 | Submitter's own stage | unit | to do: the author's Keep and power cycle on fe5b9a6a | | |

#### Edge cases for this change

Derive them from what the change touches and run each one (docs/TEST_PROCEDURE.md#edge-cases). A start, from the manifest and the changed files:

- an effect slot: FX1 and FX2, both DSP cores, eight instances at once; one edited while another plays (docs/MODULE_QUALIFICATION.md#essential-persistence-and-instance-checks--8-october-2026)
- persistence: saved in a Part, then a Part reload, a project reload and a power cycle; removed while a saved Part still names it (docs/OCTATRACK_MODULE_EDGE_CASES.md#copying-and-saving)
- the loader: install, replace, remove and Undo; a set the base refuses rolls back whole; the pool full; a trial that expires with a page open (docs/OCTATRACK_HARDWARE_TRAPS.md#dsp-loader-dynamic-dsp-code)
- DSP code: DSP FULL; both cores; the receiver window; pipeline stalls the instruction count hides (docs/OCTATRACK_HARDWARE_TRAPS.md#coldfire-and-dsp-load)
- the USB link: USB unplugged mid-transfer; the host silent until the base rolls back; a reconnect (docs/OCTATRACK_HARDWARE_TRAPS.md#usb-and-ep0)
- load and admission: the pick at the 85 % line with the delays quiet and open; the guard counters while playing (docs/OCTATRACK_HARDWARE_TRAPS.md#coldfire-and-dsp-load)

| Case | Why this change makes it a risk | How run | Result |
|---|---|---|---|
| FX1 and FX2 on both cores | the ring sits in the slot's buffer; FX1's is 3,072 words | step 7 (six placed at once); step 11 (T1 FX1, T2 FX2, T5 FX1); verify.py's guard on all four FX1 bases | passed: no crash, stall or dropped frame; CPU 727, core 0 peak 769, core 1 peak 634 per mille |
| Notes running out while playing | the run-out, the return clunk and FADE every second | step 11: TAPE 1s, MECH 127, END FADE | passed: no stall or crash; the clunk's sound is the author's to judge |
| TAPE moved while a note plays | the head's room cap is drawn at the trig | step 11 (swept 1s to 12s); test_reference.py: the offset stays under every TAPE's cap | passed |
| Trig splits | stock splits calls at the trig's sample | verify.py with and without the split; test_reference.py: split = unsplit | passed in dsp_host |
| The frame-cost curve, playing | a DSP effect does no ColdFire work per frame | step 9: `device:price --curve T1,T3,T6,T7` | rest 0, first and each 3.5 points within the curve's run-to-run spread (T1 -2.6, T3 -3.3, T6 +3.5, T7 -2.5); empty and medium patterns admitted, longest frame 85.5 % |
| Persistence | knob bytes saved in the Part | step 12 | the author's stage |

#### Left for the submitter at their unit

- how it sounds and plays, and timing by ear
- MIDI, scenes and recording with it
- it beside the other modules installed on their unit
- two instances with different settings, on both FX slots and both DSP cores where it can (docs/MODULE_QUALIFICATION.md)
- Part reload, project save and reload, and a power cycle with it saved: what survives (the Keep and the power cycle are theirs)

#### For the pull request

Tested on a unit: package fe5b9a6a8d8a, <model and OS>, test:procedure steps 6, 7, 8, 9, 10; the developer's stage <done or not yet>.
Edge cases: the table above, one row a case (or "Edge cases: none, because …").

## Stock flows

Not tested.

## Performance

Not measured on a unit.

## Reported by the author after the Keep (package fe5b9a6a)

Reported by jrs1717 on the flashed base, one trig at the pattern's start and a long sample, while turning main and setup
knobs: "seems to be an issue with volume cutting out after changing values while playing with a play trig"; the sound
stayed silent through later trigs until stop and play.

Cause, as far as software can see it: the engine placed each trig by a count of the block's frames carried from call
to call. If the dispatcher's calls ever stop summing to 16 frames a block (a call left out, say), every later trig
falls outside its call and is missed; the note runs out once and stays silent, and only a restart of the sequencer
(where the count and the trig line up again) brings it back. Which event moved the count on the unit is not known.

Fixed: each call now places the trig by itself, from the dispatcher's a flag (a = 0: the block's first sub-block, from
frame 0; a = 1: the block's last frames, from 16 - n7), so nothing carries from call to call; a call with no frames
returns at once. test_reference.py: a block whose a = 0 call never came still finds its trig and the later ones; an
empty call. verify.py: every gate passes again, bit for bit.

The author tried that build (e5fb1d2c) in a RAM trial: it still cut out ("something is definitely wrong, but I can't
pinpoint it. Volume keeps cutting out"). Next suspect: the trig bit in only one of the block's two calls (the
finding says it is set in the trig's frame, not in which call), so a trig landing mid-block was missed by both
builds. Fixed: a latch fires each trig once, whichever calls carry its bit: at its sample in its call, at once when
already past, at the next call's start when it lands after this call. test_reference.py 24 pass (the bit in the first
call only, in the second only; one firing while the bit stays); verify.py bit for bit. Not yet tested on a unit.

Loading