Skip to content

Fix: Rytm base: the lean engine clears an idle sample voice's output every block - #2515

Merged
repeat98 merged 3 commits into
repeat98:base/analog-rytm-mkii-nextfrom
npp1993:claude/rytm-lean-voice-clear
Dec 2, 2026
Merged

repeat98 merged 3 commits into
repeat98:base/analog-rytm-mkii-nextfrom
npp1993:claude/rytm-lean-voice-clear

Conversation

@npp1993

@npp1993 npp1993 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

What this fixes. With the Rytm base's lean engine, a module that shapes a sample voice's audio in place could hear its own last block again after the sample ended. Sample Layer's TRANSIENT delay (SHF, PUNCH) or band then looped forever instead of dying away. Found while reviewing Sample Layer (#2253). The base now clears an idle sample voice's output every audio block, as the stock OS does, so any module may write that buffer.

What it means for musicians. Nothing changes with today's library modules: none writes that buffer. Sample Layer's tails end as designed once it is in the library.

Cost. About 240 instructions a block with all 8 sample voices idle (about 0.16 % of the audio block); the lean engine keeps 98 % of its sample-voice saving. Idle and playing output is identical to stock's sample engine, sample for sample (emulator, zero-time twin).

On a unit: yes, on the maintainer's MKII, inside the current combo set (RC47's 20 modules plus Sample Layer from #2253), RAM-booted, 1 Dec 2026. On the old base Sample Layer's TRANSIENT tail (SHF at its top, DEC INF) still sounded at -12 dBFS 2.5 s after the hit; on the fixed base it was silent (-83.9 dBFS, the noise floor), like the SHF-0 control (-83.5).

Who acts: a maintainer merges this into base/analog-rytm-mkii-next once green; it ships with the next Rytm base release.

Tested on a unit: base a0b41d24 (this tree's voices variant, built as a development base for the RAM boot; the release packages b37be733 / dacd67fe / 8b2663e1 are the same sources without the dev parts and did not run on a unit), MKII, RC47's set + Sample Layer: slv-tail, abd-voice, sy-voices pass; the old base 89a81ff5 fails slv-tail.

Guides: the Rytm base's lean-engine section did not say which stock buffers the lean engine no longer rewrites every block; added there (sdk/machines/analog-rytm-mkii/elekloader/README.md).

Edge cases

Case Why this change makes it a risk How run Result
A module writes an idle voice's sample stream in place (Sample Layer TRANSIENT, SHF at its top, DEC INF) the bug itself unit, rig case slv-tail on LVC2 (fixed) and LVB2 (old) pass (old base fails: tail -12.2 dBFS)
Idle voices with no module writing them the zeroing now runs every block rytm-emu zero-time twin against stock's sample engine pass: identical DAC words, 16 channels
Samples starting, looping and stopping on several voices (voices going idle and active) a voice moves between the skip and stock's loop rytm-emu zero-time scenario (BD, SD, BT; notes, PLAY, STOP) pass: identical to stock
Analog BD and the SY machines, which write the digital stream beside it the voice mix reads both streams unit, abd-voice and sy-voices on LVC2 pass
A skipped voice with ACC2/ACC3 not clear that path zeroes the decimation output and runs stock's loop independent code review not run: that path's code is unchanged and no run produced nonzero accumulators there
CPU load with all 8 voices idle 32 stores a voice a block added rytm-emu instruction counts (+240 a block) pass; unit load not measured
Cause, change and tests

Cause. common builds perf-sample-voices.s with LE_TRIM=1. For a voice with nothing to play, le_dsg skips stock's gain loop and writes the voice's 32 output longs (0x800067f8 + 128 x voice) itself, but skipped that write while a per-voice bit (dsz_out) said the buffer still held zeros from an earlier block. That assumed nothing else writes the buffer. It is the sample stream stock's voice mixer reads, and Sample Layer shapes it in place from a gate on the mixer's call (0x4012129a): after a voice went idle, the last block Sample Layer wrote stayed in the buffer and was fed back into its delay every block, at unity with DEC INF.

Change. le_dsg zeroes the 32 longs in every block it skips the gain loop (4 passes of 8 clr.l); dsz_out is gone. The LE_VERIFY build runs stock's loop there as before. The lean-engine section of elekloader/README.md now says which buffers the lean engine zeroes once and then leaves (the delay's return while it rests, the USB input streams while nothing streams), so a module does not shape those in place. Release identities: plain 8b2663e1, voices dacd67fe, send-bus b37be733 (sizes unchanged); packages, import record, catalog and registry follow.

Library modules that write the sample stream: none (searched every Rytm module and draft for the buffer). Analog BD and the digital voices write the digital stream (0x80006bf8), Improved SMPL changes a fetch's source (a real transfer, which the trim already treats as unknown).

Tests.

  • Build: the unchanged tree rebuilds base-binding.json's identities; the fixed tree records the new ones.
  • rytm-emu, a twin module on Sample Layer's site that writes a marker into idle voice 7's stream every 1000 blocks and counts blocks in which the stream arrives stale: old base 25,288 of 25,288 blocks stale (and the marker kept playing on voice 7's DAC channel), fixed base 0.
  • rytm-emu, zero-time twin (the audio interrupt takes no emulated time, so both runs see the same clock), a scenario with samples on BD, SD and BT, notes, PLAY and STOP, 163,287 blocks: fixed base and the same image with the five sample-voice sites put back to stock give identical DAC words on all 16 channels (119,995 frames, 48,030 with sound). Old base: voice 7's channel differs in 71,965 frames (the stale marker). Instructions a block: old 35,217, fixed 35,458, stock sample engine 47,055.
  • Independent code review of the change: no defect; one stale comment fixed.
  • Unit, Analog Rytm MKII, RAM boot, no flash written; images RC47's set + Sample Layer 0.1.0-experimental, layout 0x901016c3, scratch project with a sample in slot 1. Rig case slv-tail: BD with the amp held open, the analog body off, a one-shot sample; a control hit on TRANSIENT with SHF 0, then a hit with SHF at its top and DEC INF; each tail measured 2.5 s after its note.
    • LVB2 (old base, dev voices 89a81ff5): FAIL, delayed tail -12.24 dBFS against the control's -83.57 (hit level and SHF's onset delay passed).
    • LVC2 (fixed base, dev voices a0b41d24): PASS, tail -83.9 dBFS, control -83.5; the combo checks abd-voice (Analog BD sounds) and sy-voices pass on the same image.
  • npm run check: passed.

What the guides lacked. The lean-engine section did not say that some stock buffers are no longer rewritten every block; fixed there (sdk/machines/analog-rytm-mkii/elekloader/README.md).

🤖 Generated with Claude Code

npp1993 and others added 3 commits December 1, 2026 20:01
… block, as stock does

The sample voices' trim (LE_TRIM) left a skipped voice's 32 output longs (0x800067f8 + 128 x voice) alone while a
bit a voice (dsz_out) said they still held zeros from an earlier block. That assumed nothing else writes the buffer,
but it is the sample stream stock's voice mixer reads, and a module may shape it in place first: Sample Layer
(repeat98#2253) does, from a gate on the mixer's call 0x4012129a, so after a voice went idle its TRANSIENT
delay tail or band ring stayed in the buffer and was read back every block. le_dsg now zeroes the 32 longs in every
block it skips stock's gain loop, the bytes stock's loop writes; dsz_out is gone (le_dsk_total [7] unused).

rytm-emu, a twin module on Sample Layer's site marking idle voice 7 every 1000 blocks: old base 137,812 of 137,812
blocks after the first mark found the stream stale (and its DAC channel kept the marker), fixed base 0.
Release identities plain 8b2663e1, voices dacd67fe, send-bus b37be733 (sizes unchanged); packages, record and
registry follow. Review: no defect; the README's lean-engine section now says which buffers a module may not
shape in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…8b2663e1, voices dacd67fe, send-bus b37be733)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@repeat98 repeat98 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed on 35907b8: an idle sample voice's 32 output longs are zeroed every block again and dsz_out is gone; all three variants regenerated. Thanks, Nathaniel.

@repeat98
repeat98 merged commit 0479d83 into repeat98:base/analog-rytm-mkii-next Dec 2, 2026
2 checks passed
npp1993 added a commit to npp1993/modwerk that referenced this pull request Dec 2, 2026
repeat98#2515 (lean engine: an idle voice's sample stream zeroed every block) changed perf-sample-voices.s, so the release
bases with the loader are rebuilt from the merged sources: plain 6496a83a, voices a0efb9e9, send-bus a981a3b0 (sizes
unchanged). base-next's loaderless 8b2663e1, dacd67fe and b37be733 are replaced; its README note on stock's audio
buffers is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chevyone added a commit to chevyone/modwerk that referenced this pull request Dec 2, 2026
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