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
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion sdk/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
},
{
"id": "grain",
"version": "0.1.3-experimental",
"version": "0.2.0-experimental",
"addedAt": "2026-11-20T12:00:00Z"
}
]
Expand Down
2 changes: 1 addition & 1 deletion sdk/machines/octatrack/frame-costs.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"bbd": {"first":0.7,"each":0.4,"rest":0,"points":[0.7,-0.1,0.4,0.7],"measured":"bbd 0.1.2-experimental on T1 T3 T6 T7: Dev17 C04 at 126 BPM, trigs on steps 1/5/9/13 of T1-T4, T6, T7 (T2 and T4 play samples), picks on empty C02; owner's MKII; base 0.8 twin 27 479ad391; 8 s a reading; 2026-11-22"},
"euclid": {"first":3.7,"each":2.5,"rest":2.5,"points":[3.7,3.9,6.4,6.7],"measured":"euclid 0.1.5-experimental on T1 T3 T6 T7: Dev17 C04 at 126 BPM, trigs on steps 1/5/9/13 of T1-T4, T6, T7 (T2 and T4 play samples; stock alone 79.4 %), picks on empty C02; base dce1d30e (0.8 twin); 8 s a reading; 2026-11-22 (npm run device:price -- --curve)"},
"everb": {"first":0.7,"each":0.2,"rest":0,"points":[0.7,0.8,1,-0.6],"measured":"everb 0.1.2-experimental on T1 T3 T6 T7: Dev17 C04 at 126 BPM, trigs on steps 1/5/9/13 of T1-T4, T6, T7 (T2 and T4 play samples; stock alone 79.4 %), picks on empty C02; base dce1d30e (0.8 twin); 8 s a reading; 2026-11-22 (npm run device:price -- --curve)"},
"grain": {"first":33.3,"each":33.3,"rest":0,"points":[33.3],"measured":"grain 0.1.3-experimental on T1: C04 at 126 BPM, trigs on steps 1/5/9/13 of T1-T4, T6, T7 (the scene FM Synth 0.1.5's curve used); picks on empty C02; Grain on T1, whose Flex slot holds a loaded 16-bit stereo sample. One instance: a second (T3, the other track with a loaded sample) was refused on 23 November and on T6/T7 Grain would render silence; owner's MKII; base 95adb64b (0.8 development twin, built from main 4035fdfa8); 8 s a reading; 2026-11-23 (evidence/frame-cost.json)"},
"grain": {"first":33.9,"each":33.9,"rest":0,"points":[33.9],"measured":"grain 0.1.2-experimental on T1: Dev17 C04 at 126 BPM, trigs on steps 1/5/9/13 of T1-T4, T6, T7 (T2 and T4 play samples), picks on empty C02; owner's MKII; base 0.8 twin 28 053fd054; 8 s a reading; 2026-11-22"},
"lofi2": {"first":1,"each":0,"rest":0,"points":[1,-1.5,-0.3,-1.3],"measured":"lofi2 0.1.1-experimental on T1 T3 T6 T7: Dev17 C04 at 126 BPM, trigs on steps 1/5/9/13 of T1-T4, T6, T7 (T2 and T4 play samples), picks on empty C02; owner's MKII; base 0.8 twin 28 053fd054; 8 s a reading; 2026-11-22"},
"miniverb": {"first":1.5,"each":0,"rest":0,"points":[1.5,1.4,1.2,1.2],"measured":"miniverb 0.2.3-experimental on T1 T3 T6 T7: Dev17 C04 at 126 BPM, trigs on steps 1/5/9/13 of T1-T4, T6, T7 (T2 and T4 play samples; stock alone 79.4 %), picks on empty C02; base dce1d30e (0.8 twin); 8 s a reading; 2026-11-22 (npm run device:price -- --curve)"},
"poly8": {"first":51,"each":51,"measured":"0.3.4 on T1 (empty) from rest, owner's MKII, base 0.8, 22 Nov 2026, Dev17 C01 (trigs on steps 1/5/9/13 of all eight tracks), longest frame over 8 s: 88-90 -> 140.8 %, mean 39.0 -> 77.1 %, 5,260 renders dropped in 8 s, twin 64b66394; T1/T5 retrigger auditions +30.3 on base 0.7.11 (#1863)"},
Expand Down
13 changes: 7 additions & 6 deletions sdk/octatrack/modules/grain/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Grain

Version 0.1.3-experimental · by A Force Truly Evil (@AForceTrulyEvil). The author played an earlier build on an MKI. The [test record](TESTING.md) identifies the build for each result.
Version 0.2.0-experimental · by A Force Truly Evil (@AForceTrulyEvil). The author played an earlier build on an MKI. The [test record](TESTING.md) identifies the build for each result.

## Overview

Expand All @@ -20,17 +20,18 @@ SRC (knobs A to F):
| POS | 0 to 127.8 | Where the grains are read: 0 is the start of the sample, 127.8 the end. Turned slowly it moves in eighths (41.0, 41.1, 41.2, 41.3, 41.5, 41.6, 41.7, 41.8, 42.0) and speeds up as you turn faster; a pressed knob jumps by seven. |
| SIZE | 0 to 127 | The length of each grain, on an exponential scale: 0 is 10 ms, 64 about 100 ms, 127 one second. |
| DENS | 0 to 127 | How often a grain is born. Low values leave gaps; 64 puts the grains one after another; 127 overlaps four of them (up to six sound at once). With MODE SYNC it picks the division of the bar: 1, 2, 4, 6, 8, 12, 16, 24, 32, 48 or 64 grains. |
| SPRY | 0 to 127 | How far each grain strays from POS at random: 0 keeps them all on POS, 127 spreads them up to half the sample either way. The sample is a ring: a grain born or reading past the end carries on from the beginning, and one going back past the beginning carries on from the end. |
| SPRY | 0 to 127 | How far each grain strays from POS at random: 0 keeps them all on POS, 127 spreads them up to half the sample either way. What happens when a grain reaches an edge of the sample is set by EDGE. |
| SCAN | -2.00 to +2.00 | A read head that runs through the sample from POS: 1.00 is the sample's own speed, negative runs backwards, 0.00 holds. It wraps round the sample and starts again from POS at every trig. |

SRC SETUP (knobs A to D):
SRC SETUP (knobs A to E):

| Knob | Values | What it does |
| --- | --- | --- |
| SHAP | NORM, TRI, PERC, SQR | The window of each grain. NORM a smooth bell: the grains melt into one another. TRI a triangle, a little more present in the middle. PERC an instant attack and an exponential fall to about -40 dB, so each grain is a tick or a pluck. SQR almost square, with short ramps: the grain keeps the sample's transients, like a stutter. |
| DIR | 0 to 127 | The share of grains that play backwards: 0 none, 64 half, chosen at random, 127 all. |
| PAN | OFF, 1 to 127 | A random pan for each grain, independent of where it was born. OFF at 0, the widest spread at 127. |
| MODE | RAND, SYNC | RAND: the grains are born freely, as DENS says. SYNC: they follow the project's tempo, and DENS picks how many fall in a bar. |
| EDGE | CLMP, WRAP, STOP, BNCE | What happens at the start and end of the sample. Turn several detents to change a value. **CLMP:** SPRY can't push a grain past an end. A grain that runs off one end carries on from the other. **WRAP:** the sample is a loop. A grain pushed or running off one end comes out of the other (as in 0.1.2). **STOP:** grains stay inside. SPRY can't push one past an end, and a grain that reaches an end stops there. **BNCE:** SPRY can't push a grain past an end. A grain that reaches an end plays back the other way. |

## Usage

Expand All @@ -43,7 +44,7 @@ SRC SETUP (knobs A to D):
1. Double-tap a track key, choose GRAIN in the machine list and press YES, then double-tap again and pick a Flex sample.
2. Put a trig on the track and play. Press SRC and turn POS: the grains move through the sample, and the waveform shows where. Turn SIZE down for a fine mist and up for long overlapping grains.
3. Turn SPRY up to scatter the grains around POS, and DENS up to thicken the cloud. Turn SCAN to let the read head run through the sample by itself.
4. Press SRC twice for SRC SETUP: turn PAN for a spread across the stereo field, DIR for a share of backward grains, SHAP to change the grain window, and MODE to SYNC to lock the grains to the tempo.
4. Press SRC twice for SRC SETUP: turn PAN for a spread across the stereo field, DIR for a share of backward grains, SHAP to change the grain window, MODE to SYNC to lock the grains to the tempo, and EDGE to choose what happens when a grain reaches the start or end of the sample.
5. Press SRC once more from SRC SETUP for the full-screen page, with a larger waveform and every value beside its name, for precise settings.
6. Press SRC again to leave the full-screen page. Press STOP to stop playback.

Expand All @@ -59,7 +60,7 @@ Everything else, menus, saving, loading, scenes, recording, MIDI and timing, is

## What a Part keeps

Everything Grain stores in a Part is a value stock's own power-on check accepts: PTCH as Flex's (64 is 0), SHAP and MODE in LOOP and RATE, POS's eighths in TSNS, and DIR and PAN in the track's unused NEIGHBOR bytes. A project opened without the module, or on a unit without it, keeps its banks and plays the track as Flex.
Everything Grain stores in a Part is a value stock's own power-on check accepts: PTCH as Flex's (64 is 0), SHAP and MODE in LOOP and RATE, POS's eighths in TSNS, EDGE in TSTR (0 to 3), and DIR and PAN in the track's unused NEIGHBOR bytes. A project opened without the module, or on a unit without it, keeps its banks and plays the track as Flex.

## Screens and audio

Expand All @@ -74,7 +75,7 @@ The author supplied a 45-second recording of Grain on their Octatrack MKI. They

## Compatibility and limitations

Grain uses a Modwerk base for Octatrack OS 1.40C and plays the selected track's Flex sample. Up to six grains can sound on each admitted track. An unreadable or loading sample plays silence. Replacing a sample during a note takes effect on the next trig. Sequencer trigs, trig keys, CHROMATIC keys and MIDI notes all play the grains, a note at its pitch (within PTCH's -12 to +12 semitones, as on Flex); only FUNC + YES in the sample pool plays the sample as a plain Flex, as a preview, until the track's next trig. POS parameter locks use whole numbers. Each grain plays 3 dB below full scale, so six long grains of a loud sample stay clean; raise the track volume if a single grain is too quiet. PTCH changed units in 0.1.3: Grain 0.1.2 stored semitones (-24 to +24), 0.1.3 reads Flex's units (5 a semitone), so a PTCH saved with 0.1.2 plays at a fifth of its transposition (+12 becomes +2.4): set it again. A SCALE in PROJECT > CONTROL > SEQUENCER (the scale quantizer that comes with FM Synth and Scale Quantizer) now steps in the same units as Grain; not tested on a unit.
Grain uses a Modwerk base for Octatrack OS 1.40C and plays the selected track's Flex sample. Up to six grains can sound on each admitted track. An unreadable or loading sample plays silence. Replacing a sample during a note takes effect on the next trig. Sequencer trigs, trig keys, CHROMATIC keys and MIDI notes all play the grains, a note at its pitch (within PTCH's -12 to +12 semitones, as on Flex); only FUNC + YES in the sample pool plays the sample as a plain Flex, as a preview, until the track's next trig. POS parameter locks use whole numbers. Each grain plays 3 dB below full scale, so six long grains of a loud sample stay clean; raise the track volume if a single grain is too quiet. PTCH changed units in 0.1.3: Grain 0.1.2 stored semitones (-24 to +24), 0.1.3 reads Flex's units (5 a semitone), so a PTCH saved with 0.1.2 plays at a fifth of its transposition (+12 becomes +2.4): set it again. A SCALE in PROJECT > CONTROL > SEQUENCER (the scale quantizer that comes with FM Synth and Scale Quantizer) now steps in the same units as Grain; not tested on a unit. EDGE (0.2.0): a project saved with 0.1.3 or earlier opens with EDGE on CLMP, so a grain that SPRY threw past an edge is now born on that edge instead of wrapping. Set EDGE to WRAP for the 0.1.2 sound, or to STOP for the 0.1.0 and 0.1.1 sound without the click.

## Tests and measurements

Expand Down
46 changes: 45 additions & 1 deletion sdk/octatrack/modules/grain/TESTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
# GRAIN testing

Grain 0.1.3-experimental · by A Force Truly Evil.
Grain 0.2.0-experimental · by A Force Truly Evil.

## 0.2.0-experimental: EDGE, four ways to treat the sample's edges, 23 November 2026

The package is `e8d7c794905a2ff05a1f44f4d5a221263a8668f4fbf1f1e407a9f849701ae6d1` (31,524 bytes), rebuilt on 0.1.3 with
`scripts/octatrack-module-packages.py` in the pinned toolchain. It loads 30,148 bytes of code and data and reserves 2,864 of BSS
(33,012 bytes of static memory; 31,808 in 0.1.2). The deepest Grain-only audio stack is 780 bytes by the same method as 0.1.2's 768
(`grain_render` 168, `gran_render` 412 against 392, `stereo_paged` 92 and `stereo_page` 84, plus four return addresses and 8 for the
frame pointers `link.w` saves).

- **EDGE** is a selector in SRC SETUP, knob E, with four values stored in SETUP E (the byte stock calls TSTR, whose range 0 to 3
passes the power-on check): CLMP 0 (the default), WRAP 1, STOP 2 and BNCE 3. A value above 3 reads as CLMP. SETUP E also held the
eighths of SIZE in the display code, but nothing ever wrote them, so `part_size` no longer reads it. EDGE lives in the engine's track (`gran_set_edge`), not in `GranParams`, so the
structure `verify_lanes.py` reads is 0.1.3's.
- **Where a grain is born** (POS plus SPRY outside the sample). WRAP: on the other side, as in 0.1.2. CLMP, STOP and BNCE: on the edge
that was crossed; past the end, a forward CLMP grain starts at the beginning (the end and the beginning are the same point) and a
STOP or BNCE grain, or a backward one, on the last frame.
- **A grain that reaches an edge while it plays.** CLMP and WRAP: it carries on from the other side, in its own direction. STOP: it
ends there. BNCE: it is reflected about the edge and turns round.
- **STOP shortens the grain** that would reach an edge before its window ends, so that the window ends at the edge. 0.1.0 and 0.1.1
cut such a grain in the middle of its window, which clicked. A grain that does not reach an edge is unchanged.
- **Cost.** The two loops that run for every sample, `stereo_page` and `stereo_paged`, compile to the same instructions as in 0.1.2
(the function bodies in `grain_core.s` compared). The new code runs when a grain is born or reaches an edge: a few compares, and for
STOP a multiplication and a compare (a division only for a grain that does reach an edge).
- **Host results.** WRAP renders match 0.1.2 bit for bit over 7,200 combinations of sample length, mono and stereo, POS, SIZE, DENS,
SPRY, DIR, SCAN and pitch. STOP renders match 0.1.1's engine (with 0.1.2's window tables) bit for bit where no grain comes near an
edge (96 cases with SPRY 0, DIR 0 and SCAN 0 on long samples). On a clean 220 Hz tone, the output steps over 2,500 in one sample went from 118 to 0 at POS 124, 10 to 0 at
POS 100, 7 to 0 at POS 110 with SPRY 60, and 2 to 0 at POS 60 with SPRY 127 (STOP, SIZE 70, DENS 100, before and after the
shortening); at pitch x4 with half the grains backwards, from 23 to 8. `verify.py` runs every case in all four modes (optimized
against plain paths) and holds references for CLMP, STOP and BNCE beside 0.1.2's three, which WRAP keeps. `range_test.c` checks
births at both edges and a sounding grain at both edges in every mode. `verify_lanes.py` passes on the compiled kernels, including
0.1.3's PTCH checks.

**On the MKI** (the author, OS 1.40C, official base `6d23e888`, card set with Grain, E-Verb, Mini Verb, syntiz, FM Synth, BBD Delay and
Tape Echo): the first build of this release, package `8a4555de` (STOP without the shortening), with an eight-tone sample, one tone a
second from C3 to E5, so the notes heard say which part of the sample each grain reads. SIZE 64, DENS 100, SCAN 0, PTCH 0. In CLMP,
WRAP and BNCE the notes heard were those the host renders give: at POS 0 with SPRY 60, at POS 127 with SPRY 0 and 60, and at POS 0
with DIR 127. STOP was nearly silent at POS 127.8, as expected (a grain born that close to the end has a few milliseconds of sample
left), and played as expected at POS 120. The author heard a click when a STOP grain reached an edge; the shortening above is the
change made for it. A later build, package `0e4bebd4` (STOP shortened; card set for the same base), loaded and played, and the author ran the rest of
the release checklist (the STOP click, EDGE across a save and a power cycle, a p-lock on EDGE, an older project) and reported nothing
wrong. **CPU meter** (the stock meter, read by eye, DENS and SPRY at maximum, PTCH +24, all four EDGE modes): 65 to 68 %, about 66 to
67 % on average in every mode. **Not recorded:** a unit run of the final package `e8d7c794`, which is `0e4bebd4`'s engine on 0.1.3 (the unit
runs above were made before 0.1.3 was merged); the frame-cost curve for 0.2.0 (`evidence/frame-cost.json` is 0.1.3's: first 33.3, each
33.3); MKII.

## 0.1.3-experimental: trig keys, CHROMATIC keys and MIDI notes play grains, in tune, 23 November 2026

Expand Down
2 changes: 1 addition & 1 deletion sdk/octatrack/modules/grain/evidence/performance.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schema": 1,
"module": "grain",
"version": "0.1.3-experimental",
"version": "0.2.0-experimental",
"kind": "coldfire",
"cycles": {
"unit": "cycles/event",
Expand Down
Loading
Loading