Skip to content
Draft
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/drivebox/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.
73 changes: 73 additions & 0 deletions sdk/drafts/drivebox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Drivebox

Version 0.1.0-experimental · by @jrs1717 · a draft: bit for bit against its model in `dsp_host`, not yet run on a unit.

## Overview

Drivebox is a heavy distortion for an audio track's FX1 or FX2 slot, voiced four ways by MODE:
- **CRNCH:** a single stage into a hard knee. Bright, aggressive, classic hard clipping.
- **SAW:** an upper-mid push into a soft stage and a hard clip, the lows and highs lifted after: a chainsaw buzz.
- **METAL:** a tight low cut into a soft stage and a hard clip, with a full three-band EQ after: high-gain metal.
- **TUBE:** a biased soft stage, so even harmonics and a warmer edge; SAG makes loud notes squash and bloom.

TIGHT cuts the lows before the drive, GAIN pushes the stages, LOW, MID and HIGH shape the result around MIDF, PRES opens the top for bite, GATE silences the hiss between notes, and LEVL and MIX set the level and the blend with the dry track.

## Controls

| Page | Knob | Name | Range | Default | What it does |
|---|---|---|---|---|---|
| Main | A | GAIN | 0-127 | 64 | Drive: how hard the stages are pushed. 0 is a light crunch, 127 saturated. |
| Main | B | LOW | 0-127 | 64 | The lows after the drive: 64 the voicing's own, 0 none, 127 about +12 dB. |
| Main | C | MID | 0-127 | 64 | The mids around MIDF: 64 the voicing's own, 0 scooped out, 127 about +12 dB. |
| Main | D | HIGH | 0-127 | 64 | The highs after the drive: 64 the voicing's own, 0 none, 127 about +12 dB. |
| Main | E | LEVL | 0-127 | 64 | Output level: 64 about the dry track's, 127 about +6 dB. |
| Main | F | MIX | 0-127 | 127 | Dry/distorted blend. 127 is the distortion alone. |
| Setup | A | MODE | CRNCH, SAW, METAL, TUBE | CRNCH | The voicing (above). |
| Setup | B | MIDF | 0-127 | 64 | The mid band's centre, 200 Hz to 3 kHz. LOW and HIGH sit below and above it. |
| Setup | C | TIGHT | 0-127 | 32 | Cuts the lows before the drive, 20 Hz to 900 Hz, for a tighter, less flubby distortion. |
| Setup | D | GATE | 0-127 | 0 | Noise gate: silences the distortion's hiss between notes. 0 is off. |
| Setup | E | PRES | 0-127 | 32 | Presence: lifts the highs and opens the cabinet roll-off for more bite. |
| Setup | F | SAG | 0-127 | 0 | Squash and bloom: loud notes drive less and, on TUBE, shift the bias, like a tube amp. |

## Usage

Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to DRIVEBOX at the end of the list and press YES. Press FX1 for the main page (GAIN, LOW, MID, HIGH, LEVL, MIX); hold FUNC and press FX1 for the setup page (MODE, MIDF, TIGHT, GATE, PRES, SAG).

## Quick tutorial

1. Put Drivebox on FX1 of a track playing a bass line, a guitar or a synth. At the defaults it is CRNCH at GAIN 64.
2. Turn GAIN up for more drive, and LEVL to match the level of the dry track.
3. Hold FUNC and press FX1, and step MODE through SAW, METAL and TUBE.
4. On METAL, scoop MID and sweep MIDF; raise TIGHT for a tighter low end and GATE to silence the hiss between notes.
5. On TUBE, raise SAG and play harder and softer to hear it squash and bloom.

## Compatibility and limitations

- FX1 or FX2, any audio track. Buffer-free: no delay line.
- With GATE at 0, silence in gives exact silence out.
- Knob moves glide over a call (16 samples) for LEVL, MIX and the gate; GAIN and the EQ step once a call.
- A MODE change fades the effect out and swaps the voicing once it is silent, then fades back in.
- Driven hard it aliases (a bright, gritty edge on high notes), as heavy digital distortion does; the band-limit into the clipper and the two-pole cabinet soften it. TUBE with SAG high leaves a little DC on loud high notes.
- Cost: at most 377.9 executed DSP instructions a sample in dsp_host, 1.20x stock SPRING REV.
- It prefers effect id 10, as Fuzzbox, Glitchbox, Loopbox, Grainbox and Cassettebox do. Over USB the base gives each its own id; in a card set only one of them fits.

## Tests and measurements

See [TESTING.md](TESTING.md).

## Authorship and licences

Original code by @jrs1717 under the MIT licence in LICENSE. Inspired by distortion pedals and tube stages in general, with no product's code, tables, names or labels.

## Screens and audio

Captured from the author's MKII on its flashed base with Drivebox kept (package c58dbaa4):

![FX1 SETUP page with an effect list running from COMB FILTER to Euclid, Drivebox selected; knobs labelled CRNCH (MODE), MIDF, TIGHT, GATE, PRES and SAG.](media/ot-location.png)

![FX1 main page titled DRIVEBOX with knobs GAIN, LOW, MID, HIGH, LEVL and MIX.](media/ot-controls.png)

## Develop

- Hear it: `npm run module:dev -- drivebox --cycles 378 --cycles-kind executed --state 80 --buffer 0 --slots both`.
- Check it: `npm run module:doctor -- --draft drivebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`. `engine.asm` is written by `gen_engine.py` from `reference.py`: edit those, not the engine.
93 changes: 93 additions & 0 deletions sdk/drafts/drivebox/TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Drivebox testing

## 0.1.0-experimental

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.

## In dsp_host (not hardware evidence)

`python3 -B verify.py`, 5 December 2026, on the engine after the code review's fixes: every gate passes. The engine matches `reference.py` bit for bit for every MODE at its defaults and its dearest setting, every knob swept over its range in each mode, MODE changed while playing (the fade and the swap) and with a trig split every block (the swap waits for the fade), GATE on loud and near-silent stretches, TUBE with SAG 127 on a loud tone, a 5-frame trig split every block, a knob word with an LFO's fraction bits, a MODE word with companion bits set, garbage state before init, two seeds and two instances. Silence in is exact silence out in every mode at the defaults, the dearest setting, every knob at 0 and SAG and GATE at 127; a burst's tail ends in exact silence.

`python3 -B test_reference.py`: 21/21 (the knob sweeps' ends and shape, silence, MIX 0, LEVL 64 near the dry level, GAIN, TUBE's even harmonics, the EQ bands, TIGHT, the cabinet and PRES, the clipper band, the gate's hold, SAG, the mode fade and swap (with a split), the DC blockers cleared at a swap, HIGH and PRES never saturating, no accumulator wrap).

A fresh-session code review (5 December) found two bugs, both fixed and covered: a MODE change could swap the voicing while the effect was still at about 69 % level when a trig split shortened the fade (the swap now waits for LEVL's run to reach nothing), and going back to a biased voicing could thump from a stale DC blocker (the blockers are cleared at every swap). Its smaller points are fixed too: the gate's hold counts samples, not calls; HIGH and PRES no longer saturate together (the EQ's gains have headroom); the knob sweeps are exact at their ends (TIGHT 0 cut at 72 Hz, not the 20 Hz the README says, before).

## Sound quality

`npm run fx:audit` on renders from `dsp_host` of this engine (`python3 -B verify.py --fx-audit PLAN RENDERS --mode N`, the dearest setting: every knob at 127, MIX 96), 5 December 2026:

| Mode | Idle | DC alone / under a tone (after 1.5 s) | Aliasing, 1.1 / 2.7 / 5.3 / 9.1 kHz at -12 dBFS |
|---|---|---|---|
| CRNCH | digital silence | -72.0 / -67.9 dBFS | -22.3 / -16.4 / -12.4 / -2.5 dBc |
| SAW | digital silence | -72.0 / -65.9 dBFS | -20.3 / -15.6 / -11.4 / -2.3 dBc |
| METAL | digital silence | -72.0 / -70.5 dBFS | -19.9 / -15.2 / -11.1 / -3.6 dBc |
| TUBE | digital silence | -72.0 / -54.7 dBFS | -23.5 / -17.1 / -12.6 / -5.1 dBc |

- Idle is digital silence and DC passes in every mode, alone and under a tone (the audit's limit -45 dBFS).
- Moving the DC blocker after LEVL fixed TUBE's DC under a tone (it was -35.6 dBFS: LEVL's clip of the biased stage's lopsided output added DC after the blocker), and SAG's bias shift is now TUBE's alone, so CRNCH stays symmetric. TUBE with SAG 127 still leaves -45 to -58 dBFS of DC on loud high tones (its bias moves with the level, by design); recorded, not changed.
- Aliasing exceeds the audit's -60 dBc default in every mode, as Fuzzbox's does: a distortion driven this hard turns a tone into a near-square wave whose harmonics fold back at 44.1 kHz. The band-limit into the clipper and the two-pole cabinet soften it; oversampling would cost far more than the budget allows. The author heard it on the unit and judged the sound good; the figures are recorded here.

## On the unit

### Test procedure: drivebox 0.1.0-experimental, 2026-12-05

Build: revision `50a4c1fc5811`, package `drivebox.mwrm` SHA-256 `c58dbaa439115adf28524edf38449b2fb74e50ac8c21782cf8b7c2b05d5f17e2`. `npm run test:procedure -- drivebox --package <run>/../drivebox.mwrm --share /tmp/modwerk-share.sock --no-emulator --soak-pc-channel 11 --soak-auto-channel 11 --out <run>`, 580 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 drivebox` | 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>/../drivebox.mwrm` | logs/07-unit-pass.log |
| 8 | Soak | unit | passed: Part 1 on A01: transport stopped, Part 1 on A01 reloaded; working = saved | `node scripts/device.mjs try <run>/../drivebox.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>/../drivebox.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 c58dbaa4, Drivebox on T1 FX1, T2 FX2 and T5 FX1 at once (both slots, both cores) while the pattern played: the defaults; every knob at 127 on TUBE; MODE stepped quickly down to CRNCH and up through SAW and METAL. Health after each: 0 stalls, 0 errors, no crash, CPU 685-729. After STOP: stall none recorded, latest entry 39.8 us late (0 in the guard's 80-190 us window). The main and setup pages match the README; every label fits (CRNCH, SAW, METAL, TUBE, MIDF, TIGHT). The sound not judged here (the author's stage). STOP, Part reloaded (working = saved), the trial rolled back | `device try`, `pick:T1:FX1:DRIVEBOX`, `pick:T2:FX2:DRIVEBOX`, `pick:T5:FX1:DRIVEBOX`, `png:`, `health`, `stats`, `stall`, `late`, `reload` | main.png, setup.png, setup-full.png, mode-crnch.png, mode-2.png, mode-3.png |
| 12 | Submitter's own stage | unit | passed, as reported by jrs1717 (5 December 2026): on the flashed base ddb56b72, `device try c58dbaa4 --seconds 60 --accept` (no crash, stall, freeze or skipped track; kept set 21 to 22, only Drivebox added); the setup and main pages captured for the README; Drivebox picked on a track with MODE and GAIN changed, played, the Part saved, a power cycle: "everything survived" | `device try --accept`, `png:` | media/ot-location.png, media/ot-controls.png |

#### 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, both cores | buffer-free: only its 80 state words | step 7 (T1 and T5); step 11 (T1 FX1, T2 FX2, T5 FX1 at once) | passed: five placed at once, CPU 733, core 1 peak 799, core 0 peak 753 per mille; three refused by the base for budget, no crash, stall or dropped frame |
| The frame-cost curve, playing | the per-call work (the mode, the follower, the sweeps, the gate's hold) runs on the frame | step 9: `device:price --curve T1,T3,T6,T7` | passed: frame 0 at rest and in use; empty admitted (longest frame 36.6 %), medium admitted (86.3 %), 0 dropped |
| MODE changed while playing | each mode's constants and stage count change at once | step 11 (quick steps down and up); verify.py: the fade and swap, and with a trig split every block (the swap waits for silence) | passed: no stall, error or crash; whether it clicks is the author's to hear |
| Every knob at 127 | the most drive, EQ and gate at once | step 11 on TUBE; verify.py each mode at its dearest | passed |
| Silence and the tail | one-poles and the bias can leave a few LSB | verify.py: exact silence in and after a burst, every mode, at the defaults, the dearest, every knob at 0 and SAG and GATE at 127 | passed in dsp_host |
| DC under a tone | the biased stage and LEVL's clip | fx:audit dc and dc-tone in every mode | passed (limit -45 dBFS); TUBE with SAG 127 leaves -45 to -58 dBFS on loud high tones, recorded |
| Persistence | knob bytes saved in the Part | step 12 | passed (the author, after a Part save and a power cycle) |

#### 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 c58dbaa43911, MKII, OS 1.40C, development twin 117eb07f of base ddb56b72, test:procedure steps 6 to 11; the developer's stage passed (Keep, Part save, power cycle).
Edge cases: the table above, one row a case (or "Edge cases: none, because …").

The author's trial of c58dbaa4 before this run (5 December): "Sounds awesome".

#### Earlier trials

Not yet run on a unit through the test procedure. The author heard earlier builds in RAM trials (5 December, development twin 117eb07f of base ddb56b72): the first prototype (a2f871ea) "sounds good so far", the upgraded build (fa97b960: the two-pole cabinet, the clipper band, the gate's hold) "sounds great". The review fixes since have not been heard.

## Performance

`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 5 December 2026: per-sample work 366 words; measured unsplit 340.1 (SAW, METAL) to 362.5 (moving), worst 377.9 (the moving pattern with a split of 1 frame); stress clean (eight instances, per-core peaks 1508.8 and 1477.7, 0 clobbers, 0 stray writes). 1.20x SPRING REV (314.19), 1.14x DJ EQ (330.94), justified in the record. The package declares 378.
Loading
Loading