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
1 change: 1 addition & 0 deletions changelog/2026-11-29-digitakt-ii-filter-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Digitakt II base (development): modules can add filter types to each track's FLTR page, listed after the six stock types with their own names and knob names, saved with the kit, and running their own sound-chip routine with the stock filter envelope and LFO. Stock filters are unchanged; a kit saved with a module filter opens on the official OS with the default filter. A filter module names its routine and its cost in `build.json` (`sharc.filters`, `sharc.cost`). Run on one unit with a test filter.
46 changes: 41 additions & 5 deletions docs/verification/2026-11-25-digitakt-ii-filter-types.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Proposal: module filter types on the Digitakt II's FLTR page

Status: design approved by the owner on 25 November 2026 (types in the stock list, one type per module, stock movement, the per-voice site at `0x1c6c13`, `tables/7`), with four points folded in below: the official OS must open these kits, the fallback is the stock default, one budget per block, and how a fifth filter gets its number. No base code yet; the open points below come first.
Status: design approved by the owner on 25 November 2026 (types in the stock list, one type per module, stock movement, the per-voice site at `0x1c6c13`, `tables/7`), with four points folded in below: the official OS must open these kits, the fallback is the stock default, one budget per block, and how a fifth filter gets its number. Built in the base on this branch, checked in the emulator and on one unit (below).

## Why

Expand Down Expand Up @@ -71,11 +71,11 @@ struct dt2_filter {
};
```

Each module filter has its own fixed type number, claimed on the agent board and kept once released, because kits save it, so it needs the same protection as a machine id. The base code adds a board kind `filter-id` (`filter-id digitakt-ii/N`, in `KINDS` in `scripts/agent-board.mjs`), and `pr:ready` detects a package's new `filter:<type>` the way it detects a new `machine:<id>`. Until that kind exists, types 7 and 8 for the first two filters are claimed by hand as `machine-id` claims named `digitakt-ii/filter-7` and `digitakt-ii/filter-8`. Numbers start at 7 and have no fixed end below 127 (the stored byte is signed, and `0xff` means "none"): the fifth filter module claims 11, the sixth 12, and so on. Room 4 limits how many filters are installed together, not which numbers exist, so a fifth module only needs the room raised in a base update, and its type number never moves. The base's sound-chip table covers types up to the highest registered number. The base answers the descriptor lookup, the names, the list, the parameter codes and the kit-load check for registered types. An unregistered type loads as the stock default (type 0), as on the official OS.
Each module filter has its own fixed type number, claimed on the agent board and kept once released, because kits save it, so it needs the same protection as a machine id. The base code adds a board kind `filter-id` (`filter-id digitakt-ii/N`, in `KINDS` in `scripts/agent-board.mjs`), and `pr:ready` detects a package's new `filter:<type>` the way it detects a new `machine:<id>`. The kind came with #2447; types 7 (Vowel) and 8 (Notch/Peak) are claimed as `filter-id digitakt-ii/7` and `digitakt-ii/8`. Numbers start at 7 and have no fixed end below 127 (the stored byte is signed, and `0xff` means "none"): the fifth filter module claims 11, the sixth 12, and so on. Room 4 limits how many filters are installed together, not which numbers exist, so a fifth module only needs the room raised in a base update, and its type number never moves. The base's sound-chip table answers every index from -128 to 255. The base answers the descriptor lookup, the names, the list, the parameter codes and the kit-load check for registered types. An unregistered type loads as the stock default (type 0), as on the official OS.

### Sound-chip slots

A module's package carries its filter in `build.dt2_sharc` as machine players do, with `{ "filters": [{ "type": 7, "entry": "label" }] }`. The base keeps L2 `0x200c4000`-`0x200c4800` (after the effect slot's `0x200c3000`-`0x200c4000`) for its filter dispatcher, four slots (one 48-bit instruction each) and four per-voice state areas' pointers. The builder writes `JUMP entry` for a registered filter and a jump to its stand-in's stock case for a type with no code. The site at `0x1c6c13` becomes a jump to the dispatcher only for types 7 or more; types 0-5 take the stock path untouched.
A module's package carries its filter in `build.dt2_sharc` as machine players do, with `{ "filters": [{ "type": 7, "entry": "label" }] }`. The base keeps L2 `0x200c4000`-`0x200c4800` (after the effect slot's `0x200c3000`-`0x200c4000`) for its type table (`0x200c4000`), four slots (one 48-bit instruction each, `0x200c4600`) and its filter dispatcher (`0x200c4640`). The builder writes `JUMP entry` for a registered filter and a jump to its stand-in's stock case for a type with no code. The site at `0x1c6c13` becomes a jump to the dispatcher only for types 7 or more; types 0-5 take the stock path untouched.

The dispatcher saves the registers the voice loop keeps (the machine work found `R0` live across a nearby test; the set will be read off a register dump before code is written), reads the type in `R2`, and calls the slot. A filter routine:

Expand All @@ -97,9 +97,45 @@ Different site (effects: pre-send `0x1c18a6`; filters: per-voice dispatch `0x1c6

No module on the Digitakt II. On the Digitakt I, draadpiraat's Filters (#1445, draft) adds two types to the FLTR page by its own patch; that machine's base has no filter hook either, and nothing is shared between the two.

## Still to confirm before code
## Built so far (25 November 2026, development base, emulator only)

1. In a coupled run: that `DM(0x255990 + track)` follows the FLTR type the musician picks, and the field each stock type gives. A first scripted run (25 November, FUNC+FLTR, DOWN, YES twice, then a trig) left every voice's field at 1, the default type's, so that key sequence did not change the type; the next run picks it by the path the OS's list really uses.
- **ColdFire** (`filters.c`, `filters-entry.s`, `mk2/filters.h`): `core_filters` (room 4), and five guarded sites: the filter descriptor lookup `0x400c89c6`, the filter-type list getter `0x40052c98` (the menu that FUNC+SRC opens on the FLTR page), the name and short-name lookups `0x400da71e` and `0x400da744` (12-byte records at `0x4020ef30`), and the kit-load check `0x400db492`. The parameter-code lookup `0x400da3a2`, which the base already takes for machines, reads the filter type as its third argument for slots 35-37 (bound 5); its entry answers an added filter as its stand-in. The FLTR page's knob names follow the type on E, F and G.
- **Sound chip** (`planDt2FilterTable`): the lookup at `0x1c26df` points at a table in L2 `0x200c4000`-`0x200c4600` that answers every index from -128 to 255 (index 0 at `0x200c4200`), with a registered type's field set to its stand-in's. Builder tests with the owner's OS check the six stock words (1, 3, 2, 4, 5, 6), the stand-ins' words, none for every other number, and that a set with filters and no machine changes only this site.
- **Panel probe** (development base `a444e01d`, a test filter standing for Multi-Mode): the list shows TEST FILTER after EQUALIZER; choosing it sets track 1's filter byte to 7; the FLTR page shows TFRQ, TRES and TMOR; no fault. The filter picture above FREQ and RESO is not drawn for the added type (a per-type view switch, still to find).
- **Coupled run** (development base `85ccfb78`, the test filter standing for Lowpass 4, image `ea693607`): choosing TEST FILTER runs per-voice field 3 (Lowpass 4) on track 1, and the PCM since the ready point is identical to choosing Lowpass 4 (`82c37eb7`). So an added type reaches the sound chip as itself and plays as its stand-in.

## Later checks (29-30 November 2026)

- **Track 9** (emulator, image `f3dev`): with the test filter on track 9 and track 1 on a stock type, the routine ran for voices 16 and 17 only, so filter types reach the sound chip per track (the machine words' track-1-only trap does not apply).
- **The official OS opens these kits** (emulator, stock OS 1.17 image, a persistence card): track 1's filter byte set to 7, SAVE PROJECT, the byte set to 5, LOAD PROJECT. The load routine read the stored 7 (`d0` at `0x400db492`), stored 0, and the FLTR page drew Multi-Mode; no fault. On the development base the same round trip keeps 7.
- **The FLTR page's picture** (`0x40074580`, a switch on types 0-5) now answers an added type as its stand-in.
- **One budget**: packages declare `build.dt2_sharc` `cost`; the builder sums machines, filters and effects against `DT2_SHARC_BUDGET`.
- **Unit**, Digitakt II, OS 1.17, image `443ff13134c316e4e40df919cdc63b859b1a4af0b2d51396ac8de1c03b4fdf58` (development base `6273bc6b` with a test routine for filter 7 that halves the voice, standing for Lowpass 4), run by Claptom-music on 30 November 2026, reported as all steps passed: the type list showed the six stock types and TEST FILTER last; the stock types sounded as before; TEST FILTER played the track at about half level without clicks and showed Lowpass 4's box with TFRQ and TRES; back on Lowpass 4 the level returned; with TEST FILTER on track 9 and a stock type on track 1 only track 9 was quieter; SAVE PROJECT, another project and back kept TEST FILTER; a busy pattern with it on several tracks ran for a minute without freezes or clicks; the saved project loaded on the official OS 1.17 with Multi-Mode and no freeze.

## The owner's review (30 November 2026)

- **Claims**: `filter-id digitakt-ii/7` and `/8` are on the board.
- **Build path**: a module's `build.json` names its routine in `sharc.filters` (`{type, entry label}`, type 7-126 claimed as `filter:<type>`) with `sharc.cost` above 0; a filter-only part needs no `players`. The package build writes both into `build.dt2_sharc`. The contract refuses a routine without a cost or with cost 0, an unclaimed or out-of-range type and an empty part; the builder refuses cost 0 too.
- **The sound chip's bound**: the index the table is read with is the track's word at `0x255990` as it is (`M0 = DM(I1, M4)`, `0x1c26c5`); nothing bounds it on stock either. The table now answers -128 to 255, every index but the six stock ones and the registered types giving 0 (no filter), so neither a stored `0xff` (255 or, sign-extended, -1) nor any other byte reaches a slot. Builder tests read indices -128, -1, 127, 128 and 255 as 0.
- **`d4` after the picture switch** (`filters-entry.s`): after `0x40074588` every case ends at `0x40074800`, which restores `d4` with the other saved registers before `rts`; the only later uses (`0x40074670` on) are on another path and write `d4` first. Nothing reads the stand-in type after the switch.
- **After #2445 merges in**: the shared `I4` constant, one budget for effects with machines and filters, and the table order in `interface.json` and `base.json`.
- **Builder tests** added: more than four routines, module code over the filter range, the filter-only set (only the filter parts and the module's code).

Unit cases for the combined image (not run yet):

1. The base with no filter module installed, against stock: every stock filter type sounds and draws as before.
2. Morpha on machine type 9 after the parameter-lookup change in `machines-entry.s`: its knobs and sound as before.
3. Two filter types in one kit, on two tracks, with the knob names switching between them.
4. A kit naming a filter type the build doesn't have, opened on the official OS 1.17.
5. A cycle count with a filter routine on every voice.

## Open (as of 30 November 2026)

Items 1, 3 and 4 below are done; item 2, where each stand-in keeps its cooked cutoff, is open in [FILTERS.md](../../sdk/machines/digitakt-ii/elekloader/modwerk/FILTERS.md), and a unit cycle count sets the budget again.

## Confirmed before code

1. Done for track 1 (above). Still to check on other tracks: the machine work found the sound chip's own per-track machine words held the added type for track 1 only, so a run with the filter on track 9 decides whether the filter types need the same treatment.
2. Where the stand-in's cooked cutoff and second value live per voice: inside each filter's own per-voice state (`R4` at its case). Whether that state is updated for a voice on another type decides whether a module filter reads it there or the base computes it.
3. Registers: the stock cases call their routine as a compiled function, so the module routine's contract is the same (keep the compiler's preserved registers, `R15` saved by the caller); `R0` holds the comparison from `0x1c6c10` when the branch is taken.
4. The ColdFire list, names and parameter-code sites.
Expand Down
17 changes: 10 additions & 7 deletions scripts/build-elemod-packages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,18 @@ for (const machine of machines.filter(item => item.sdk?.platform === 'elemod'))
for (const target of sites.flatMap(site => 'target' in site ? [site.target] : (site.relocs ?? []).map(reloc => reloc.target))) if (!Object.hasOwn(module.symbols, target) && !module.imports.includes(target)) module.imports.push(target)
module.imports.sort()
if (build.sharc) {
// A Digitakt II machine module's sound-chip player, assembled from its source; the site composes it into section 7.
if (machine.id !== 'digitakt-ii') throw new Error('Only Digitakt II modules carry a sound-chip player: ' + document.id)
// A Digitakt II module's sound-chip code (machine players, filter routines), assembled from its source; the site
// composes it into section 7.
if (machine.id !== 'digitakt-ii') throw new Error('Only Digitakt II modules carry sound-chip code: ' + document.id)
const program = assembleSharc(await readFile(await resolveModuleFile(folder, build.sharc.source), 'utf8'))
const players = build.sharc.players.map(player => {
const entry = program.symbols.get(player.entry)
if (entry === undefined) throw new Error(document.id + ': no label ' + player.entry + ' in ' + build.sharc.source)
return { type: player.type, entry }
const entries = list => (list ?? []).map(item => {
const entry = program.symbols.get(item.entry)
if (entry === undefined) throw new Error(document.id + ': no label ' + item.entry + ' in ' + build.sharc.source)
return { type: item.type, entry }
})
module.build = { ...module.build, dt2_sharc: { version: 2, allocations: program.blocks.map(block => ({ address: block.address, data: Buffer.from(block.bytes).toString('base64'), code: block.code })), players } }
const players = entries(build.sharc.players), filters = entries(build.sharc.filters)
module.build = { ...module.build, dt2_sharc: { version: 2, allocations: program.blocks.map(block => ({ address: block.address, data: Buffer.from(block.bytes).toString('base64'), code: block.code })), players,
...(filters.length ? { filters } : {}), ...(build.sharc.cost === undefined ? {} : { cost: build.sharc.cost }) } }
}
parseElemod(module)
const plan = { schemaVersion: 1, machine: machine.id, id: document.id, version: document.version, release, module, sites, derive: build.derive,
Expand Down
7 changes: 7 additions & 0 deletions sdk/digitakt-ii/core-profile/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@
"entry": 4,
"room": 4,
"purpose": "Null-terminated pointers to struct dt2_machine records (mk2/machines.h): track machines added after the seven stock types, each with its own machine type 7-10 (claimed as machine:<type>, saved with kits), the stock type it stands for, its names and its five knob names on the stand-in's parameters. The base lists them in the machine menu, keeps them through kit load, shows their knob names while a page shows that machine and, when the module's package carries a build.sharc player, sends their voices to it on the sound chip through that type's registry slot; without one they play as the stock type they stand for."
},
{
"name": "core_filters",
"since": "1.1",
"entry": 4,
"room": 4,
"purpose": "Null-terminated pointers to struct dt2_filter records (mk2/filters.h): filter types added after the six stock ones, each with its own fixed type from 7 (claimed as filter-id digitakt-ii/N, saved with kits; numbers have no fixed end below 127, room limits how many are installed together), the stock type it stands for, its names and its three knob names (E-G) on the stand-in's parameters. The base lists them in the FLTR page's type list, shows their names and the stand-in's picture, keeps them through kit load (an unregistered type loads as the stock default, as on the official OS) and, when the module's package carries a build.sharc filter routine, calls it for their voices on the sound chip in one of four slots with the stand-in's per-voice state; without one they filter as the stock type they stand for. Proposal board index: tables/7, after core_fx (#2146)."
}
],
"exports": [
Expand Down
2 changes: 1 addition & 1 deletion sdk/machines/digitakt-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ By the core's documentation (emulator-tested, not hardware-tested), both data ar
The Digitakt II core does not start DTIM0 and exposes no audio-render hook yet ([proposal and emulator measurements](../../../docs/verification/2026-11-10-digitakt-ii-pre-send-render.md)). Audio is rendered by the separate SHARC DSP; these hooks are not sample-accurate.
The [guarded render probe](../../../docs/verification/2026-11-14-digitakt-ii-render-probe.md) records the local OS 1.17 build and dispatcher test.
**Effects wait for the base's effect slot.** An effect module (delay, reverb, drive) does not patch the render site: the [effect slot proposal](../../../docs/verification/2026-11-25-digitakt-ii-fx-slot.md) gives every effect, Sidechain Comp included, a slot in the base table `core_fx` with track inserts before the stock sends and one shared FX page in the Mixer. The owner approved its design on 26 November 2026; the base code follows.
**Filters wait for the base's filter types.** A filter module does not patch the per-voice filter on the sound chip: the [filter-type proposal](../../../docs/verification/2026-11-25-digitakt-ii-filter-types.md) lists module filters after the stock types on the FLTR page (base table `core_filters`), each standing in for a stock type's knobs and movement. The owner approved its design on 25 November 2026; the base code follows.
**Filters are the base's filter types.** A filter module never patches the per-voice filter on the sound chip: it registers one type in `core_filters`, listed after the six stock types (FUNC+SRC on the FLTR page), with its own names on knobs E-G over the rows of the stock type it stands for, and its routine runs in that type's slot with the stand-in's moving cutoff ([FILTERS.md](elekloader/modwerk/FILTERS.md), [proposal and emulator record](../../../docs/verification/2026-11-25-digitakt-ii-filter-types.md)). Machines, filters and effects share one sound-chip budget per block.

The proposed Mixer and frame interfaces are declared in [core-profile/interface.json](../../digitakt-ii/core-profile/interface.json).

Expand Down
Loading
Loading