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

Version 0.1.0-experimental · by @jrs1717 · a draft, not tested on a unit yet.

## Overview

A glitch effect for FX2 of any track. Glitchbox keeps the last third of a second of what the track plays. At every slice, a note value at the project's tempo, ACT decides whether that slice glitches. A glitched slice is filled with RPT repeats taken from what was just played:

- **CHOP** replays recent pieces in a new order.
- **STUT** ratchets the start of the slice before: each repeat half as long as the last, speeding up into a buzz.
- **ARPG** steps it through pitches: arpeggios or octave leaps.

The glitch side is silent between glitches, so MIX works like a normal wet/dry: 64 puts the glitches over the track, 127 leaves the glitches alone.

## Controls

Main page (press FX2):

| Knob | Name | Range | Default | What it does |
|---|---|---|---|---|
| A | TIME | 1/64, 1/32, 1/16, 1/8, 1/4 | 1/16 | Slice length at the project's tempo. A slice longer than 179 ms is halved until it fits. |
| B | ACT | 0-127 | 64 | The share of slices that glitch, rising evenly from none at 0 to about 70 % at 127. |
| C | SHAP | 0-127 | 32 | Each repeat's fade in and out: 1/64 of it at 0, rising evenly to a quarter at 64 and a full swell at 127. |
| D | RPT | 1-8 | 4 | Repeats within a glitched slice. CHOP and ARPG cut it into equal repeats; STUT halves each repeat, a ratchet that speeds up. |
| E | MIX | 0-127 | 64 | Dry/glitch blend: 0 the dry track, 127 the glitches alone (silent between them). |
| F | TAIL | 0-127 | 64 | After a glitch its last repeat keeps echoing and fades out: 0 none, about a third of a second at 64, about 3 s at 127. The next glitch cuts it. |

Setup page (hold FUNC and press FX2):

| Knob | Name | Values | What it does |
|---|---|---|---|
| A | TYPE | CHOP, STUT, ARPG | The kind of glitch. |
| C | VAR | A, B, C, D | CHOP: plain, pitched (0.5, 0.75, 1.5 or 2x), reversed with fades twice as long, pitched and crushed to 9 bits. STUT: plain, each repeat's second half silent, reversed, three semitones lower each repeat and crushed. ARPG: major arpeggio up, minor arpeggio down, octave leaps, random major steps and crushed. |

Every knob can be parameter-locked and modulated by an LFO. A change takes effect at the next slice.

## Usage

1. Select an audio track with its TRACK key.
2. Hold FUNC and press FX2 to open the effect's SETUP, turn LEVEL to GLITCHBOX and press YES.
3. Press FX2 for TIME, ACT, SHAP, RPT, MIX and TAIL. Hold FUNC and press FX2 again for TYPE (knob A) and VAR (knob C).

On MKI, FUNC is labelled FUNCTION.

## Quick tutorial

1. Put Glitchbox on FX2 of a track playing a drum loop. At the defaults it is CHOP A at 1/16, glitching about half the slices over the track at half level.
2. Raise ACT for more glitched slices, RPT for faster rolls inside them, and change TIME for longer or shorter slices.
3. Hold FUNC and press FX2, set TYPE to STUT or ARPG and VAR to B, C or D, and play the same loop.
4. Turn MIX to 127 for the glitches alone, or to 0 to hear the track alone again.

## Compatibility and limitations

- FX2 only: the capture ring needs an FX2 slot's buffer (15,870 words, stopping short of Sidechain Compressor's key window). On FX1 it passes the track dry.
- During a long tail the ring stops recording if its write position would reach the window being echoed; it records again, from nothing, once the tail has faded, so the next glitch can wait up to a slice longer.
- Mono capture: the replay is the track's mono sum on both sides, raised 3 dB to sit level with a stereo track; loud peaks are limited at full scale.
- Slices follow the project's tempo but not yet the pattern's steps, track speed or swing; [issue #2491](https://github.com/repeat98/modwerk/issues/2491) asks for a step clock for effects.
- Declared incompatible with Analog BD, which currently requires the stock DSP effects, as every custom DSP effect is.
- Cost in dsp_host: about 139 executed DSP instructions a sample while glitching (stock SPRING REV about 262). Not measured on a unit yet.

## Tests and measurements

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

## Authorship and licences

Original code by @jrs1717 under the MIT licence in [LICENSE](LICENSE). The design is inspired by glitch effects in general; no product's code, tables, samples or names. Ghost Cut's notes on the FX2 ring (its size and the key window) helped.

## Screens and audio

None yet.

## Develop

- Host test, no tools: `python3 -B test_reference.py`.
- Render gate (Octabam's DSP tools): `python3 -B verify.py`.
- Hear it: `npm run module:dev -- glitchbox`; check it: `npm run module:doctor -- --draft glitchbox`.
28 changes: 28 additions & 0 deletions sdk/drafts/glitchbox/TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Glitchbox 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.

## In dsp_host (no firmware, no unit)

1 December 2026, macOS, Octabam f7d7290's `dsp_asm` and `dsp_host`, `sdk/octatrack/tools/dsp_gate.py` 4c33a6ac.

- `python3 -B verify.py`: every gate passed. Every instruction decodes as written (signed `mpy`/`mac x0,y1` only, no `rep`, no `mpysu`); no label is a prefix of another, case-blind; state inside X:(r7+$00..$3f). Bit for bit against `reference.py`: every TYPE and VAR glitching at every slice, the defaults at 90, 120 and 174 BPM, every knob swept while glitching, a tempo word changing the slices, a 5-frame trig split every block, a knob word with an LFO's fraction bits, garbage state before init, state from two seeds, and an FX1-sized slot (allocator base $2000), which passes dry. Exact silence out for silence in, in every type at the dearest setting; a burst's tail ends in exact silence.
- `python3 -B test_reference.py`: 11 of 11 passed (constants against their formulas, slice lengths at four tempos, MIX 0 within 1 LSB of dry, ACT 0 at MIX 127 silent, ACT setting how often, all twelve TYPE/VAR combinations sounding different, SHAP's fade rising evenly, the tail ringing on and longer with TAIL, silence).
- Cycle meter while glitching at every slice, executed instructions a sample: 134.5 to 138.7 across the twelve combinations.
- Not run: two instances with their own buffers (dsp_gate hands every instance the same allocator entry).

## On the unit

1 December 2026, the author's Octatrack on its flashed base ddb56b72 (OS 1.40C), RAM trials of 120 s with `npm run module:dev -- glitchbox --cycles 130 --cycles-kind executed --state 64 --buffer 15870 --slots fx2`: three trials installed and rolled back, each with no crash, stall, freeze or skipped track logged. Reported by the author: no clicks or dropouts; MIX kept a lot of the dry track (the glitch side then played the live track between glitches). Changed: the glitch side is silent between glitches and MIX defaults to 64. Then reported: SHAP had little effect (its fade grew from 1/64 to only 1/33 of a repeat by the knob's middle). Changed: the fade rises evenly, 1/64 at 0, 1/4 at 64, a full swell at 127, and CHOP C doubles it. Then reported: full MIX seemed lower than the dry track (the replay is the mono sum, about 3 dB under a stereo track, and fades in and out). Changed: +3 dB on the glitch, limited at full scale. Then reported: ACT seemed to do nothing (a glitch lasted RPT slices and the ring then recaptured for a slice or two, so ACT 64 and 127 glitched about as much). Changed: a glitch fills one slice with RPT repeats, the ring keeps recording, and ACT is the share of slices that glitch (in the model: 0 %, about 31-38 %, 38-55 %, 72-79 % and 93 % of the time at ACT 0, 32, 64, 96 and 127). Then asked: temper ACT between the two, more difference between the variations and between the types. Changed: ACT scaled so 127 glitches about 70 % of the time (model: 24, 31, 55 and 72 % at 32, 64, 96, 127); STUT is a ratchet, each repeat half what is left of the slice (2756, 1378, 689, 344, 172, 173 samples for 1/16 at 120 BPM, RPT 6); CHOP B always pitched, CHOP C reversed; ARPG B a falling minor arpeggio, ARPG C octave leaps; D variations crushed to 9 bits. Then asked for longer tails (an echo after a glitch). Changed: a TAIL knob (slot 5): the last repeat keeps looping under a decaying gain, about 50 ms near 0 to about 3 s at 127; the ring freezes only if its writer would reach the looped window.

## Stock flows

Not tested.

## Sound quality

Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour.

## Performance

Not measured on a unit. Listing it needs evidence/performance.json.
Loading
Loading