From feac9ae9ba58d3393c7c8c774fdbc88998fb03e9 Mon Sep 17 00:00:00 2001 From: Chevy One <316992723+chevyone@users.noreply.github.com> Date: Tue, 1 Dec 2026 16:02:57 +0000 Subject: [PATCH] Docs: Rytm guide, inline-asm struct operands and the cost of a table voice Co-Authored-By: Claude Opus 5.5 --- sdk/machines/analog-rytm-mkii/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/machines/analog-rytm-mkii/README.md b/sdk/machines/analog-rytm-mkii/README.md index a45a928bd0..a2f4e88487 100644 --- a/sdk/machines/analog-rytm-mkii/README.md +++ b/sdk/machines/analog-rytm-mkii/README.md @@ -61,7 +61,7 @@ A machine that makes its sound in software (as stock's CP CLASSIC does) adds one - **The stream:** LEV squared into the voice's digital stream (0x80006bf8 + 128 x voice), which stock's mixer sends through the voice's filter, AMP and OVR. `ev_render_out` clears it after the mixer, so a voice another machine takes over plays no stale block. A hit ends after 64 blocks below -102 dB, measured before LEV. - **The type:** up to eight variants of a machine in a 3-bit field of the sound. A tap of the record's encoder on the machine's SYNTH page steps it and that knob's label follows; `ev_sound_applied` keeps each track's type exact through kit and sound loads and a trig's sound lock. - **The EMAC:** `render` runs in fractional mode with all four accumulators clear; the base keeps stock's MACSR and all four accumulators around it, as stock's mixers rely on them. [`include/modwerk/dsp.h`](include/modwerk/dsp.h) has the multiply, sum and table helpers, and a host model for testing the same C off the unit. -- **Cost on the unit:** the core runs at twice DTIM0. A `mac.l` whose accumulator is read by the next instruction waits 3 cycles (5 for the pair, 2 with three independent instructions between, measured on a MKII), so a voice's hot loops spread independent products over ACC0-ACC3; GCC's `qmul` pairs cannot. Stock's audio work evicts a voice's code and tables between blocks, so every block pays their cache refill (about a third of a bass drum voice's render, measured, before it was trimmed): keep per-block code and tables small, and pass settings in place rather than copying records. rytm-emu counts instructions only; its ticks match the unit's warm cost, not the stalls or refills. A routine in assembly saves every register it uses of d2-d7 and a2-a6 (the caller's under GCC's convention); one that did not corrupted its caller without a fault. Budget against what is left: on a MKII with the base (send bus, no send effect) the whole audio block, ev_render_in to ev_render_out, takes about two thirds of its 88,000 ticks with nothing playing and three quarters at its dearest, so digital voices hitting together share about a quarter of the block. +- **Cost on the unit:** the core runs at twice DTIM0. A `mac.l` whose accumulator is read by the next instruction waits 3 cycles (5 for the pair, 2 with three independent instructions between, measured on a MKII), so a voice's hot loops spread independent products over ACC0-ACC3; GCC's `qmul` pairs cannot. Stock's audio work evicts a voice's code and tables between blocks, so every block pays their cache refill (about a third of a bass drum voice's render, measured, before it was trimmed): keep per-block code and tables small, and pass settings in place rather than copying records. rytm-emu counts instructions only; its ticks match the unit's warm cost, not the stalls or refills. A routine in assembly saves every register it uses of d2-d7 and a2-a6 (the caller's under GCC's convention); one that did not corrupted its caller without a fault. In inline assembly, take a struct's address from an `"r"(&s)` operand, never by moving its `"+m"(s)` operand into an address register: that loads the struct's first word, and the voice then wrote through it, which hung a unit at the first note while the host tests (C fallback) passed; rytm-emu stopped on the same image with `FAULT vector 4`, so run an image with new assembly there first (HH ALLOY, 28 November 2026). A voice played from a short sample table cost a quarter of one synthesised per sample (HH ALLOY: 2.3 % against 8.8 % of a block, one voice on a MKII). Budget against what is left: on a MKII with the base (send bus, no send effect) the whole audio block, ev_render_in to ev_render_out, takes about two thirds of its 88,000 ticks with nothing playing and three quarters at its dearest, so digital voices hitting together share about a quarter of the block. - **The meter:** `mw_voice_meter` keeps each slot's blocks, DTIM0 ticks (88,000 a block) and dearest block. The base's voices are in the voices and send-bus variants and take about 4 KB of `.run`. A module that adds a voice machine lists its id in [`voice-modules.json`](voice-modules.json) (`npm run modules:check` asks for it), so the site builds its sets on voices, which has no send bus, or on send-bus when the set also holds a send effect. Such a module uses none of the send bus's code (`mw_send_*`, `mw_fx_clock`, `mw_fx_step`, `mw_fx_rate`, `mw_fx_onepole`, `mw_fx_tempo`): `modules:check` refuses it, since it would not link on voices.