Skip to content

Improvement: Digitakt II base: module filter types on the FLTR page (core_filters) - #2446

Draft
Claptom-music wants to merge 12 commits into
repeat98:base/digitakt-ii-nextfrom
Claptom-music:base/dt2-filter-code
Draft

Claptom-music wants to merge 12 commits into
repeat98:base/digitakt-ii-nextfrom
Claptom-music:base/dt2-filter-code

Conversation

@Claptom-music

@Claptom-music Claptom-music commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong or hard

Filter modules need their own filter types on each track's FLTR page, and several must sit side by side. The per-voice filter is a sound-chip voice site, so the base has to own it. The design was approved in the proposal (#2180, merged); this is the base code for it.

What this changes

Base code for core_filters on base/digitakt-ii-next, as the proposal (docs/verification/2026-11-25-digitakt-ii-filter-types.md) describes. The module author's contract is in sdk/machines/digitakt-ii/elekloader/modwerk/FILTERS.md.

  • ColdFire (filters.c, filters-entry.s, mk2/filters.h): table core_filters (room 4), and six guarded sites. They cover the filter descriptor lookup 0x400c89c6, the filter-type list 0x40052c98 (FUNC+SRC on the FLTR page), the name and short-name lookups 0x400da71e and 0x400da744, the kit-load check 0x400db492, and the FLTR page's picture switch 0x40074580. The parameter-code lookup the base already takes for machines (0x400da3a2) now reads the filter type for slots 35-37. An added type answers as the stock type it stands for, except for its names and its E-G knob names. A kit naming an unregistered type loads as type 0.
  • Sound chip (src/engine/elektron/dt2-sharc.ts):
    • planDt2FilterTable points the track filter-type lookup (0x1c26df) at a table in the base's L2 (0x200c4000-0x200c4600). The table answers every index from -128 to 255 (index 0 at 0x200c4200). It keeps the six stock words, read from the owner's OS by hash, and has 0 (no filter) for every unregistered number.
    • planDt2FilterDispatch turns the voice loop's "field 7 or more" branch (0x1c6c13) into an absolute jump to a base dispatcher (0x200c4640) with four slots (0x200c4600). Stock fields never reach base code.
    • A slot calls the module's routine exactly as the stand-in's stock case calls the stock routine: the stand-in's per-voice state in R4, the samples in R8/R12, CCALL. It then returns through the stock case tail.
  • Builder (dt2-render-build.ts): reads core_filters records and build.dt2_sharc filters: [{type, entry}]. Adds one sound-chip budget: cost (instructions per block over the stock work replaced), summed for machines, filters and effects against DT2_SHARC_BUDGET (60,000). A filter part must declare a cost above 0. Machine parts released before the budget are listed as uncounted.
  • Module build path (module-contract-v3.ts, build-elemod-packages.mjs): a module's build.json names its routine in sharc.filters ({type, entry label}), with each type 7-126 claimed as filter:<type>, and sharc.cost above 0. A filter-only part needs no players. The package build writes both into build.dt2_sharc.
  • Docs: FILTERS.md, the machine guide's line, interface.json's core_filters entry, a changelog entry, and the proposal's record of what was checked.
  • Development base: a test filter (type 7, standing for Lowpass 4) beside the test machine.

Review points (30 November)

  1. Claims: filter-id digitakt-ii/7 (Vowel) and digitakt-ii/8 (Notch/Peak) are on the board, and FILTERS.md says so.

  2. Build path: added (above). The contract refuses:

    • a routine without a cost, or with cost 0;
    • an unclaimed or out-of-range type;
    • a part with neither players nor filters.

    dt2SharcCost refuses cost 0 for a filter part too.

  3. After Digitakt II base: the effect slot (core_fx) and the FX page #2445 merges in: one I4 constant, one budget for effects plus machines and filters, and the table order in interface.json and base.json. I'll do these when I merge base/digitakt-ii-next in after Digitakt II base: the effect slot (core_fx) and the FX page #2445.

  4. The dispatcher's bound:

    • Yes, it could happen. The table is read with the track's word at 0x255990 as it is (M0 = DM(I1, M4), 0x1c26c5). Nothing bounds that index, on stock either. With the old 127-word table, a stored 0xff (255, or -1 sign-extended) would have read the base's slots or the effect range.
    • Now closed. The table answers -128 to 255, with 0 (no filter) everywhere except the six stock words and the registered types. No stray number can reach a slot.
    • Re-checked. The new layout passed the emulator again: the halving routine gives the same level (peak 0.0315) and runs at 0xbe8000.
    • d4: after 0x40074588 every case ends at 0x40074800, which restores d4 before rts. The later uses (0x40074670 on) are on another path and write d4 first. Nothing reads the stand-in type after the switch.
  5. Unit cases for the combined image are listed in the record. None has run yet:

    • the base with no filter module, against stock;
    • Morpha on type 9 after the parameter-lookup change;
    • two filter types in one kit, with the knob names switching;
    • an unknown type opened on the official OS;
    • a cycle count with a filter on every voice.
  6. Builder tests:

    • more than four routines;
    • module code over the filter range (table, slots, last word), and code just past it accepted;
    • the filter-only set, which gets only the filter parts and the module's code;
    • indices -128, -1, 127, 128 and 255 reading 0.

How I checked it

  • npm run check -- --base upstream/base/digitakt-ii-next on the new head: passed in 222 s (head 99ac88147): SDK checks 665 cases, module-doctor tests.
  • Builder and contract tests with the owner's OS (MODWERK_DT2_STOCK): src/engine/elekloader/dt2-render-build.test.ts (20), src/catalog/module-contract-v3.test.ts (15) and src/engine/elektron all pass, 189 tests in total.
  • Emulator (panel probe and coupled ColdFire + sound chip, OS 1.17):
    • The list shows TEST FILTER after EQUALIZER. The knob names and the picture follow the type.
    • The test filter with no routine runs field 3 (Lowpass 4), and its PCM is identical to Lowpass 4.
    • A halving routine gives -6.02 dB on track 1. On track 9 it runs for voices 16 and 17 only.
    • SAVE PROJECT / LOAD PROJECT keeps type 7 on the base. The official OS 1.17 loads a project saved with type 7 (its load routine read the stored 7) as type 0 and draws Multi-Mode, with no fault.
    • On 30 November, after the table moved: the same halving routine, image 8f54c4ea, gives the same level.
  • Unit: Digitakt II, OS 1.17, image 443ff13134c316e4e40df919cdc63b859b1a4af0b2d51396ac8de1c03b4fdf58 (development base 6273bc6b plus the halving routine for type 7, with the earlier 127-word table). Run by Claptom-music on 30 November 2026, who reported every step passed:
    • the list and the stock types unchanged;
    • half level without clicks;
    • track 9 only;
    • save and reload;
    • a busy pattern for a minute;
    • the saved project on the official OS with Multi-Mode.
  • Board: hook digitakt-ii/tables/6-7, and filter-id digitakt-ii/7 and /8.

Still open

  • Which words of each stand-in's per-voice state hold the cooked cutoff and resonance (FILTERS.md). The Vowel module will read them first.
  • A unit cycle count, to set the budget again.
  • Point 3 above, after Digitakt II base: the effect slot (core_fx) and the FX page #2445.
  • No release base yet: this is the development build's code. The binding and pin come once, on the combined build.

Guides

FILTERS.md described a build path the contract didn't accept. It now shows the build.json form. The guide said filters wait for the base's filter types; it now points filter modules to FILTERS.md.

🤖 Generated with Claude Code

Filter descriptor lookup, filter-type list, names, knob names on E-G, the parameter-code lookup for slots 35-37 and the kit-load check answer a registered added type as its stand-in. Development base adds a test filter (type 7, Multi-Mode). Emulator panel probe: listed after Equalizer, chosen through FUNC+SRC on the FLTR page, type byte 7, knobs TFRQ TRES TMOR, no fault.
planDt2FilterTable points the track filter-type lookup (0x1c26df) at a 127-word table: the six stock words read from the owner's OS by hash, each registered added type gets its stand-in's per-voice field, every other number none. The builder reads core_filters records and composes it; a set with filters and no machine changes only this site. Tests with the owner's OS: 15 pass.
So a coupled run tells it from the default type. Emulator (dev base 85ccfb78 composed with the filter table and machine parts, image ea693607): Test Filter chosen through the menu runs per-voice field 3 (Lowpass 4) on track 1, and PCM since ready is identical to choosing Lowpass 4 (82c37eb7).
…und chip

planDt2FilterDispatch takes the voice loop's 'field 7 or more' branch (0x1c6c13, now an absolute jump under the same condition) to a base dispatcher in L2 0x200c4300; fields 7-10 are four slots, each called as the stand-in's stock case calls its routine (its per-voice state in R4, the samples in R8/R12, R15 on the stack, CCALL), returning through the stock case tail. Packages name routines in build.dt2_sharc filters [{type, entry}]. Tests with the owner's OS: 17 pass. Emulator (dev base 85ccfb78 + a halving test routine for filter 7, image f3dev): track 1 on the test filter peaks at 0.0315 against 0.0630 on Lowpass 4 in the same run (-6.02 dB), routine called every block, no halt.
…ects

A package's sound-chip part declares its worst case per block (build.dt2_sharc cost); the builder sums every part against DT2_SHARC_BUDGET (60,000, the effect slot's cap) and refuses a set past it. A part with filter routines must declare its cost; machine parts released before the budget are listed as uncounted. Emulator, same day: the test filter on track 9 runs for voices 16 and 17 only; the official OS 1.17 loads a project saved with filter type 7 on track 1 (the load routine read stored 7) as the default type, no fault; the development base keeps type 7 through SAVE PROJECT and LOAD PROJECT.
The page's picture switch (0x40074580, types 0-5) answers an added type as the stock type it stands for. Panel probe (dev base 6273bc6b, 53 sites): the test filter's page draws Lowpass 4's box with TFRQ and TRES, no fault.
… and changelog

FILTERS.md gives a filter module's record and routine contract; the machine guide points filter modules to it; interface.json declares core_filters (board index tables/7 after core_fx, repeat98#2146); changelog entry. Engine tests: 46 files, 592 tests pass.
…/dt2-filter-types

# Conflicts:
#	sdk/machines/digitakt-ii/README.md
…er-id claims as machine-id until the board kind exists
@repeat98

Copy link
Copy Markdown
Owner

Thanks, this is careful work. With no filter module installed every new site falls through to stock, the numbers are fixed per module, and a kit naming a type nobody provides loads as Multi-Mode. A separate table is also the right shape: the filter runs per voice inside the voice, where an effect slot can't reach.

Plan for the release: #2204, #2477, this one and #2445 go into base/digitakt-ii-next, then one combined image and one unit round on that exact build. I'd merge #2445 first (core_fx as table 6, as interface.json already says), then this one merges base/digitakt-ii-next in. Before that:

  1. Claim the filter numbers. Improvement: Board: a filter-id claim kind #2447 is merged and live, so the filter-id kind works now. The machine-id digitakt-ii/filter-7 and filter-8 claims the description mentions aren't on the board. Please claim them as filter-id and update the claim line in FILTERS.md.
  2. The build path for a filter routine. FILTERS.md tells authors to put filters and cost in the sound-chip part of build.json, but module-contract-v3.ts accepts only source and players (types 7 to 10), and build-elemod-packages.mjs writes only players. So a filter module can't declare its routine yet, and a filter-only module with a routine is refused for having no players. Please add it here, or say plainly in FILTERS.md that it comes before the first filter module.
  3. After merging Digitakt II base: the effect slot (core_fx) and the FX page #2445 in:
    • both add const I4 = 0x14 to dt2-sharc.ts. git merge-tree merges that silently and the builder no longer compiles, so drop one;
    • one budget for the frame: here part.cost counts against DT2_SHARC_BUDGET, in Digitakt II base: the effect slot (core_fx) and the FX page #2445 fx.cost counts against DT2_ADDED_BUDGET, so a set could reach 60,000 for effects plus 60,000 for machines and filters. Please sum them into one. A filter with cost 0 is accepted today, which it probably shouldn't be;
    • interface.json (tables/7, after core_fx) and base.json (core_filters right after core_machines) should agree on the order.
  4. The sound-chip dispatcher's bound. The selector table has 127 words, and kit load keeps type 0xff. Can 0xff, or a word the signed compare reads as negative, reach the dispatcher? If so, it would run another slot's routine on a voice's state where stock skips the filter. A 256-word table or an unsigned compare with a lower bound closes it. We didn't check the stock path for this, so please confirm either way. Smaller, in the same file: filters-entry.s replaces d4, which the drawing function keeps, with the stand-in type; please check nothing after the switch reads it.
  5. Unit cases on the combined image, since the image you ran carried the test filter:
    • the base with no filter module installed, against stock;
    • a machine module (Morpha) on type 9 after the parameter-lookup change in machines-entry.s;
    • two filter types in one kit, with the knob names switching between them;
    • a kit that names a filter type the build doesn't have, opened on the official OS;
    • the cycle count with a filter on every voice.
  6. Builder tests for the new refusals: more than four routines, module code overlapping the base's filter range, and the filter-only path in dt2-render-build.ts.

Pull requests into base/digitakt-ii-next only get the description check in CI, so please paste the npm run check -- --base upstream/base/digitakt-ii-next result for the new head. Mark it ready once these are in.

…ype table, claims and tests

A module's build.json names its filter routine in sharc.filters with sharc.cost above 0 (a filter-only part needs no players), and the package build writes both into build.dt2_sharc. The sound chip's type table answers every index from -128 to 255, so no stray stored number reaches a filter slot; the slots and dispatcher move to 0x200c4600 and 0x200c4640. A filter part with cost 0 is refused. FILTERS.md names the filter-id claims 7 and 8. Builder tests cover more than four routines, code over the filter range and the filter-only set.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working through the review so quickly. I checked the new head (99ac881) against the 30 November points:

  • 1. Claims: settled. filter-id digitakt-ii/7 and /8 are on the board, and FILTERS.md names them.
  • 2. Build path: settled. build.sharc.filters with a claimed type from 7 to 126 and a cost above 0 now passes the contract, a filter-only part no longer needs players, and the package build writes both into build.dt2_sharc.
  • 4. Dispatcher bound: settled. The table now answers -128 to 255, with 0 for every unregistered index, so a stored 0xff or a negative word can no longer reach a slot. Thanks also for the d4 check.
  • 6. Builder tests: the new cases cover what was asked.

Two points still stand, as planned: 3 (one I4, one sound-chip budget and the table order) once #2445 is merged in, and 5, the unit cases on the combined image. When both are done, mark this ready.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants