From e5d438badca46c09947bc17bd1fdf60c6742c2ed Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Thu, 3 Dec 2026 22:05:54 -0600 Subject: [PATCH 01/16] Cassettebox 0.1.0-experimental (draft): an '80s cassette effect for FX1 or FX2 The track goes onto a short tape (a 1,024-word ring on r5, as Mini Verb addresses its lines) and plays back through a moving head: drift and flutter bend the speed, the tape saturates (a cubic), playback rolls off the top and lifts a head bump, hiss and crackle ride on it, dropouts and glitches come and go. DECK picks STUDIO, HOME or POCKET; WIDE parts the channels; TONE darkens; AGE wears the tape as it plays. The dry is read at the tape's centre (256 samples), so MIX never combs. verify.py bit-exact against reference.py in dsp_host (every deck, every knob, a 12 s wear, splits, garbage state, two seeds, an FX1-sized slot); test_reference.py 15/15. Worst 270.6 executed instructions a sample, 0.86x SPRING REV. Not yet run on a unit. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/LICENSE | 30 + sdk/drafts/cassettebox/README.md | 66 ++ sdk/drafts/cassettebox/TESTING.md | 23 + sdk/drafts/cassettebox/engine.asm | 879 ++++++++++++++++++ .../cassettebox/evidence/performance.json | 34 + sdk/drafts/cassettebox/manifest.py | 86 ++ sdk/drafts/cassettebox/octamod.module.json | 178 ++++ sdk/drafts/cassettebox/perf.py | 113 +++ .../cassettebox/qualification.example.json | 84 ++ sdk/drafts/cassettebox/reference.py | 286 ++++++ .../cassettebox/resource-impact.example.json | 21 + sdk/drafts/cassettebox/test_reference.py | 164 ++++ sdk/drafts/cassettebox/verify.py | 151 +++ 13 files changed, 2115 insertions(+) create mode 100644 sdk/drafts/cassettebox/LICENSE create mode 100644 sdk/drafts/cassettebox/README.md create mode 100644 sdk/drafts/cassettebox/TESTING.md create mode 100644 sdk/drafts/cassettebox/engine.asm create mode 100644 sdk/drafts/cassettebox/evidence/performance.json create mode 100644 sdk/drafts/cassettebox/manifest.py create mode 100644 sdk/drafts/cassettebox/octamod.module.json create mode 100644 sdk/drafts/cassettebox/perf.py create mode 100644 sdk/drafts/cassettebox/qualification.example.json create mode 100644 sdk/drafts/cassettebox/reference.py create mode 100644 sdk/drafts/cassettebox/resource-impact.example.json create mode 100644 sdk/drafts/cassettebox/test_reference.py create mode 100644 sdk/drafts/cassettebox/verify.py diff --git a/sdk/drafts/cassettebox/LICENSE b/sdk/drafts/cassettebox/LICENSE new file mode 100644 index 0000000000..250cae34a6 --- /dev/null +++ b/sdk/drafts/cassettebox/LICENSE @@ -0,0 +1,30 @@ +MIT License + +Copyright (c) 2026 jrs1717 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- + +This licence covers this module's own source code and documentation only. It +does not extend to any Elektron Music Machines firmware, which is not +distributed here and remains the property of its copyright holder. Nothing in +this module is endorsed by, supported by, or affiliated with Elektron. +Octatrack and Elektron are trademarks of Elektron Music Machines MAV AB, used +only to identify the hardware this module targets. diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md new file mode 100644 index 0000000000..987d8a99be --- /dev/null +++ b/sdk/drafts/cassettebox/README.md @@ -0,0 +1,66 @@ +# Cassettebox + +Version 0.1.0-experimental · by @jrs1717 · a draft: bit for bit against its model in `dsp_host`, not yet run on a unit. + +## Overview + +Cassettebox is an '80s cassette deck for an audio track's FX1 or FX2 slot. It puts the track on a short tape and plays it back through a moving head: +- **The speed wanders:** DRFT sways and wanders slowly, FLUT adds the fast shimmering wobble. +- **The tape colours it:** DRIV saturates it, and the playback rolls off the top and lifts a bump in the lows. +- **The tape is imperfect:** HISS and DUST (crackle) ride on it, GAPS brings dropouts, and GLCH brings speed hiccups and lost head contact. + +DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; or POCKET, a pocket recorder. WIDE parts the left and right channels, and TONE darkens the top. AGE wears the tape while it plays, as a loop recorded over again and again: the top fades, the hiss and crackle grow, dropouts come more often and the speed grows less steady. MIX blends the tape with the dry track. + +## Controls + +| Page | Knob | Name | Range | Default | What it does | +|---|---|---|---|---|---| +| Main | A | DRFT | 0-127 | 32 | Drift: the tape speed's slow sway and wander. 0 is steady. | +| Main | B | FLUT | 0-127 | 24 | Flutter: the fast shimmering wobble. | +| Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder). | +| Main | D | HISS | 0-127 | 24 | Tape hiss, shaped by the deck. | +| Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. | +| Main | F | MIX | 0-127 | 127 | Dry/tape blend. 127 is the tape alone, 0 the dry track. | +| Setup | A | DECK | STUDIO, HOME, POCKET | HOME | The machine: its tone, head bump, saturation, hiss and how steady it runs. STUDIO is clean and steady, HOME duller with more hiss and a little warble, POCKET narrow, hissy, fluttery and crunchy. | +| Setup | B | WIDE | 0-127 | 32 | Stereo: left and right drift and flutter apart, and the right head sits slightly misaligned. | +| Setup | C | DUST | 0-127 | 0 | Crackle and clicks. | +| Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed hiccup or a moment of lost head contact. | +| Setup | E | TONE | 0-127 | 0 | Darkens the top end, as worn heads or a cheap copy do. 0 is the deck's own. | +| Setup | F | AGE | 0-127 | 0 | Wear over time. 0 keeps the tape fresh; higher wears it faster, about 95 s to worn out at 127 and about 3 minutes at 64. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | + +## Usage + +Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to CASSETTEBOX at the end of the list and press YES. Press FX1 for the main page (DRFT, FLUT, DRIV, HISS, GAPS, MIX); hold FUNC and press FX1 for the setup page (DECK, WIDE, DUST, GLCH, TONE, AGE). + +## Quick tutorial + +1. Put Cassettebox on FX1 of a track playing a pad, a drum loop or a whole mix. At the defaults it is a HOME deck with a little warble and hiss. +2. Raise DRFT and FLUT for a seasick warble, and DRIV to push the tape into saturation. +3. Hold FUNC and press FX1, and try DECK on STUDIO and POCKET. +4. Raise GAPS, DUST and GLCH for a worn, dropout-prone tape. +5. Turn AGE up and let the pattern play: over a minute or two the tape wears, darker, noisier and less steady. + +## Compatibility and limitations + +- FX1 or FX2, any audio track. It uses 1,024 words of its slot's buffer. +- The tape sits 5.8 ms (256 samples) behind the track, so the speed can sway both ways. The dry signal is read at the same delay, so MIX blends without combing, and MIX 0 is the dry track 5.8 ms late. +- With HISS and DUST at 0, silence in gives exact silence out. With them up, the tape hisses and crackles when the track is quiet, as real tape does. +- Wear isn't saved: the tape starts fresh when the effect is picked or the Part reloads. +- It prefers effect id 10, as Fuzzbox, Glitchbox, Loopbox, Grainbox and Midiverb do. Over USB the base gives each its own id; in a card set only one of them fits. + +## Tests and measurements + +See [TESTING.md](TESTING.md). + +## Authorship and licences + +Original code by @jrs1717 under the MIT licence in LICENSE. Inspired by cassette tape and tape effects in general, with no product's code, tables or names. + +## Screens and audio + +None yet. + +## Develop + +- Hear it: `npm run module:dev -- cassettebox --cycles 240 --cycles-kind executed --state 88 --buffer 1024 --slots both`. +- Check it: `npm run module:doctor -- --draft cassettebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`, and `python3 -B test_reference.py` tests the model. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md new file mode 100644 index 0000000000..50669456b5 --- /dev/null +++ b/sdk/drafts/cassettebox/TESTING.md @@ -0,0 +1,23 @@ +# Cassettebox testing + +Record what you ran, on which build and which unit, and what you saw. "Not tested" is a valid answer; never write a result you did not observe, and keep emulator runs apart from hardware ones. + +## In dsp_host (not hardware evidence) + +`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and an FX1-sized slot. MIX 0 is the track exactly, 256 samples late. With HISS and DUST at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 15/15. + +## On the unit + +Not tested. + +## Stock flows + +Not tested. List the stock flows you compared with and without the module (docs/module-guides/README.md, Leave stock flows alone). + +## Sound quality + +Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (docs/module-guides/effects.md, Sound quality). + +## Performance + +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 219 words; measured unsplit 235.9 to 236.4, worst 270.6 (the dearest POCKET setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1081.6 and 1011.6, 0 clobbers, 0 stray writes). 0.86x SPRING REV (314.19). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm new file mode 100644 index 0000000000..c15bf823c0 --- /dev/null +++ b/sdk/drafts/cassettebox/engine.asm @@ -0,0 +1,879 @@ +; CASSETTEBOX -- an original '80s cassette effect for FX1 or FX2 of any track. +; Copyright (c) 2026 jrs1717, MIT (LICENSE). +; +; The track goes onto a short tape, a ring of 1024 Y words at the slot's +; base (every FX1 base is 1024-aligned; FX2 bases are 16K-aligned), left at +0 +; and right at +512, one pointer r5 (m5 = $3ff) stepping once a sample and +; every read and write at (r5+n5), as Mini Verb and E-Verb address theirs. The +; head reads d behind the writer (Q11.12), between two samples: d walks to a +; target each call, D0 (256) plus a slow sine drift, a wandering random, +; flutter and a decaying hiccup (WIDE parts the right channel's phases, its +; wander and its azimuth). The dry is read 256 behind, so MIX never combs. +; Each channel: the drive (x 4) and a cubic a - a^3/3, hiss on the tape +; (a 24-bit LCG: its low word left, its high word right), playback's top (a +; one-pole low-pass, DECK x TONE x wear x a dropout's dip), a head bump (110 Hz +; one-pole, DECK's level), dropouts' gain and crackle, then MIX. +; DECK: STUDIO, HOME, POCKET (drift, flutter, drive, hiss, top, bump). +; AGE: 0 keeps the tape fresh; above it wears AGE << 6 a call (48-bit), full in +; about 95 s at 127; wear lifts the drive, darkens the top and multiplies the +; drift, flutter, hiss, dropouts, glitches and crackle. +; +; Knobs (value<<16): page 1 DRFT r6+0, FLUT r6+1, DRIV r6+2, HISS r6+3, GAPS +; r6+4, MIX r6+5; page 2 DECK slot 6 (r6+$c bits 16-23, 0-2), WIDE slot 7 +; (r6+$c 8-15), DUST slot 8 (r6+$d 16-23), GLCH slot 9 (r6+$d 8-15), TONE slot +; 10 (r6+$e 16-23), AGE slot 11 (r6+$e 8-15). +; +; State (X, offsets from r7; init clears $00..$5f): +; $00 the ring's base (Y) $02 the pointer r5 $03 the hiss LCG (left's noise) $04 wear (Q23) +; $05 LFSR $06/$07 each head's d (Q11.12) $08/$09 its step a sample $0a drift's phase $0b flutter's +; $0c/$0d each channel's wander $0e/$0f playback's low-pass states $10/$11 the bump's states +; $12/$13 the drive and its step $14/$15 the dropout gain and its step $16/$17 MIX and its step +; $18 the click $1a the top's coefficient $1b the bump's level $1c the hiss level +; $1d a dropout's frames left $1e its gain $1f the hiccup (Q11.12) +; $21-$2c DRFT FLUT DRIV HISS GAPS MIX DECK WIDE DUST GLCH TONE AGE $2d wear's low word $2e seeded +; $30/$31 drift's and flutter's swings $32-$3a nine random words $3b right's noise +; $3c the dry (scratch) $3d WIDE's phase offset $3e right's wander +; $40-$57 DECK's tables, three words each: drift, flutter, their rates, drive, hiss, top, bump +; Nothing above $57 is touched. Every product is the signed mpy/mac x0,y1 +; form. Labels are cb and two characters, so none is another's prefix. +; CYCLES_FORWARD_BRANCHES +init: + clr a + move r7,r5 + move #>$ffffff,m5 + do #$60,>cbi0 + move a,x:(r5)+ +cbi0: + nop + move x:>$213,r4 + move #>$ffffff,m4 + nop + move x:(r4),x0 + move x0,x:(r7+$00) + move x0,x:(r7+$02) + move x0,r3 + move #>$ffffff,m3 + do #1024,>cbi1 + move a,y:(r3)+ +cbi1: + nop + move #>$5a3c1f,x0 + move x0,x:(r7+$03) + move #>$2b1d5f,x0 + move x0,x:(r7+$05) + move #>$100000,x0 + move x0,x:(r7+$06) + move x0,x:(r7+$07) + move #>$7fffff,x0 + move x0,x:(r7+$14) + move x0,x:(r7+$1e) + move #>$010000,x0 + move x0,x:(r7+$40) + move #>$020000,x0 + move x0,x:(r7+$41) + move #>$030000,x0 + move x0,x:(r7+$42) + move #>$003000,x0 + move x0,x:(r7+$43) + move #>$006000,x0 + move x0,x:(r7+$44) + move #>$00c000,x0 + move x0,x:(r7+$45) + move #>$00068a,x0 + move x0,x:(r7+$46) + move #>$000a1b,x0 + move x0,x:(r7+$47) + move #>$000f75,x0 + move x0,x:(r7+$48) + move #>$006aff,x0 + move x0,x:(r7+$49) + move #>$005338,x0 + move x0,x:(r7+$4a) + move #>$0082c6,x0 + move x0,x:(r7+$4b) + move #>$200000,x0 + move x0,x:(r7+$4c) + move #>$2a0000,x0 + move x0,x:(r7+$4d) + move #>$3a0000,x0 + move x0,x:(r7+$4e) + move #>$0033ef,x0 + move x0,x:(r7+$4f) + move #>$00925f,x0 + move x0,x:(r7+$50) + move #>$019c86,x0 + move x0,x:(r7+$51) + move #>$70e5a3,x0 + move x0,x:(r7+$52) + move #>$59dee0,x0 + move x0,x:(r7+$53) + move #>$39a3b8,x0 + move x0,x:(r7+$54) + move #>$2ccccd,x0 + move x0,x:(r7+$55) + move #>$200000,x0 + move x0,x:(r7+$56) + move #>$000000,x0 + move x0,x:(r7+$57) + rts + +proc: + move #>$ffffff,m1 + move r7,r1 +; ---- the knobs + move x:(r6+$0),a + and #>$7f0000,a + move a1,x:(r7+$21) + move x:(r6+$1),a + and #>$7f0000,a + move a1,x:(r7+$22) + move x:(r6+$2),a + and #>$7f0000,a + move a1,x:(r7+$23) + move x:(r6+$3),a + and #>$7f0000,a + move a1,x:(r7+$24) + move x:(r6+$4),a + and #>$7f0000,a + move a1,x:(r7+$25) + move x:(r6+$5),a + and #>$7f0000,a + move #>$7f0000,x0 + cmp x0,a + move #>$7fffff,x0 + tge x0,a + move a1,x:(r7+$26) + move x:(r6+$c),a + and #>$7f0000,a + asr #16,a,a + move #>$2,x0 + cmp x0,a + tgt x0,a + move a1,x:(r7+$27) + move x:(r6+$c),a + and #>$00ff00,a + asl #8,a,a + move a1,x:(r7+$28) + move x:(r6+$d),a + and #>$7f0000,a + move a1,x:(r7+$29) + move x:(r6+$d),a + and #>$00ff00,a + asl #8,a,a + move a1,x:(r7+$2a) + move x:(r6+$e),a + and #>$7f0000,a + move a1,x:(r7+$2b) + move x:(r6+$e),a + and #>$00ff00,a + asl #8,a,a + move a1,x:(r7+$2c) +; ---- wear: AGE 0 keeps the tape fresh; above, AGE << 6 a call into wear's 48 bits, at most whole + move x:(r7+$2c),b + tst b + bne cbw1 + clr a + move a,x:(r7+$04) + move a,x:(r7+$2d) + bra cbw2 +cbw1: + move x:(r7+$04),a + move x:(r7+$2d),a0 + asr #18,b,b + add b,a + move #>$7fffff,b + cmp b,a + tgt b,a + move a1,x:(r7+$04) + move a0,x:(r7+$2d) +cbw2: +; ---- the deck's figures: the drive, the hiss, the top, the bump, the swings + move x:(r7+$27),a + add #>$4c,a + move a1,n1 + nop + move x:(r1+n1),x0 + move x0,b + move x:(r7+$23),x0 + move #>$3c0000,y1 + mac x0,y1,b + move x:(r7+$04),x0 + move #>$140000,y1 + mac x0,y1,b + move b,x:(r7+$3f) + move x:(r7+$27),a + add #>$4f,a + move a1,n1 + nop + move x:(r1+n1),y1 + move x:(r7+$24),x0 + mpy x0,y1,a + move a,x0 + move x:(r7+$04),y1 + move x0,a + mpy x0,y1,b + add b,a + add b,a + add b,a + move a,x0 + move x0,x:(r7+$1c) + move #>$7fffff,a + move x:(r7+$2b),x0 + move #>$600000,y1 + mpy x0,y1,b + sub b,a + move a,x:(r7+$3c) + move #>$7fffff,a + move x:(r7+$04),x0 + move #>$4ccccd,y1 + mpy x0,y1,b + sub b,a + move a,x:(r7+$3d) + move x:(r7+$27),a + add #>$52,a + move a1,n1 + nop + move x:(r1+n1),x0 + move x:(r7+$3c),y1 + mpy x0,y1,a + move a,x0 + move x:(r7+$3d),y1 + mpy x0,y1,a + move a,x0 + move x:(r7+$14),y1 + mpy x0,y1,a + move a,x:(r7+$1a) + move x:(r7+$27),a + add #>$55,a + move a1,n1 + nop + move x:(r1+n1),x0 + move x0,x:(r7+$1b) + move x:(r7+$27),a + add #>$40,a + move a1,n1 + nop + move x:(r1+n1),y1 + move x:(r7+$21),x0 + mpy x0,y1,a + move a,x0 + move x:(r7+$04),y1 + move x0,a + mpy x0,y1,b + add b,a + move a,x0 + move x0,x:(r7+$30) + move x:(r7+$27),a + add #>$43,a + move a1,n1 + nop + move x:(r1+n1),y1 + move x:(r7+$22),x0 + mpy x0,y1,a + move a,x0 + move x:(r7+$04),y1 + move x0,a + mpy x0,y1,b + add b,a + move a,x0 + move x0,x:(r7+$31) +; ---- nine random words, always in this order: wander L and R, a dropout's test, length and depth, a click's test and size, a glitch's test and kind + bsr cbrn + move x0,x:(r7+$32) + bsr cbrn + move x0,x:(r7+$33) + bsr cbrn + move x0,x:(r7+$34) + bsr cbrn + move x0,x:(r7+$35) + bsr cbrn + move x0,x:(r7+$36) + bsr cbrn + move x0,x:(r7+$37) + bsr cbrn + move x0,x:(r7+$38) + bsr cbrn + move x0,x:(r7+$39) + bsr cbrn + move x0,x:(r7+$3a) +; ---- drift's and flutter's phases; each channel's wander a 32nd of the way to a new random word + move x:(r7+$27),a + add #>$46,a + move a1,n1 + nop + move x:(r1+n1),x0 + move x:(r7+$0a),a + add x0,a + and #>$7fffff,a + move a1,x:(r7+$0a) + move x:(r7+$27),a + add #>$49,a + move a1,n1 + nop + move x:(r1+n1),x0 + move x:(r7+$0b),a + add x0,a + and #>$7fffff,a + move a1,x:(r7+$0b) + move x:(r7+$32),a + sub #>$400000,a + asl #1,a,a + move a,x0 + move x0,a + move x:(r7+$0c),x0 + sub x0,a + asr #5,a,a + add x0,a + move a1,x:(r7+$0c) + move x:(r7+$33),a + sub #>$400000,a + asl #1,a,a + move a,x0 + move x0,a + move x:(r7+$0d),x0 + sub x0,a + asr #5,a,a + add x0,a + move a1,x:(r7+$0d) +; WIDE: the right channel's phase offset, its wander between left's and its own, the hiccup settling + move x:(r7+$28),x0 + move #>$200000,y1 + mpy x0,y1,a + move a1,x:(r7+$3d) + move x:(r7+$0d),a + move x:(r7+$0c),x1 + sub x1,a + move a,x0 + move x:(r7+$28),y1 + mpy x0,y1,a + add x1,a + move a,x:(r7+$3e) + move x:(r7+$1f),x0 + move #>$6ccccd,y1 + mpy x0,y1,a + move a,x:(r7+$1f) +; ---- left's head target, clamped, and its step a sample (a 16th of the way) + move x:(r7+$0a),a + bsr cbsn + move x:(r7+$30),y1 + mpy x0,y1,b + move x:(r7+$30),a + asr #1,a,a + move a,y1 + move x:(r7+$0c),x0 + mac x0,y1,b + move x:(r7+$0b),a + bsr cbtr + move x:(r7+$31),y1 + mac x0,y1,b + move x:(r7+$1f),x0 + move x0,a + add a,b + move #>$100000,x0 + move x0,a + add a,b + move b,x1 + move x1,a + move #>$1fd000,x0 + cmp x0,a + tgt x0,a + move #>$002000,x0 + cmp x0,a + tlt x0,a + move x:(r7+$06),x0 + sub x0,a + asr #4,a,a + move a,x:(r7+$08) +; ---- right's head target, clamped, and its step a sample (a 16th of the way) + move x:(r7+$0a),a + move x:(r7+$3d),x0 + add x0,a + bsr cbsn + move x:(r7+$30),y1 + mpy x0,y1,b + move x:(r7+$30),a + asr #1,a,a + move a,y1 + move x:(r7+$3e),x0 + mac x0,y1,b + move x:(r7+$0b),a + move x:(r7+$3d),x0 + add x0,a + add x0,a + bsr cbtr + move x:(r7+$31),y1 + mac x0,y1,b + move x:(r7+$1f),x0 + move x0,a + add a,b + move x:(r7+$28),x0 + move #>$003000,y1 + mpy x0,y1,a + move a,x0 + move x0,a + add a,b + move #>$100000,x0 + move x0,a + add a,b + move b,x1 + move x1,a + move #>$1fd000,x0 + cmp x0,a + tgt x0,a + move #>$002000,x0 + cmp x0,a + tlt x0,a + move x:(r7+$07),x0 + sub x0,a + asr #4,a,a + move a,x:(r7+$09) +; ---- a dropout: one under way counts down, else GAPS (x wear) may start one + move x:(r7+$1d),a + tst a + ble cbg1 + move n7,x0 + sub x0,a + move a1,x:(r7+$1d) + tst a + bgt cbg3 + clr a + move a,x:(r7+$1d) + move #>$7fffff,x0 + move x0,x:(r7+$1e) + bra cbg3 +cbg1: + move x:(r7+$25),x0 + move #>$0a0000,y1 + mpy x0,y1,a + move a,x0 + move x:(r7+$04),y1 + move x0,a + mpy x0,y1,b + add b,a + add b,a + add b,a + move a,x0 + move x:(r7+$34),a + cmp x0,a + bge cbg3 + move x:(r7+$35),x0 + move #>7938,y1 + mpy x0,y1,a + move a1,x0 + move #>441,a + add x0,a + move a1,x:(r7+$1d) + move x:(r7+$36),x0 + move #>$600000,y1 + mpy x0,y1,b + move #>$7fffff,a + sub b,a + move a,x:(r7+$1e) +cbg3: +; ---- a glitch (GLCH x wear): a speed hiccup, or (none under way) a lost head contact + move x:(r7+$2a),x0 + move #>$040000,y1 + mpy x0,y1,a + move a,x0 + move x:(r7+$04),y1 + move x0,a + mpy x0,y1,b + add b,a + add b,a + move a,x0 + move x:(r7+$39),a + cmp x0,a + bge cbg6 + move x:(r7+$3a),a + and #>$400000,a + tst a + beq cbg4 + move x:(r7+$3a),a + sub #>$600000,a + asl #2,a,a + move a,x0 + move #>$040000,y1 + mpy x0,y1,a + move a,x:(r7+$1f) + bra cbg6 +cbg4: + move x:(r7+$1d),a + tst a + bne cbg6 + move x:(r7+$3a),x0 + move #>882,y1 + mpy x0,y1,a + move a1,x0 + move #>441,a + add x0,a + move a1,x:(r7+$1d) + move #>$0ccccd,x0 + move x0,x:(r7+$1e) +cbg6: +; ---- a click (DUST x wear): its size a random word x DUST's loudest + move x:(r7+$29),x0 + move #>$100000,y1 + mpy x0,y1,a + move a,x0 + move x:(r7+$04),y1 + move x0,a + mpy x0,y1,b + add b,a + add b,a + add b,a + move a,x0 + move x:(r7+$37),a + cmp x0,a + bge cbg7 + move x:(r7+$29),x0 + move #>$300000,y1 + mpy x0,y1,a + move a,y1 + move x:(r7+$38),a + sub #>$400000,a + asl #1,a,a + move a,x0 + mpy x0,y1,a + move a,x:(r7+$18) +cbg7: +; ---- the runs: the first call snaps them; then the drive and MIX walk a 16th of the way a sample, the dropout gain a 64th + move x:(r7+$2e),a + tst a + bne cbf1 + move x:(r7+$3f),x0 + move x0,x:(r7+$12) + move x:(r7+$26),x0 + move x0,x:(r7+$16) + move #>$1,x0 + move x0,x:(r7+$2e) +cbf1: + move x:(r7+$3f),a + move x:(r7+$12),x0 + sub x0,a + asr #4,a,a + move a,x:(r7+$13) + move x:(r7+$1e),a + move x:(r7+$14),x0 + sub x0,a + asr #6,a,a + move a,x:(r7+$15) + move x:(r7+$26),a + move x:(r7+$16),x0 + sub x0,a + asr #4,a,a + move a,x:(r7+$17) +; ---- a filter state or click within SNAP of zero is zero (truncation would hold it a few LSB off) + move x:(r7+$0e),a + abs a + move #>64,x0 + cmp x0,a + bgt cbn0 + clr a + move a,x:(r7+$0e) +cbn0: + move x:(r7+$0f),a + abs a + move #>64,x0 + cmp x0,a + bgt cbn1 + clr a + move a,x:(r7+$0f) +cbn1: + move x:(r7+$10),a + abs a + move #>64,x0 + cmp x0,a + bgt cbn2 + clr a + move a,x:(r7+$10) +cbn2: + move x:(r7+$11),a + abs a + move #>64,x0 + cmp x0,a + bgt cbn3 + clr a + move a,x:(r7+$11) +cbn3: + move x:(r7+$18),a + abs a + move #>64,x0 + cmp x0,a + bgt cbn4 + clr a + move a,x:(r7+$18) +cbn4: +; ---- the samples: straight-line + move x:(r7+$02),r5 + move #>$3ff,m5 + do n7,>cbsl +; the hiss: one LCG step, v = v x A + C; its low word left's noise, its high word right's + move x:(r7+$03),x0 + move #>$19660d,y1 + mpy x0,y1,a + asr #1,a,a + move a1,x:(r7+$3b) + move a0,x0 + move x0,b + add #>$6ef35f,b + move b1,x:(r7+$03) +; the drive, the dropout gain and MIX step; the click falls + move x:(r7+$12),a + move x:(r7+$13),x0 + add x0,a + move a,x:(r7+$12) + move x:(r7+$14),a + move x:(r7+$15),x0 + add x0,a + move a,x:(r7+$14) + move x:(r7+$16),a + move x:(r7+$17),x0 + add x0,a + move a,x:(r7+$16) + move x:(r7+$18),x0 + move #>$4ccccd,y1 + mpy x0,y1,a + move a,x:(r7+$18) +; ---- left: onto the tape at +0; the dry 256 behind; the head at d (Q11.12), read between its two samples + move x:(r0),a + move #>$000000,n5 + nop + move a,y:(r5+n5) + move #>$ffff00,n5 + nop + move y:(r5+n5),a + move a,x:(r7+$3c) + move x:(r7+$06),a + move x:(r7+$08),x0 + add x0,a + move a,x:(r7+$06) + move a,b + asr #12,b,b + and #>$fff,a + asl #11,a,a + move a1,y1 + move b1,x0 + move #>$000000,b + sub x0,b + move b1,n5 + nop + move y:(r5+n5),x1 + sub #>$1,b + move b1,n5 + nop + move y:(r5+n5),a + sub x1,a + move a,x0 + mpy x0,y1,a + add x1,a + move a1,x0 +; the drive (x 4) and the tape's cubic, a - a^3 / 3 + move x:(r7+$12),y1 + mpy x0,y1,a + asl #2,a,a + move a,x0 + move x0,y1 + mpy x0,y1,a + move a,y1 + mpy x0,y1,a + move a,x1 + move x0,b + move x1,x0 + move #>$2aaaab,y1 + mpy x0,y1,a + sub a,b + move b,x0 +; hiss on the tape + move x0,b + move x:(r7+$03),x0 + move x:(r7+$1c),y1 + mpy x0,y1,a + add a,b + move b,x0 +; playback's top (a one-pole low-pass), then the head bump + move x0,a + move x:(r7+$0e),x1 + sub x1,a + move a,x0 + move x:(r7+$1a),y1 + mpy x0,y1,a + add x1,a + move a1,x:(r7+$0e) + move a1,x1 + move x1,a + move x:(r7+$10),y0 + sub y0,a + move a,x0 + move #>$01fd8c,y1 + mpy x0,y1,a + add y0,a + move a1,x:(r7+$10) + move a1,x0 + move x:(r7+$1b),y1 + mpy x0,y1,a + add x1,a + move a,x0 +; dropouts, crackle, then MIX against the dry + move x:(r7+$14),y1 + mpy x0,y1,a + move x:(r7+$18),x1 + add x1,a + move a,x0 + move x0,a + move x:(r7+$3c),x1 + sub x1,a + move a,x0 + move x:(r7+$16),y1 + mpy x0,y1,a + add x1,a + move a,x:(r0)+ +; ---- right: onto the tape at +512; the dry 256 behind; the head at d (Q11.12), read between its two samples + move x:(r0),a + move #>$000200,n5 + nop + move a,y:(r5+n5) + move #>$000100,n5 + nop + move y:(r5+n5),a + move a,x:(r7+$3c) + move x:(r7+$07),a + move x:(r7+$09),x0 + add x0,a + move a,x:(r7+$07) + move a,b + asr #12,b,b + and #>$fff,a + asl #11,a,a + move a1,y1 + move b1,x0 + move #>$000200,b + sub x0,b + move b1,n5 + nop + move y:(r5+n5),x1 + sub #>$1,b + move b1,n5 + nop + move y:(r5+n5),a + sub x1,a + move a,x0 + mpy x0,y1,a + add x1,a + move a1,x0 +; the drive (x 4) and the tape's cubic, a - a^3 / 3 + move x:(r7+$12),y1 + mpy x0,y1,a + asl #2,a,a + move a,x0 + move x0,y1 + mpy x0,y1,a + move a,y1 + mpy x0,y1,a + move a,x1 + move x0,b + move x1,x0 + move #>$2aaaab,y1 + mpy x0,y1,a + sub a,b + move b,x0 +; hiss on the tape + move x0,b + move x:(r7+$3b),x0 + move x:(r7+$1c),y1 + mpy x0,y1,a + add a,b + move b,x0 +; playback's top (a one-pole low-pass), then the head bump + move x0,a + move x:(r7+$0f),x1 + sub x1,a + move a,x0 + move x:(r7+$1a),y1 + mpy x0,y1,a + add x1,a + move a1,x:(r7+$0f) + move a1,x1 + move x1,a + move x:(r7+$11),y0 + sub y0,a + move a,x0 + move #>$01fd8c,y1 + mpy x0,y1,a + add y0,a + move a1,x:(r7+$11) + move a1,x0 + move x:(r7+$1b),y1 + mpy x0,y1,a + add x1,a + move a,x0 +; dropouts, crackle, then MIX against the dry + move x:(r7+$14),y1 + mpy x0,y1,a + move x:(r7+$18),x1 + add x1,a + move a,x0 + move x0,a + move x:(r7+$3c),x1 + sub x1,a + move a,x0 + move x:(r7+$16),y1 + mpy x0,y1,a + add x1,a + move a,x:(r0)+ + move (r5)+ +cbsl: + nop + move r5,x:(r7+$02) +; Back to linear addressing, as the code after us expects: m5 held the ring's modulus. +cbzz: + move #>$ffffff,m5 + rts + +; x0 = a sine of the phase a1 (Q23 cycles): the triangle t, then t + t/2 - t^3/2. +cbsn: + bsr cbtr + move x0,y1 + mpy x0,y1,a + move a,y1 + mpy x0,y1,a + move a,x1 + move #>$400000,y1 + mpy x0,y1,b + move x0,a + add b,a + move x1,x0 + mpy x0,y1,b + sub b,a + move a,x0 + rts + +; x0 = a triangle of the phase a1 (Q23 cycles), -1 .. 1. +cbtr: + and #>$7fffff,a + move a1,x0 + move #>$400000,x1 + cmp x1,a + bge cbt1 + sub #>$200000,a + asl #2,a,a + move a,x0 + rts +cbt1: + move #>$600000,a + sub x0,a + asl #2,a,a + move a,x0 + rts + +; x0 = the next random word (23 bits). +cbrn: + move x:(r7+$05),a + lsr a + bcc cbrc + move #>$b40000,x0 + eor x0,a +cbrc: + move a1,x:(r7+$05) + and #>$7fffff,a + move a1,x0 + rts diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json new file mode 100644 index 0000000000..6c8381340d --- /dev/null +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -0,0 +1,34 @@ +{ + "schema": 1, + "module": "cassettebox", + "version": "0.1.0-experimental", + "sourceSha256": "5c88929aa7333818cfef403eda66db745aa497c78da76dce89767ee78428b4f2", + "kind": "dsp", + "cycles": { + "unit": "instructions/sample", + "static": 219, + "measured": 270.6, + "instancesPerCore": 4, + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 219 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK, a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 235.9 to 236.4; worst 270.6, the dearest POCKET setting with a split of 1 frame, where the per-call work (the knobs, wear, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." + }, + "stock": { + "comparator": "SPRING REV", + "comparatorWorst": 314.19, + "dearestWorst": 330.94, + "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", + "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 270.60, is 0.86x SPRING REV's 314.19 and 0.82x DJ EQ's 330.94; unsplit 236.4 against 257.50 and 293.38. Per sample and channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds hiss, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; one LCG step and three gain runs are shared." + }, + "stress": { + "instancesPerCore": 4, + "tracks": 8, + "lfosPerTrack": 3, + "lockedSlots": 12, + "seconds": 2, + "guard": true, + "dirty": true, + "clobbers": 0, + "hangs": 0, + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1081.6 and 1011.6 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + } +} diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py new file mode 100644 index 0000000000..7f2fd2e432 --- /dev/null +++ b/sdk/drafts/cassettebox/manifest.py @@ -0,0 +1,86 @@ +"""CASSETTEBOX -- an original '80s cassette effect for FX1 or FX2 of any track. + +The track goes onto a short tape (a 1,024-word ring in its slot's buffer) and plays back through a moving head: +DRFT (a slow drift and wander) and FLUT (fast flutter) bend the speed, DRIV saturates the tape, the playback rolls +off the top and lifts a head bump, HISS and DUST (crackle) ride on it, GAPS (dropouts) and GLCH (speed hiccups and +lost head contact) come and go. DECK picks the machine (STUDIO, HOME, POCKET), WIDE parts the channels, TONE +darkens it, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape +with the dry track, read at the tape's centre delay (5.8 ms) so the two never comb. + +verify.py holds engine.asm to reference.py's model bit for bit in dsp_host. Not yet run on a unit. +""" +import importlib.util +import pathlib + +from remix.schema import (Category, Claims, Proof, BusRole, DspSection, Formatter, Gate, Harness, Kind, + MenuEntry, Module, Param, YBase) + +# Under its own name: every module's manifest loads in one process, and another may have a reference.py too. +_spec = importlib.util.spec_from_file_location("cassettebox_ref", pathlib.Path(__file__).with_name("reference.py")) +_ref = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_ref) + +P, S = Formatter.PLAIN, Formatter.STEPPED +D = dict(zip(_ref.KNOBS, _ref.DEFAULTS)) + +MODULE = Module( + name="cassettebox", + key="CASSETTEBOX", + kind=Kind.DSP_EFFECT, + doc="'80s cassette effect on FX1 or FX2: drift, flutter, saturation, hiss, dropouts and tape wear.", + category=Category.TRACK, author="jrs1717", author_url="https://github.com/jrs1717", + proof=Proof.RENDER, + proof_note="verify.py bit-exact against reference.py in dsp_host; not yet run on a unit", + + menu=MenuEntry( + fx2_id=0x0a, + donor_desc=0x400d58b8, # DARK REV; every drawn slot is written below + abbr=b"CASS", + fullname=b"CASSETTEBOX", + build_tag=False, + ), + mode_slot=6, + + params=( + Param(b"DRFT", D["DRFT"], 128, active=True, formatter=P, + doc="drift: the tape speed's slow wander and sway; 0 steady"), + Param(b"FLUT", D["FLUT"], 128, active=True, formatter=P, + doc="flutter: the fast shimmering wobble; 0 none"), + Param(b"DRIV", D["DRIV"], 128, active=True, formatter=P, + doc="drive: saturation and compression, the tape pushed harder (and louder)"), + Param(b"HISS", D["HISS"], 128, active=True, formatter=P, + doc="tape hiss, shaped by the deck; 0 none"), + Param(b"GAPS", D["GAPS"], 128, active=True, formatter=P, + doc="dropouts: how often the level dips and muffles, as on creased or worn tape; 0 none"), + Param(b"MIX", D["MIX"], 128, active=True, formatter=P, + doc="dry/tape blend; 127 the tape alone, 0 the dry track (5.8 ms late, as the tape is)"), + Param(b"DECK", D["DECK"], 3, active=True, formatter=S, labels=_ref.DECKS, + doc="the machine: STUDIO (a good deck), HOME (a home stereo) or POCKET (a pocket recorder)"), + Param(b"WIDE", D["WIDE"], 128, active=True, formatter=P, + doc="stereo: left and right drift and flutter apart, the right head slightly misaligned"), + Param(b"DUST", D["DUST"], 128, active=True, formatter=P, + doc="crackle and clicks; 0 none"), + Param(b"GLCH", D["GLCH"], 128, active=True, formatter=P, + doc="glitches: now and then a speed hiccup or a lost head contact; 0 none"), + Param(b"TONE", D["TONE"], 128, active=True, formatter=P, + doc="darkens the top end, as worn heads or a cheap copy do; 0 the deck's own"), + Param(b"AGE", D["AGE"], 128, active=True, formatter=P, + doc="wear over time: 0 keeps the tape fresh; higher wears it faster (about 95 s to worn out at 127)"), + ), + + dsp=DspSection( + asm="modules/cassettebox/engine.asm", + priority=10, + bus_role=BusRole.NONE, + ybase=YBase.NEVER, + r7_latch_slot=None, + gate_label=None, + ), + # One 1,024-word ring out of its slot's buffer (an FX1 slot gives 3,072, 1024-aligned; an FX2 slot 16,384). + claims=Claims(stock_instance_buffer=True, buffer_words=_ref.RING), + + harness=Harness(layout_char=None, is_server=False), + + gates=(Gate("modules/cassettebox/verify.py", remix_arg=False),), + dear={k: v for k, v in zip(_ref.KNOBS, _ref.DEAREST)}, +) diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json new file mode 100644 index 0000000000..2a492289a4 --- /dev/null +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -0,0 +1,178 @@ +{ + "schemaVersion": 2, + "id": "cassettebox", + "key": "CASSETTEBOX", + "name": "Cassettebox", + "version": "0.1.0-experimental", + "category": "effects", + "author": { + "github": "jrs1717", + "credits": [ + "jrs1717" + ] + }, + "nativeManifest": "manifest.py", + "presentation": { + "label": "CASS", + "family": "Tape", + "summary": "An '80s cassette deck on FX1 or FX2: drift and flutter, tape saturation, hiss, crackle, dropouts and glitches, three decks, and tape that wears as it plays.", + "overview": "Cassettebox puts the track on a short tape and plays it back through a moving head. DRFT and FLUT bend the speed, DRIV saturates the tape, and the playback rolls off the top and lifts a bump in the lows. HISS and DUST ride on it, and GAPS and GLCH bring dropouts, speed hiccups and lost head contact. DECK picks the machine: STUDIO, HOME or POCKET. WIDE parts the channels, TONE darkens the top, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape with the dry track, which is read at the tape's centre delay so the two never comb.", + "highlights": [ + "Three decks: STUDIO, HOME and POCKET", + "Drift, flutter, saturation and a head bump, with hiss and crackle on the tape", + "Dropouts, speed hiccups and lost head contact, as often as you like", + "AGE wears the tape as it plays: duller, noisier and less steady over time", + "Runs on FX1 or FX2" + ], + "usage": [ + "Start on HOME with the defaults on a pad, a drum loop or a whole mix, then raise DRFT and FLUT for warble and DRIV for saturation.", + "Turn up AGE and let it play: the tape wears over a minute or two." + ] + }, + "controls": [ + { + "name": "DRFT", + "default": 32, + "count": 128, + "doc": "Drift: the tape speed's slow wander and sway; 0 steady.", + "labels": null + }, + { + "name": "FLUT", + "default": 24, + "count": 128, + "doc": "Flutter: the fast shimmering wobble; 0 none.", + "labels": null + }, + { + "name": "DRIV", + "default": 32, + "count": 128, + "doc": "Drive: saturation and compression, the tape pushed harder (and louder).", + "labels": null + }, + { + "name": "HISS", + "default": 24, + "count": 128, + "doc": "Tape hiss, shaped by the deck; 0 none.", + "labels": null + }, + { + "name": "GAPS", + "default": 0, + "count": 128, + "doc": "Dropouts: how often the level dips and muffles, as on creased or worn tape; 0 none.", + "labels": null + }, + { + "name": "MIX", + "default": 127, + "count": 128, + "doc": "Dry/tape blend; 127 the tape alone, 0 the dry track (5.8 ms late, as the tape is).", + "labels": null + }, + { + "name": "DECK", + "default": 1, + "count": 3, + "doc": "The machine: STUDIO (a good deck), HOME (a home stereo) or POCKET (a pocket recorder).", + "labels": [ + "STUDIO", + "HOME", + "POCKET" + ] + }, + { + "name": "WIDE", + "default": 32, + "count": 128, + "doc": "Stereo: left and right drift and flutter apart, the right head slightly misaligned.", + "labels": null + }, + { + "name": "DUST", + "default": 0, + "count": 128, + "doc": "Crackle and clicks; 0 none.", + "labels": null + }, + { + "name": "GLCH", + "default": 0, + "count": 128, + "doc": "Glitches: now and then a speed hiccup or a lost head contact; 0 none.", + "labels": null + }, + { + "name": "TONE", + "default": 0, + "count": 128, + "doc": "Darkens the top end, as worn heads or a cheap copy do; 0 the deck's own.", + "labels": null + }, + { + "name": "AGE", + "default": 0, + "count": 128, + "doc": "Wear over time: 0 keeps the tape fresh; higher wears it faster (about 95 s to worn out at 127).", + "labels": null + } + ], + "compatibility": { + "firmware": "1.40C", + "location": "FX1 / FX2", + "conflicts": [], + "uiClaims": [], + "limitations": [ + "A draft: verified bit-exact against its model in dsp_host; not yet run on a unit.", + "The tape sits 5.8 ms (256 samples) behind the track, and MIX 0 is the dry track at the same delay, so the two blend without combing." + ], + "effectId": 10 + }, + "resources": { + "recorded": "Not measured", + "storage": { + "label": "Storage", + "display": "Not measured", + "value": null, + "unit": "unknown", + "method": "unmeasured", + "conditions": "No measurements exist yet. Add exact conditions and source evidence when available.", + "source": "TESTING.md" + }, + "processing": { + "label": "CPU / DSP load", + "display": "Not measured", + "value": null, + "unit": "unknown", + "method": "unmeasured", + "conditions": "No measurements exist yet. Add exact conditions and source evidence when available.", + "source": "TESTING.md" + } + }, + "tests": { + "report": "TESTING.md", + "summary": "No tests have been run. Add tests.qualification with worst-case cycles, exact memory and attributed owner-reviewed hardware evidence before submitting. This scaffold cannot pass publication checks.", + "hardwareStatus": "untested", + "evidenceRevision": "b8deefc88b2c3e5f3c6158e364eb741df1924e1d", + "gates": [ + "Worst-case cycles under parameter modulation and maximum load", + "Exact memory region and maximum-instance totals", + "Owner-reviewed real-hardware evidence with actual coverage and limitations" + ] + }, + "license": { + "spdx": "MIT", + "file": "LICENSE", + "declaration": "Replace with accurate authorship, attribution and original/licensed source and media rights. Never include Elektron firmware, extracted routines or tables." + }, + "media": [], + "access": { + "location": "Describe the exact OT page or menu where the module is selected or enabled.", + "steps": [ + "Describe prerequisites, track/machine selection and the exact button/menu sequence." + ], + "screenshots": [] + } +} diff --git a/sdk/drafts/cassettebox/perf.py b/sdk/drafts/cassettebox/perf.py new file mode 100644 index 0000000000..7cedb72e91 --- /dev/null +++ b/sdk/drafts/cassettebox/perf.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python3 +"""Cassettebox's cost, for evidence/performance.json (docs/MODULE_PERFORMANCE.md). + + python3 -B perf.py (needs the DSP tools; a few minutes) + python3 -B perf.py --stress (the stress run only) + +static the per-sample loop's words: between `do n7,>cbsl` and cbsl, straight-line (no branch, no bsr, no nested + do or rep), so every sample runs every word. +measured executed instructions a sample from dsp_host's meter, one instance on verify.py's synthetic image: + the defaults, the dearest setting for each DECK (every artifact knob at 127, TONE 64, AGE 127, MIX 96) and + a moving pattern (every slot swept by triangles, DECK stepped, everything jumped every 37 blocks), each + unsplit and with a trig split at every position 1-15. +stress eight instances, four a core, each a different signal and split, the knobs moving, for 2 s through + dsp_host -guard 0x4000 -guard-shared -dirty: no clobber, no stray write, no hang. +Then npm run perf:audit -- check evidence/performance.json --stamp (docs/MODULE_PERFORMANCE.md). +""" +import math +import pathlib +import random +import sys + +HERE = pathlib.Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import verify as V # noqa: E402 (finds sdk/octatrack/tools) + +G, R = V.G, V.R +Q = R.Q +BLOCKS = 4096 +SECONDS = 2 + + +def static(asm): + """The per-sample loop's words: from after `do n7,>cbsl` (two words) to cbsl.""" + syms = asm.syms + lines = G.listing(asm) + do = [addr for addr, line in lines.items() if line.mnemonic.lower() == "do" and "n7" in line.operands.lower() + and addr < syms["cbsl"]] + return syms["cbsl"] - (max(do) + 2) + + +def moving(blocks, seed=1): + """Every slot swept by triangles an eighth of a turn apart (DECK 0-2 by its steps), everything jumped at random + every 37 blocks.""" + rnd = random.Random(seed) + rows = {} + for b in range(blocks): + row = [min(127, 128 - abs(((b + 32 * k) % 256) - 128)) for k in range(12)] + row[R.DECK_SLOT] = (b // 128) % 3 + if b % 37 == 0: + row = [rnd.randrange(128) for _ in range(12)] + row[R.DECK_SLOT] = rnd.randrange(3) + rows[b] = tuple(row) + return rows + + +def dearest(d): + row = list(R.DEAREST) + row[R.DECK_SLOT] = d + return tuple(row) + + +def stems(n, live): + rnd = random.Random(9) + on = lambda i, v: v if i < live else 0 # noqa: E731 + return [ + [on(i, round(0.9 * Q * (rnd.random() * 2 - 1) * math.exp(-(i % 11025) / 1500))) for i in range(n)], + [on(i, Q - 1 if (i // 110) % 2 else -Q) for i in range(n)], + [on(i, round(0.9 * Q * math.sin(2 * math.pi * (20 * (1000 ** (i / live))) * i / G.FS))) for i in range(n)], + [on(i, round(Q * (rnd.random() * 2 - 1))) for i in range(n)], + [on(i, Q - 1 if i % 4410 == 0 else 0) for i in range(n)], + [on(i, (Q - 1) if (i // 8820) % 2 else -Q) for i in range(n)], + [0] * n, + [on(i, round(0.3 * Q * sum(math.sin(2 * math.pi * f * i / G.FS) for f in (220, 277.2, 329.6)))) + for i in range(n)], + ] + + +def main(): + G.require_tools(HERE) + with G.workdir("cassettebox-perf-") as tmp: + work = pathlib.Path(tmp) + asm = G.assemble(V.SOURCE, work) + if "--stress" not in sys.argv: + print(f"static: {static(asm)} cycles/sample (the per-sample loop's words)", flush=True) + sig = G.noise(16 * BLOCKS, 0.7, 5) + cases = {"defaults": dict(knobs=R.DEFAULTS), "moving": dict(rows=moving(BLOCKS))} + for d, name in enumerate(R.DECKS): + cases[f"dearest {name}"] = dict(knobs=dearest(d)) + worst = (0.0, "") + for name, knobs in cases.items(): + found = {} + for split in range(16): + found[split] = G.run(asm, [G.Instance(sig, sig, **knobs)], split=split or None, tag="m").meter + if found[split] > worst[0]: + worst = (found[split], f"{name}, split {split}") + print(f"measured {name}: unsplit {found[0]:.2f}, worst with a split {max(found[s] for s in range(1, 16)):.2f}", + flush=True) + print(f"measured worst: {worst[0]:.2f} executed instructions a sample ({worst[1]})", flush=True) + + n = G.FS * SECONDS * 2 + insts = [G.Instance(s, s, rows=moving(n // 16, seed=k + 11), split=split, core=k // 4) + for k, (s, split) in enumerate(zip(stems(n, G.FS * SECONDS), (1, 3, 7, 8, 12, 15, 0, 0)))] + r = G.run(asm, insts, dirty=0x5a, guard="0x4000", extra=("-guard-shared",), check=False, tag="stress", timeout=3600) + print(f"stress: dsp_host exit {r.returncode}; meters {r.meters}; clobbers {sum(r.clobbers)}, stray {sum(r.stray)}") + for k, (core, pos) in enumerate(r.layout): + note = " (dsp_host's own word lands here)" if r.harness_word(k) else "" + print(f" instance {k}: core {core} pos {pos}, {r.per_instance[k]} a sample, {r.nonzero[k]} non-zero samples{note}") + if r.returncode: + print(r.stdout[-2000:]) + + +if __name__ == "__main__": + main() diff --git a/sdk/drafts/cassettebox/qualification.example.json b/sdk/drafts/cassettebox/qualification.example.json new file mode 100644 index 0000000000..f24ba06cd4 --- /dev/null +++ b/sdk/drafts/cassettebox/qualification.example.json @@ -0,0 +1,84 @@ +{ + "moduleVersion": "0.1.0", + "sourceSha256": "REPLACE_WITH_NATIVE_SOURCE_SHA256", + "imageSha256": "REPLACE_WITH_LOCAL_TESTED_IMAGE_SHA256", + "cycles": [ + { + "processor": "dsp", + "worstCase": null, + "maxConfiguration": null, + "maxInstances": null, + "budget": null, + "unit": "cycles/sample", + "method": "emulator", + "conditions": { + "parameterExtremes": "Describe every minimum, maximum and branch boundary tested.", + "parameterModulation": "Describe simultaneous LFOs, p-locks, MIDI CC and scene sweeps; justify each inapplicable mechanism.", + "modeSwitching": "Describe repeated/interrupted mode, bypass and Part changes.", + "maxLoad": "Describe maximum voices/instances, both cores, FX slots, streaming and USB/MIDI load.", + "inputConditions": "Describe silence, impulses, full-scale inputs, feedback and other worst-case signal conditions." + }, + "report": "TESTING.md" + } + ], + "memory": { + "regions": [ + { + "name": "Replace with each code, state, table, buffer, stack/heap and padding allocation", + "space": "dsp-p", + "words": null, + "wordBits": 24, + "bytes": null, + "scope": "shared" + } + ], + "perInstanceBytes": null, + "sharedBytes": null, + "maxInstances": null, + "totalBytes": null, + "conditions": "State exact build options, alignment, accounting convention, allocator/stack bounds and reused stock/shared memory; justify every absent allocation class.", + "report": "TESTING.md" + }, + "hardware": { + "status": "pending", + "model": "MKII", + "testedOn": "YYYY-MM-DD", + "tester": "Your credited tester handle; no email", + "project": { + "name": "Your local stress project", + "sha256": "REPLACE_WITH_PROJECT_FINGERPRINT", + "recipe": "Record generator/tool revision and command, local source template fingerprint, sample recipe, all settings and modifications needed to reproduce this stress project. Keep the project/card/firmware local." + }, + "durationMinutes": null, + "audioTracks": 8, + "midiTracks": null, + "conditions": { + "parameterExtremes": "Describe every minimum, maximum and branch boundary tested.", + "parameterModulation": "Describe simultaneous LFOs, p-locks, MIDI CC and scene sweeps; justify each inapplicable mechanism.", + "modeSwitching": "Describe repeated/interrupted mode, bypass and Part changes.", + "maxLoad": "Describe maximum voices/instances, both cores, FX slots, streaming and USB/MIDI load.", + "inputConditions": "Describe silence, impulses, full-scale inputs, feedback and other worst-case signal conditions." + }, + "checks": { + "audioContinuity": "failed", + "transport": "failed", + "controls": "failed", + "memoryIntegrity": "failed", + "recovery": "failed" + }, + "report": "TESTING.md", + "maxInstances": null + }, + "documentation": { + "tutorial": { + "title": "Quick tutorial", + "steps": [ + "Explain setup and exactly where to select or enable the module.", + "Demonstrate the main controls with a useful example setting.", + "Explain what to hear/observe and how to stop, reset or bypass." + ] + }, + "screenshots": [], + "screenshotStyle": "black-and-white" + } +} diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py new file mode 100644 index 0000000000..5e0c03ae33 --- /dev/null +++ b/sdk/drafts/cassettebox/reference.py @@ -0,0 +1,286 @@ +"""Cassettebox's reference, imported by verify.py and test_reference.py. + +Model is engine.asm instruction by instruction, on 24-bit words and a 56-bit accumulator, so dsp_host's render +must match it to the bit (verify.py). The design is original: an '80s cassette deck on an insert. The track goes +onto a short tape (a ring in the slot's buffer) and is played back through a moving head: slow drift and fast +flutter bend the speed, the tape saturates, the playback rolls off the top and lifts a bump in the lows, hiss and +crackle ride on it, and dropouts and glitches come and go. DECK picks the machine (STUDIO, HOME, POCKET); AGE +wears the tape while it plays, as a loop recorded over again and again. No product's code, tables or names. +""" +import math + +FS = 44100.0 +Q = 1 << 23 + +# ---- the fixed-point model ------------------------------------------------- + +def s24(v): + v &= 0xffffff + return v - (1 << 24) if v & 0x800000 else v + + +def w56(a): + a &= (1 << 56) - 1 + return a - (1 << 56) if a >> 55 else a + + +def lim(a): + return max(-0x800000, min(0x7fffff, a >> 24)) + + +def hi(a): + return s24(a >> 24) + + +def ld(x): + return s24(x) << 24 + + +def mac(a, x, y): + return w56(a + 2 * s24(x) * s24(y)) + + +def mpy(x, y): + return mac(0, x, y) + + +# ---- the tape -------------------------------------------------------------- + +RING = 1024 # the ring: Y words at the slot's base (every FX1 base is 1024-aligned), modulo $3ff +OFFS = (0, 512) # left's and right's lines: 512 samples each +D0 = 256 # the tape's centre delay: the dry is read here too, so MIX never combs (5.8 ms) +DMIN, DMAX = 2 << 12, 509 << 12 # the head's delay, Q11.12 samples +DRY_N5 = -D0 # n5 for the dry read (left; right adds 512) + +# DECK: STUDIO, HOME, POCKET +DECKS = ("STUDIO", "HOME", "POCKET") +WOWD = tuple(round(s * 4096) for s in (16, 32, 48)) # drift's swing at DRFT 127, Q11.12 samples (wear doubles it) +FLTD = tuple(round(s * 4096) for s in (3, 6, 12)) # flutter's swing at FLUT 127 (wear doubles it) +WOWR = tuple(round(f * 16 / FS * Q) for f in (0.55, 0.85, 1.3)) # drift's cycle a call (Q23) +FLTR = tuple(round(f * 16 / FS * Q) for f in (9.0, 7.0, 11.0)) # flutter's +DRVB = (0x200000, 0x2a0000, 0x3a0000) # the drive at DRIV 0, x 4 (1, 1.31, 1.81) +DRVR = 0x3c0000 # what DRIV 127 adds (x 4: +1.88) +HISSB = tuple(round(10 ** (db / 20) * Q) for db in (-56, -47, -38)) # hiss at HISS 127 +HFC = tuple(round((1 - math.exp(-2 * math.pi * fc / FS)) * Q) for fc in (15000, 8500, 4200)) # playback's top +BUMP = (0x2ccccd, 0x200000, 0x000000) # the head bump's level (0.35, 0.25, none) +CBUMP = round((1 - math.exp(-2 * math.pi * 110 / FS)) * Q) # the bump's corner, 110 Hz + +THIRD = 0x2aaaab # the cubic's 1/3 +TONE_K = 0x600000 # TONE 127 leaves 0.25 of the playback's corner coefficient +WEAR_HF = 0x4ccccd # full wear leaves 0.4 of it +WEAR_DRV = 0x140000 # full wear adds this to the drive (x 4: +0.63) +GAPP, DUSTP, GLP = 0x0a0000, 0x100000, 0x040000 # each event's chance a call at its knob's 127 (fresh tape) +GAP_LEN, GAP_RANGE = 441, 7938 # a dropout: 10 to 190 ms +GAP_DEPTH = 0x600000 # it dips to between 1 and 0.25 +CLICK = 0x300000 # crackle's loudest click +CDECAY = 0x4ccccd # a click falls to 0.6 a sample +HICCUP = 64 << 12 # a speed hiccup's largest jump, Q11.12 samples +GL_DECAY = 0x6ccccd # it settles at 0.85 a call +CONTACT = 0x0ccccd # a lost head contact leaves 0.1 +WIDE_PH = 0x200000 # WIDE 127 puts the right channel's drift a quarter cycle and its flutter half a cycle away +AZ = 3 << 12 # and its head 3 samples late (misaligned azimuth) +LCG_A, LCG_C = 1664525, 0x6ef35f +SNAP = 64 # a filter state or click this close to zero is zero (once a call) +LFSR_TAPS = 0xb40000 +SEED = 0x2b1d5f + +KNOBS = ("DRFT", "FLUT", "DRIV", "HISS", "GAPS", "MIX", "DECK", "WIDE", "DUST", "GLCH", "TONE", "AGE") +DEFAULTS = (32, 24, 32, 24, 0, 127, 1, 32, 0, 0, 0, 0) +DEAREST = (127, 127, 127, 127, 127, 96, 2, 127, 127, 127, 64, 127) +DECK_SLOT = 6 + + +def sine(ph): + """A sine from a phase (Q23 cycles): the triangle t in [-1, 1], then 1.5 t - 0.5 t^3.""" + ph &= 0x7fffff + if ph < 0x400000: + t = lim(w56(ld(ph - 0x200000) << 2)) # -1 .. 1 over the first half + else: + t = lim(w56(ld(0x600000 - ph) << 2)) # 1 .. -1 over the second + t3 = lim(mpy(lim(mpy(t, t)), t)) + return lim(ld(t) + mpy(t, 0x400000) - mpy(t3, 0x400000)) + + +def tri(ph): + """A triangle from a phase, -1 .. 1.""" + ph &= 0x7fffff + if ph < 0x400000: + return lim(w56(ld(ph - 0x200000) << 2)) + return lim(w56(ld(0x600000 - ph) << 2)) + + +class Model: + """One instance: the ring and the r7 block. call(frames, p) runs one block on [(left, right)] with the parameter + block p (offset -> word) and returns [(left, right)].""" + + def __init__(self, base=0x4000): + self.x = [0] * 0x60 + self.ring = [0] * RING + x = self.x + x[0x00] = base + x[0x02] = 0 # the write index (r5 - base) + x[0x03] = 0x5a3c1f # the hiss generator + x[0x05] = SEED + x[0x06] = x[0x07] = D0 << 12 + x[0x12] = 0 + x[0x14] = x[0x1e] = 0x7fffff + x[0x16] = 0 + + def rand(self): + x = self.x + v = x[0x05] & 0xffffff + carry = v & 1 + v >>= 1 + if carry: + v ^= LFSR_TAPS + x[0x05] = s24(v) + return v & 0x7fffff + + def srand(self): + """A random word, -1 .. 1.""" + return lim(w56((ld(self.rand()) - ld(0x400000)) << 1)) + + def call(self, frames, p): + x = self.x + n = len(frames) + # ---- knobs: page 1 r6+0..5 (v << 16), page 2 packed two to a word + k = [p.get(i, 0) & 0x7f0000 for i in range(6)] + x[0x21], x[0x22], x[0x23], x[0x24], x[0x25] = k[0], k[1], k[2], k[3], k[4] + m = k[5] + x[0x26] = 0x7fffff if m >= 0x7f0000 else m + x[0x27] = min((p.get(0xc, 0) & 0x7f0000) >> 16, 2) # DECK + x[0x28] = (p.get(0xc, 0) & 0x00ff00) << 8 # WIDE + x[0x29] = p.get(0xd, 0) & 0x7f0000 # DUST + x[0x2a] = (p.get(0xd, 0) & 0x00ff00) << 8 # GLCH + x[0x2b] = p.get(0xe, 0) & 0x7f0000 # TONE + x[0x2c] = (p.get(0xe, 0) & 0x00ff00) << 8 # AGE + deck = x[0x27] + # ---- wear: AGE 0 keeps the tape fresh; above, it wears AGE << 6 a call (48-bit), full in about 95 s at 127 + if x[0x2c] == 0: + x[0x04] = x[0x2d] = 0 + else: + wv = (x[0x04] << 24 | (x[0x2d] & 0xffffff)) + (x[0x2c] << 6) + if wv > 0x7fffff << 24: + wv = 0x7fffff << 24 + x[0x04], x[0x2d] = wv >> 24, wv & 0xffffff + wear = x[0x04] + more = lambda v, n3: lim(ld(v) + n3 * mpy(v, wear)) # v (1 + n3 wear) + # ---- the deck's figures this call + drv = lim(ld(DRVB[deck]) + mpy(x[0x23], DRVR) + mpy(wear, WEAR_DRV)) + hiss = more(lim(mpy(x[0x24], HISSB[deck])), 3) + tonef = lim(ld(0x7fffff) - mpy(x[0x2b], TONE_K)) + wearf = lim(ld(0x7fffff) - mpy(wear, WEAR_HF)) + chf = lim(mpy(lim(mpy(lim(mpy(HFC[deck], tonef)), wearf)), x[0x14])) # muffled as a dropout dips + x[0x1a], x[0x1b], x[0x1c] = chf, BUMP[deck], hiss + wowd = more(lim(mpy(x[0x21], WOWD[deck])), 1) + fltd = more(lim(mpy(x[0x22], FLTD[deck])), 1) + # ---- nine random words a call, always in this order + r_dl, r_dr, r_gap, r_glen, r_gdep, r_dust, r_damp, r_gl, r_gp = (self.rand() for _ in range(9)) + # ---- the speed: drift (a slow sine and a wandering random), flutter, a hiccup; WIDE parts the channels + x[0x0a] = (x[0x0a] + WOWR[deck]) & 0x7fffff + x[0x0b] = (x[0x0b] + FLTR[deck]) & 0x7fffff + x[0x0c] = hi(((ld(lim(w56((ld(r_dl) - ld(0x400000)) << 1))) - ld(x[0x0c])) >> 5) + ld(x[0x0c])) + x[0x0d] = hi(((ld(lim(w56((ld(r_dr) - ld(0x400000)) << 1))) - ld(x[0x0d])) >> 5) + ld(x[0x0d])) + wide = x[0x28] + off = mpy(wide, WIDE_PH) >> 24 + drift_r = lim(ld(x[0x0c]) + mpy(lim(ld(x[0x0d]) - ld(x[0x0c])), wide)) + x[0x1f] = lim(mpy(x[0x1f], GL_DECAY)) + for ch, (dw, ds, dr, wph, fph, az) in enumerate(( + (0x06, 0x08, x[0x0c], x[0x0a], x[0x0b], 0), + (0x07, 0x09, drift_r, x[0x0a] + off, x[0x0b] + 2 * off, lim(mpy(wide, AZ))))): + a = ld(D0 << 12) + mpy(wowd, sine(wph)) + mpy(lim(w56(ld(wowd) >> 1)), dr) + mpy(fltd, tri(fph)) + a = a + ld(x[0x1f]) + ld(az) + t = lim(a) + t = max(DMIN, min(DMAX, t)) + x[ds] = lim(w56((ld(t) - ld(x[dw])) >> 4)) + # ---- events: a dropout (GAPS), a glitch (GLCH: a hiccup or a lost contact), a click (DUST) + if x[0x1d] > 0: + x[0x1d] -= n + if x[0x1d] <= 0: + x[0x1d] = 0 + x[0x1e] = 0x7fffff + elif r_gap - more(lim(mpy(x[0x25], GAPP)), 3) < 0: + x[0x1d] = GAP_LEN + hi(mpy(r_glen, GAP_RANGE)) + x[0x1e] = lim(ld(0x7fffff) - mpy(r_gdep, GAP_DEPTH)) + if r_gl - more(lim(mpy(x[0x2a], GLP)), 2) < 0: + if r_gp & 0x400000: + x[0x1f] = lim(mpy(lim(w56((ld(r_gp) - ld(0x600000)) << 2)), HICCUP)) + elif x[0x1d] == 0: + x[0x1d] = GAP_LEN + hi(mpy(r_gp, 882)) + x[0x1e] = CONTACT + if r_dust - more(lim(mpy(x[0x29], DUSTP)), 3) < 0: + x[0x18] = lim(mpy(lim(w56((ld(r_damp) - ld(0x400000)) << 1)), lim(mpy(x[0x29], CLICK)))) + # ---- the runs: each knob's gain walks a 16th of the way a sample (none snaps but at the first call) + if x[0x2e] == 0: + x[0x12], x[0x16] = drv, x[0x26] + x[0x2e] = 1 + x[0x13] = lim(w56((ld(drv) - ld(x[0x12])) >> 4)) + x[0x15] = lim(w56((ld(x[0x1e]) - ld(x[0x14])) >> 6)) + x[0x17] = lim(w56((ld(x[0x26]) - ld(x[0x16])) >> 4)) + # truncating one-poles and the click's decay can stick a few LSB off zero: within SNAP (-102 dBFS) they are zero + for wd in (0x0e, 0x0f, 0x10, 0x11, 0x18): + if abs(x[wd]) <= SNAP: + x[wd] = 0 + return [self.sample(l, r) for l, r in frames] + + def sample(self, left, right): + x, ring = self.x, self.ring + v = x[0x03] & 0xffffff + pr = s24(v) * LCG_A + x[0x03] = s24((pr & 0xffffff) + LCG_C) + noise = (s24(x[0x03]), s24(pr >> 24)) + x[0x12] = lim(ld(x[0x12]) + ld(x[0x13])) + x[0x14] = lim(ld(x[0x14]) + ld(x[0x15])) + x[0x16] = lim(ld(x[0x16]) + ld(x[0x17])) + x[0x18] = lim(mpy(x[0x18], CDECAY)) + p = x[0x02] + out = [] + for ch, inp in enumerate((left, right)): + o = OFFS[ch] + ring[(p + o) % RING] = inp + dry = ring[(p + o - D0) % RING] + d = lim(ld(x[0x06 + ch]) + ld(x[0x08 + ch])) + x[0x06 + ch] = d + i, f = d >> 12, (d & 0xfff) << 11 + y0, y1 = ring[(p + o - i) % RING], ring[(p + o - i - 1) % RING] + w = hi(mpy(lim(ld(y1) - ld(y0)), f) + ld(y0)) + a = lim(w56(mpy(w, x[0x12]) << 2)) # the drive, x 4 + s = lim(ld(a) - mpy(lim(mpy(lim(mpy(a, a)), a)), THIRD)) # the tape's cubic + s = lim(ld(s) + mpy(noise[ch], x[0x1c])) # hiss, on the tape + lp = 0x0e + ch + x[lp] = hi(mpy(lim(ld(s) - ld(x[lp])), x[0x1a]) + ld(x[lp])) # playback's top + bp = 0x10 + ch + x[bp] = hi(mpy(lim(ld(x[lp]) - ld(x[bp])), CBUMP) + ld(x[bp])) # the head bump + t = lim(ld(x[lp]) + mpy(x[bp], x[0x1b])) + t = lim(mpy(t, x[0x14]) + ld(x[0x18])) # dropouts, then crackle + out.append(lim(ld(dry) + mpy(lim(ld(t) - ld(dry)), x[0x16]))) + x[0x02] = (p + 1) % RING + return tuple(out) + + +def pblock(values, raw=None): + """dsp_host's parameter block for slot values (0-127) and raw words {offset: word} written after.""" + v = list(values) + [0] * (12 - len(values)) + p = {i: (v[i] & 0x7f) << 16 for i in range(6)} + for w in range(3): + p[0xc + w] = ((v[6 + 2 * w] & 0x7f) << 16) | ((v[7 + 2 * w] & 0x7f) << 8) + p.update(raw or {}) + return p + + +def render(left, right, knob_rows, frames=16, split=0, raw=None, base=0x4000): + m = Model(base) + out_l, out_r = [], [] + cur = knob_rows.get(0, DEFAULTS) + for blk in range((len(left) + frames - 1) // frames): + cur = knob_rows.get(blk, cur) + p = pblock(cur, raw) + lo = blk * frames + fr = list(zip(left[lo:lo + frames], right[lo:lo + frames])) + for part in ([fr[:split], fr[split:]] if split else [fr]): + if not part: + continue + for l, r in m.call(part, p): + out_l.append(l) + out_r.append(r) + return out_l, out_r, m diff --git a/sdk/drafts/cassettebox/resource-impact.example.json b/sdk/drafts/cassettebox/resource-impact.example.json new file mode 100644 index 0000000000..8f7457a054 --- /dev/null +++ b/sdk/drafts/cassettebox/resource-impact.example.json @@ -0,0 +1,21 @@ +{ + "conditions": "Describe the active workload, expensive modes, changing controls, instance count, and whether shared/stock allocations are included.", + "cpu": { + "level": null, + "basis": "source-estimate", + "rationale": "Choose minimal, low, moderate or high from source inspection or a documented workload comparison. Explain the ColdFire work and cite the record; do not invent a utilization percentage.", + "source": "TESTING.md" + }, + "dsp": { + "level": null, + "basis": "source-estimate", + "rationale": "Choose a relative demand tier covering the expensive DSP modes and modulation. Minimal needs an explanation of the small or absent added DSP path.", + "source": "TESTING.md" + }, + "memory": { + "level": null, + "basis": "source-estimate", + "rationale": "Choose a relative footprint tier covering code, state, tables and buffers. Distinguish shared reservations and reused stock buffers from extra per-instance memory.", + "source": "TESTING.md" + } +} diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py new file mode 100644 index 0000000000..0917c87161 --- /dev/null +++ b/sdk/drafts/cassettebox/test_reference.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python3 +"""Cassettebox's model, tested on the host (no DSP tools): the constants follow their formulas, the tape behaves +as the README says (the dry 256 late, silence stays silent, each knob and deck changes the sound, AGE wears and +resets, the events happen), and nothing sticks off zero after the input stops. verify.py holds engine.asm to the +same model bit for bit.""" +import math +import pathlib +import random +import sys +import unittest + +HERE = pathlib.Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import reference as R # noqa: E402 + +N = 16 * 1500 + + +def noise(seed, n=N, amp=0.5): + rnd = random.Random(seed) + return [round(rnd.uniform(-amp, amp) * R.Q) for _ in range(n)] + + +def tone(hz=440, n=N, amp=0.4): + return [round(amp * R.Q * math.sin(2 * math.pi * hz * i / R.FS)) for i in range(n)] + + +def knobs(base=R.DEFAULTS, **kw): + row = list(base) + for name, value in kw.items(): + row[R.KNOBS.index(name.upper())] = value + return tuple(row) + + +QUIET = (0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 0) + + +def energy(v): + return sum(a * a for a in v) + + +class Constants(unittest.TestCase): + def test_formulas(self): + self.assertEqual(R.CBUMP, round((1 - math.exp(-2 * math.pi * 110 / R.FS)) * R.Q)) + self.assertEqual(R.HFC[1], round((1 - math.exp(-2 * math.pi * 8500 / R.FS)) * R.Q)) + self.assertEqual(R.WOWR[0], round(0.55 * 16 / R.FS * R.Q)) + self.assertEqual(R.HISSB[2], round(10 ** (-38 / 20) * R.Q)) + + def test_words_fit(self): + for w in (R.THIRD, R.TONE_K, R.WEAR_HF, R.WEAR_DRV, R.DRVR, R.CLICK, R.CDECAY, R.GL_DECAY, R.CONTACT, R.GAP_DEPTH, + R.CBUMP, R.LCG_C, R.LFSR_TAPS, *R.WOWD, *R.FLTD, *R.WOWR, *R.FLTR, *R.DRVB, *R.HISSB, *R.HFC, *R.BUMP): + self.assertTrue(0 <= w <= 0xffffff, hex(w)) + self.assertLess(R.LCG_A, 0x800000) + + def test_ring_and_delays(self): + self.assertEqual(R.RING, 1024) + self.assertLessEqual(R.DMAX >> 12, 511) + self.assertGreaterEqual(R.DMIN >> 12, 2) + # the largest swing never reaches the clamp: full wear doubles drift and flutter; the sine swings the drift, the + # wander half of it, then flutter, the largest hiccup and WIDE's azimuth + for d in range(3): + swing = (2 * R.WOWD[d] + R.WOWD[d] + 2 * R.FLTD[d] + R.HICCUP + R.AZ) >> 12 + self.assertLessEqual(swing, R.D0 - (R.DMIN >> 12), R.DECKS[d]) + self.assertLessEqual(R.D0 + swing, R.DMAX >> 12, R.DECKS[d]) + + def test_sine(self): + for k in range(16): + ph = k / 16 + self.assertAlmostEqual(R.sine(int(ph * R.Q)) / R.Q, -math.cos(2 * math.pi * ph), delta=0.03) + + +class Behaviour(unittest.TestCase): + def test_mix_0_is_the_dry_256_late(self): + x = noise(1) + l, r, _m = R.render(x, x, {0: knobs(mix=0)}) + self.assertEqual(l, ([0] * R.D0 + x)[:N]) + + def test_silence_stays_silent(self): + z = [0] * N + l, r, _m = R.render(z, z, {0: knobs((127,) * 12, hiss=0, dust=0, deck=2)}) + self.assertFalse(any(l + r)) + + def test_hiss_and_dust_sound_on_silence(self): + z = [0] * N + for name in ("hiss", "dust"): + l, r, _m = R.render(z, z, {0: knobs(QUIET, **{name: 127})}) + self.assertTrue(any(l), name) + + def test_the_tail_ends_in_exact_silence(self): + x = noise(2, 4410) + [0] * (16 * 6000) + for d in range(3): + l, r, _m = R.render(x, x, {0: knobs((127,) * 12, hiss=0, dust=0, deck=d)}) + self.assertFalse(any(l[-22050:] + r[-22050:]), R.DECKS[d]) + + def test_every_knob_changes_the_sound(self): + x = tone() + base = R.render(x, x, {0: knobs(QUIET, deck=1)})[:2] + for name in R.KNOBS: + if name in ("MIX", "DECK"): + continue + out = R.render(x, x, {0: knobs(QUIET, deck=1, **{name.lower(): 127})})[:2] + self.assertNotEqual(out, base, name) + + def test_decks_differ(self): + x = noise(3) + outs = [R.render(x, x, {0: knobs(deck=d)})[0] for d in range(3)] + self.assertEqual(len({tuple(o) for o in outs}), 3) + # POCKET is the darkest: least energy in the sample-to-sample differences + hf = [energy([b - a for a, b in zip(o, o[1:])]) / energy(o) for o in outs] + self.assertGreater(hf[0], hf[1]) + self.assertGreater(hf[1], hf[2]) + + def test_wide_parts_the_channels(self): + x = tone() + l, r, _m = R.render(x, x, {0: knobs(QUIET, drft=80, flut=80)}) + self.assertEqual(l, r) + l, r, _m = R.render(x, x, {0: knobs(QUIET, drft=80, flut=80, wide=127)}) + self.assertNotEqual(l, r) + + def test_age_wears_and_resets(self): + m = R.Model() + row = R.pblock(knobs(age=127)) + for _ in range(1000): + m.call([(0, 0)] * 16, row) + self.assertGreater(m.x[0x04], 0) + # full wear in about 95 s at 127: 1000 calls is 0.36 s + self.assertAlmostEqual(m.x[0x04] / 0x7fffff, 1000 / (95 * R.FS / 16), delta=0.002) + m.call([(0, 0)] * 16, R.pblock(knobs(age=0))) + self.assertEqual(m.x[0x04], 0) + + def test_wear_darkens_and_raises_hiss(self): + m = R.Model() + fresh = (m.x[0x1a], m.x[0x1c]) + row = R.pblock(knobs(age=127, hiss=64)) + m.call([(0, 0)] * 16, row) + fresh = (m.x[0x1a], m.x[0x1c]) + m.x[0x04] = 0x7fffff + m.call([(0, 0)] * 16, row) + self.assertLess(m.x[0x1a], fresh[0]) + self.assertGreater(m.x[0x1c], fresh[1]) + + def test_dropouts_and_glitches_happen(self): + m = R.Model() + dips = hiccups = 0 + row = R.pblock(knobs(QUIET, gaps=127, glch=127)) + for _ in range(4000): + m.call([(0, 0)] * 16, row) + dips += m.x[0x1e] < 0x7fffff + hiccups += m.x[0x1f] != 0 + self.assertGreater(dips, 100) + self.assertGreater(hiccups, 10) + + def test_the_head_stays_in_its_line(self): + x = noise(4, 16 * 3000) + m = R.Model() + row = R.pblock(knobs((127,) * 12, deck=2)) + for b in range(0, len(x), 16): + m.call([(x[b + i], x[b + i]) for i in range(16)], row) + for d in (0x06, 0x07): + self.assertTrue(R.DMIN - (1 << 12) <= m.x[d] <= R.DMAX + (1 << 12), hex(m.x[d])) + + +if __name__ == "__main__": + unittest.main(verbosity=1) diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py new file mode 100644 index 0000000000..20f36e7499 --- /dev/null +++ b/sdk/drafts/cassettebox/verify.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +"""Cassettebox's render gate: engine.asm assembled and run in dsp_host, held to reference.py's model. + + python3 -B verify.py (needs the DSP tools; a few minutes) + python3 -B verify.py --fx-audit PLAN RENDERS [--deck N] + +No firmware is read: the harness is sdk/octatrack/tools/dsp_gate.py, a synthetic image and dsp_host, whose +allocator hands the instance Y:$4000 (an FX2-sized slot; one gate below hands it $2000, an FX1-sized slot). Knobs +arrive as value << 16; DECK is slot 6 (bits 16-23 of r6+$c). What this cannot see: the composed image, the real +dispatcher and allocator, the panel and the sound on a unit. + +Gates: + 1. Every instruction decodes as written (signed mpy/mac x0,y1, no rep, no mpysu/macsu), no label is a + prefix of another (case-blind), the state stays inside X:(r7+$00..$57), and proc returns with every + modifier register it set to a modulus linear again. + 2. Bit for bit the model: every DECK at its defaults, its dearest and with every knob at 127, each knob alone at + 127, every knob swept, AGE wearing a tape for 12 s, a 5-frame trig split every block, a knob word carrying an + LFO's fraction bits, garbage state before init, state from two seeds, and an FX1-sized slot. + 3. MIX 0 is the track exactly, 256 samples late (the tape's centre, so MIX never combs); with HISS and DUST at 0, + silence in is exact silence out and a burst's tail ends in exact silence, at every DECK. + 4. The cycle meter, printed for TESTING.md: every DECK at its defaults, its dearest and every knob at 127. +""" +import pathlib +import re +import sys + +HERE = pathlib.Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) + + +def _library(): + for base in HERE.parents: + if (base / "sdk/octatrack/tools/dsp_gate.py").is_file(): + return base / "sdk/octatrack/tools" + sys.exit("[FAIL] sdk/octatrack/tools/dsp_gate.py not found: run this inside a Modwerk checkout") + + +sys.path.insert(0, str(_library())) +import dsp_gate as G # noqa: E402 +import reference as R # noqa: E402 + +SOURCE = HERE / "engine.asm" +STATE_LAST = 0x57 +NAMES = {name.lower(): i for i, name in enumerate(R.KNOBS)} + + +def knobs(base=R.DEFAULTS, **kw): + row = list(base) + [0] * (12 - len(base)) + for name, value in kw.items(): + row[NAMES[name]] = value + return tuple(row) + + +def main(): + G.require_tools(HERE) + gate = G.Gates("cassettebox") + with G.workdir("cassettebox-verify-") as tmp: + work = pathlib.Path(tmp) + asm = G.assemble(SOURCE, work) + if "--fx-audit" in sys.argv: + plan, renders = sys.argv[sys.argv.index("--fx-audit") + 1:][:2] + d = int(sys.argv[sys.argv.index("--deck") + 1]) if "--deck" in sys.argv else 1 + for path in G.render_fx_audit(asm, plan, renders, knobs(R.DEAREST, deck=d)): + print(path.name, flush=True) + return + + # 1. decodes as written + problems = G.trap_problems(asm, forms=("x0,y1",)) + gate("1 decodes as written: signed mpy/mac x0,y1, no rep, no mpysu/macsu", not problems, "; ".join(problems[:4])) + text = SOURCE.read_text() + labels = [l.lower() for l in re.findall(r"^([A-Za-z_][A-Za-z0-9_]*):", text, re.M)] + clashes = [(a, b) for a in labels for b in labels if a != b and b.startswith(a)] + [l for l in set(labels) if labels.count(l) > 1] + gate("1 no label is a prefix of another, case-blind (dsp_asm resolves labels by prefix)", not clashes, str(clashes)) + # Every modifier register proc sets to a modulus is linear again where proc returns (cbzz): the code that + # runs after an effect addresses with them (every published effect resets them; dsp_host cannot hear it). + bent = sorted(set(re.findall(r"move\s+#>?\$(?!ffffff)[0-9a-fA-F]+,(m[0-7])", text))) + tail = text[text.index("\ncbzz:"):] + tail = tail[:tail.index("rts")] + unreset = [m for m in bent if not re.search(r"move\s+#>?\$ffffff," + m + r"\b", tail)] + gate("1 proc leaves every modifier register it bends linear again (" + ", ".join(bent) + ")", bool(bent) and not unreset, str(unreset)) + far = [l.strip() for l in text.splitlines() if re.search(r"\blua\s+\(r[0-7]\+\$([0-9a-fA-F]+)\)", l) + and int(re.search(r"\(r[0-7]\+\$([0-9a-fA-F]+)\)", l).group(1), 16) > 0x3f] + gate("1 every lua (Rn+aa) offset is within its 7 bits (at most $3f)", not far, "; ".join(far)) + offsets = G.state_offsets(text) + gate("1 state inside X:(r7+$00..$57)", bool(offsets) and offsets[-1] <= STATE_LAST, f"(highest ${offsets[-1]:02x})") + + # 2. bit for bit the model + n = 16 * 3000 + nl, nr = G.noise(n, 0.6, 1), G.noise(n, 0.6, 2) + tl = [a + b for a, b in zip(G.tone(220, 0.4, n), G.noise(n, 0.1, 3))] + + def same(name, inst, raw=None, **kw): + r = G.run(asm, [inst], split=kw.get("split"), pwords=kw.get("pwords"), dirty=kw.get("dirty"), + image=kw.get("image")) + rows = inst.rows or {0: inst.knobs} + want = R.render(inst.left, inst.right, rows, split=kw.get("split") or 0, raw=raw, base=kw.get("base", 0x4000)) + gate.same(name, r.outputs[0], want[:2]) + return r + + meters = {} + full = (127,) * 12 + for d, dname in enumerate(R.DECKS): + meters[dname] = same(f"2 {dname} at the defaults", G.Instance(tl, nl, knobs=knobs(deck=d))).meter + meters["dear " + dname] = same(f"2 {dname} at its dearest", G.Instance(tl, nl, knobs=knobs(R.DEAREST, deck=d))).meter + meters["full " + dname] = same(f"2 {dname} with every knob at 127", G.Instance(nl, nr, knobs=knobs(full, deck=d))).meter + quiet = (0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 0) + for name in R.KNOBS: + if name in ("DECK", "MIX"): + continue + same(f"2 {name} alone at 127 (STUDIO)", G.Instance(tl, nl, knobs=knobs(quiet, **{name.lower(): 127}))) + rows, block = {0: R.DEFAULTS}, 40 + for slot, values in (("drft", (0, 127, 60)), ("flut", (0, 127, 40)), ("driv", (0, 127, 50)), ("hiss", (127, 0, 30)), + ("gaps", (127, 0, 40)), ("mix", (0, 127, 90)), ("deck", (0, 2, 1)), ("wide", (127, 0, 50)), + ("dust", (127, 0, 20)), ("glch", (127, 0, 30)), ("tone", (127, 0, 40)), ("age", (127, 0, 60))): + for value in values: + rows[block] = knobs(rows[max(rows)], **{slot: value}) + block += 120 + same("2 every knob swept", G.Instance(nl, nr, rows=rows)) + long_n = 16 * 33000 + ll, lr = G.noise(long_n, 0.5, 5), G.noise(long_n, 0.5, 6) + same("2 AGE 127 wearing the tape for 12 s, HOME, every artifact up", G.Instance(ll, lr, knobs=knobs( + drft=64, flut=64, hiss=64, gaps=64, dust=64, glch=64, age=127))) + same("2 a trig split every block", G.Instance(nl, nr, rows=rows), split=5) + word = (100 << 16) | 0xb700 + same("2 a knob word with an LFO's fraction bits", G.Instance(nl, nr, knobs=R.DEFAULTS), pwords=[(0, 0, word)], raw={0: word}) + same("2 garbage state before init", G.Instance(nl, nr, rows=rows), dirty=0x5a5a5a) + gate.two_seeds("2 the same output from state filled with two seeds: nothing read before it is written", + asm, [G.Instance(nl, nr, rows=rows)]) + same("2 an FX1-sized slot (base $2000) runs the same tape", G.Instance(nl, nr, rows=rows), + image=asm.image(x={G.ALLOC_AT: 0x2000}, name="fx1"), base=0x2000) + + # 3. the dry and silence + (l, r), = G.run(asm, [G.Instance(nl, nr, knobs=knobs(mix=0))], tag="dry").outputs + late = [0] * R.D0 + gate("3 MIX 0 is the track exactly, 256 samples late", l == (late + nl)[:n] and r == (late + nr)[:n]) + z = [0] * n + x = G.burst(4410, G.FS * 4) + for d, dname in enumerate(R.DECKS): + row = knobs(full, deck=d, hiss=0, dust=0) + (l, r), = G.run(asm, [G.Instance(z, z, knobs=row)], tag="zero").outputs + gate(f"3 {dname}: silence in, silence out with HISS and DUST at 0, everything else at 127", not any(l + r)) + (l, r), = G.run(asm, [G.Instance(x, x, knobs=row)], tag="tail").outputs + gate(f"3 {dname}: a burst's tail ends in exact silence, HISS and DUST at 0", not any(l[-G.FS // 2:] + r[-G.FS // 2:])) + + print("[INFO] cycle meter: " + ", ".join(f"{k} {v}" for k, v in meters.items())) + print(f"[INFO] dsp_gate.py {G.provenance(HERE)['dsp_gate.py']}") + gate.finish() + + +if __name__ == "__main__": + main() From 67443ec4b60cc50c1b7764a659299dba196ec866 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Thu, 3 Dec 2026 22:33:21 -0600 Subject: [PATCH 02/16] Cassettebox: cleaner (the author's first trials) and a VHS deck Hiss 8 dB lower and softened (HISS's default 16); crackle much rarer at low settings (the knob squared), quieter and through playback's low-pass; dropouts and glitches rarer at low settings, the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps maximal (it cycled every 4,599 steps). DECK gains VHS, an aged videotape's sound: narrow, a low cut in place of the head bump, a slow deep warble, more hiss. verify.py bit-exact at every deck; test_reference.py 18/18; worst 285.6, 0.91x SPRING REV. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 18 +- sdk/drafts/cassettebox/TESTING.md | 6 +- sdk/drafts/cassettebox/engine.asm | 161 +++++++++++------- .../cassettebox/evidence/performance.json | 12 +- sdk/drafts/cassettebox/manifest.py | 8 +- sdk/drafts/cassettebox/octamod.module.json | 15 +- sdk/drafts/cassettebox/perf.py | 6 +- sdk/drafts/cassettebox/reference.py | 59 ++++--- sdk/drafts/cassettebox/test_reference.py | 63 +++++-- sdk/drafts/cassettebox/verify.py | 6 +- 10 files changed, 223 insertions(+), 131 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 987d8a99be..937ad20a25 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -4,12 +4,12 @@ Version 0.1.0-experimental · by @jrs1717 · a draft: bit for bit against its mo ## Overview -Cassettebox is an '80s cassette deck for an audio track's FX1 or FX2 slot. It puts the track on a short tape and plays it back through a moving head: +Cassettebox is an '80s cassette deck, or an aged VHS tape's sound, for an audio track's FX1 or FX2 slot. It puts the track on a short tape and plays it back through a moving head: - **The speed wanders:** DRFT sways and wanders slowly, FLUT adds the fast shimmering wobble. - **The tape colours it:** DRIV saturates it, and the playback rolls off the top and lifts a bump in the lows. - **The tape is imperfect:** HISS and DUST (crackle) ride on it, GAPS brings dropouts, and GLCH brings speed hiccups and lost head contact. -DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; or POCKET, a pocket recorder. WIDE parts the left and right channels, and TONE darkens the top. AGE wears the tape while it plays, as a loop recorded over again and again: the top fades, the hiss and crackle grow, dropouts come more often and the speed grows less steady. MIX blends the tape with the dry track. +DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pocket recorder; or VHS, the sound of an old videotape. WIDE parts the left and right channels, and TONE darkens the top. AGE wears the tape while it plays, as a loop recorded over again and again: the top fades, the hiss and crackle grow, dropouts come more often and the speed grows less steady. MIX blends the tape with the dry track. ## Controls @@ -18,13 +18,13 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; or POCKET, a p | Main | A | DRFT | 0-127 | 32 | Drift: the tape speed's slow sway and wander. 0 is steady. | | Main | B | FLUT | 0-127 | 24 | Flutter: the fast shimmering wobble. | | Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder). | -| Main | D | HISS | 0-127 | 24 | Tape hiss, shaped by the deck. | -| Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. | +| Main | D | HISS | 0-127 | 16 | Tape hiss, shaped by the deck. | +| Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. Rare at low settings, frequent near 127. | | Main | F | MIX | 0-127 | 127 | Dry/tape blend. 127 is the tape alone, 0 the dry track. | -| Setup | A | DECK | STUDIO, HOME, POCKET | HOME | The machine: its tone, head bump, saturation, hiss and how steady it runs. STUDIO is clean and steady, HOME duller with more hiss and a little warble, POCKET narrow, hissy, fluttery and crunchy. | +| Setup | A | DECK | STUDIO, HOME, POCKET, VHS | HOME | The machine: its tone, head bump, saturation, hiss and how steady it runs. STUDIO is clean and steady, HOME duller with more hiss and a little warble, POCKET narrow, hissy, fluttery and crunchy, VHS an aged videotape: thin lows, a muffled top and a slow, deep warble. | | Setup | B | WIDE | 0-127 | 32 | Stereo: left and right drift and flutter apart, and the right head sits slightly misaligned. | -| Setup | C | DUST | 0-127 | 0 | Crackle and clicks. | -| Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed hiccup or a moment of lost head contact. | +| Setup | C | DUST | 0-127 | 0 | Crackle: soft pops, an occasional tick at low settings and a steady crackle near 127. | +| Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed swoop or a moment of lost head contact. Rare at low settings. | | Setup | E | TONE | 0-127 | 0 | Darkens the top end, as worn heads or a cheap copy do. 0 is the deck's own. | | Setup | F | AGE | 0-127 | 0 | Wear over time. 0 keeps the tape fresh; higher wears it faster, about 95 s to worn out at 127 and about 3 minutes at 64. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | @@ -36,7 +36,7 @@ Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to CASSETTEB 1. Put Cassettebox on FX1 of a track playing a pad, a drum loop or a whole mix. At the defaults it is a HOME deck with a little warble and hiss. 2. Raise DRFT and FLUT for a seasick warble, and DRIV to push the tape into saturation. -3. Hold FUNC and press FX1, and try DECK on STUDIO and POCKET. +3. Hold FUNC and press FX1, and try DECK on STUDIO, POCKET and VHS. 4. Raise GAPS, DUST and GLCH for a worn, dropout-prone tape. 5. Turn AGE up and let the pattern play: over a minute or two the tape wears, darker, noisier and less steady. @@ -62,5 +62,5 @@ None yet. ## Develop -- Hear it: `npm run module:dev -- cassettebox --cycles 240 --cycles-kind executed --state 88 --buffer 1024 --slots both`. +- Hear it: `npm run module:dev -- cassettebox --cycles 286 --cycles-kind executed --state 96 --buffer 1024 --slots both`. - Check it: `npm run module:doctor -- --draft cassettebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`, and `python3 -B test_reference.py` tests the model. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index 50669456b5..6c10901bc3 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -4,11 +4,11 @@ Record what you ran, on which build and which unit, and what you saw. "Not teste ## In dsp_host (not hardware evidence) -`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and an FX1-sized slot. MIX 0 is the track exactly, 256 samples late. With HISS and DUST at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 15/15. +`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and an FX1-sized slot. MIX 0 is the track exactly, 256 samples late. With HISS and DUST at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 18/18. ## On the unit -Not tested. +1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). Not yet trialled on the unit. ## Stock flows @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 219 words; measured unsplit 235.9 to 236.4, worst 270.6 (the dearest POCKET setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1081.6 and 1011.6, 0 clobbers, 0 stray writes). 0.86x SPRING REV (314.19). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 233 words; measured unsplit 250.9 to 251.4, worst 285.6 (the moving pattern with a split of 1 frame); stress clean (eight instances, per-core peaks 1143.3 and 1073.2, 0 clobbers, 0 stray writes). 0.91x SPRING REV (314.19). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index c15bf823c0..1c7b72de40 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -13,13 +13,14 @@ ; (a 24-bit LCG: its low word left, its high word right), playback's top (a ; one-pole low-pass, DECK x TONE x wear x a dropout's dip), a head bump (110 Hz ; one-pole, DECK's level), dropouts' gain and crackle, then MIX. -; DECK: STUDIO, HOME, POCKET (drift, flutter, drive, hiss, top, bump). +; DECK: STUDIO, HOME, POCKET, VHS (drift, flutter, drive, hiss, top, bump; VHS's +; negative bump cuts the lows). ; AGE: 0 keeps the tape fresh; above it wears AGE << 6 a call (48-bit), full in ; about 95 s at 127; wear lifts the drive, darkens the top and multiplies the ; drift, flutter, hiss, dropouts, glitches and crackle. ; ; Knobs (value<<16): page 1 DRFT r6+0, FLUT r6+1, DRIV r6+2, HISS r6+3, GAPS -; r6+4, MIX r6+5; page 2 DECK slot 6 (r6+$c bits 16-23, 0-2), WIDE slot 7 +; r6+4, MIX r6+5; page 2 DECK slot 6 (r6+$c bits 16-23, 0-3), WIDE slot 7 ; (r6+$c 8-15), DUST slot 8 (r6+$d 16-23), GLCH slot 9 (r6+$d 8-15), TONE slot ; 10 (r6+$e 16-23), AGE slot 11 (r6+$e 8-15). ; @@ -29,12 +30,12 @@ ; $0c/$0d each channel's wander $0e/$0f playback's low-pass states $10/$11 the bump's states ; $12/$13 the drive and its step $14/$15 the dropout gain and its step $16/$17 MIX and its step ; $18 the click $1a the top's coefficient $1b the bump's level $1c the hiss level -; $1d a dropout's frames left $1e its gain $1f the hiccup (Q11.12) -; $21-$2c DRFT FLUT DRIV HISS GAPS MIX DECK WIDE DUST GLCH TONE AGE $2d wear's low word $2e seeded -; $30/$31 drift's and flutter's swings $32-$3a nine random words $3b right's noise +; $19 left's last noise word $1d a dropout's frames left $1e its gain $1f the hiccup (Q11.12) $20 its target +; $21-$2c DRFT FLUT DRIV HISS GAPS MIX DECK WIDE DUST GLCH TONE AGE $2d wear's low word $2e seeded $2f right's last noise word +; $30/$31 drift's and flutter's swings (a call), then each channel's softened noise (a sample) $32-$3a nine random words $3b right's noise ; $3c the dry (scratch) $3d WIDE's phase offset $3e right's wander -; $40-$57 DECK's tables, three words each: drift, flutter, their rates, drive, hiss, top, bump -; Nothing above $57 is touched. Every product is the signed mpy/mac x0,y1 +; $40-$5f DECK's tables, four words each: drift, flutter, their rates, drive, hiss, top, bump +; Nothing above $5f is touched. Every product is the signed mpy/mac x0,y1 ; form. Labels are cb and two characters, so none is another's prefix. ; CYCLES_FORWARD_BRANCHES init: @@ -73,48 +74,64 @@ cbi1: move x0,x:(r7+$41) move #>$030000,x0 move x0,x:(r7+$42) - move #>$003000,x0 + move #>$02c000,x0 move x0,x:(r7+$43) - move #>$006000,x0 + move #>$003000,x0 move x0,x:(r7+$44) - move #>$00c000,x0 + move #>$006000,x0 move x0,x:(r7+$45) - move #>$00068a,x0 + move #>$00c000,x0 move x0,x:(r7+$46) - move #>$000a1b,x0 + move #>$005000,x0 move x0,x:(r7+$47) - move #>$000f75,x0 + move #>$00068a,x0 move x0,x:(r7+$48) - move #>$006aff,x0 + move #>$000a1b,x0 move x0,x:(r7+$49) - move #>$005338,x0 + move #>$000f75,x0 move x0,x:(r7+$4a) - move #>$0082c6,x0 + move #>$000429,x0 move x0,x:(r7+$4b) - move #>$200000,x0 + move #>$006aff,x0 move x0,x:(r7+$4c) - move #>$2a0000,x0 + move #>$005338,x0 move x0,x:(r7+$4d) - move #>$3a0000,x0 + move #>$0082c6,x0 move x0,x:(r7+$4e) - move #>$0033ef,x0 + move #>$003580,x0 move x0,x:(r7+$4f) - move #>$00925f,x0 + move #>$200000,x0 move x0,x:(r7+$50) - move #>$019c86,x0 + move #>$2a0000,x0 move x0,x:(r7+$51) - move #>$70e5a3,x0 + move #>$3a0000,x0 move x0,x:(r7+$52) - move #>$59dee0,x0 + move #>$2c0000,x0 move x0,x:(r7+$53) - move #>$39a3b8,x0 + move #>$0014ad,x0 move x0,x:(r7+$54) - move #>$2ccccd,x0 + move #>$003a45,x0 move x0,x:(r7+$55) - move #>$200000,x0 + move #>$00a43b,x0 move x0,x:(r7+$56) - move #>$000000,x0 + move #>$00679f,x0 move x0,x:(r7+$57) + move #>$70e5a3,x0 + move x0,x:(r7+$58) + move #>$59dee0,x0 + move x0,x:(r7+$59) + move #>$39a3b8,x0 + move x0,x:(r7+$5a) + move #>$498e4d,x0 + move x0,x:(r7+$5b) + move #>$2ccccd,x0 + move x0,x:(r7+$5c) + move #>$200000,x0 + move x0,x:(r7+$5d) + move #>$000000,x0 + move x0,x:(r7+$5e) + move #>$a33333,x0 + move x0,x:(r7+$5f) rts proc: @@ -146,7 +163,7 @@ proc: move x:(r6+$c),a and #>$7f0000,a asr #16,a,a - move #>$2,x0 + move #>$3,x0 cmp x0,a tgt x0,a move a1,x:(r7+$27) @@ -189,7 +206,7 @@ cbw1: cbw2: ; ---- the deck's figures: the drive, the hiss, the top, the bump, the swings move x:(r7+$27),a - add #>$4c,a + add #>$50,a move a1,n1 nop move x:(r1+n1),x0 @@ -202,7 +219,7 @@ cbw2: mac x0,y1,b move b,x:(r7+$3f) move x:(r7+$27),a - add #>$4f,a + add #>$54,a move a1,n1 nop move x:(r1+n1),y1 @@ -230,7 +247,7 @@ cbw2: sub b,a move a,x:(r7+$3d) move x:(r7+$27),a - add #>$52,a + add #>$58,a move a1,n1 nop move x:(r1+n1),x0 @@ -244,7 +261,7 @@ cbw2: mpy x0,y1,a move a,x:(r7+$1a) move x:(r7+$27),a - add #>$55,a + add #>$5c,a move a1,n1 nop move x:(r1+n1),x0 @@ -264,7 +281,7 @@ cbw2: move a,x0 move x0,x:(r7+$30) move x:(r7+$27),a - add #>$43,a + add #>$44,a move a1,n1 nop move x:(r1+n1),y1 @@ -298,7 +315,7 @@ cbw2: move x0,x:(r7+$3a) ; ---- drift's and flutter's phases; each channel's wander a 32nd of the way to a new random word move x:(r7+$27),a - add #>$46,a + add #>$48,a move a1,n1 nop move x:(r1+n1),x0 @@ -307,7 +324,7 @@ cbw2: and #>$7fffff,a move a1,x:(r7+$0a) move x:(r7+$27),a - add #>$49,a + add #>$4c,a move a1,n1 nop move x:(r1+n1),x0 @@ -322,7 +339,7 @@ cbw2: move x0,a move x:(r7+$0c),x0 sub x0,a - asr #5,a,a + asr #8,a,a add x0,a move a1,x:(r7+$0c) move x:(r7+$33),a @@ -332,7 +349,7 @@ cbw2: move x0,a move x:(r7+$0d),x0 sub x0,a - asr #5,a,a + asr #8,a,a add x0,a move a1,x:(r7+$0d) ; WIDE: the right channel's phase offset, its wander between left's and its own, the hiccup settling @@ -348,10 +365,16 @@ cbw2: mpy x0,y1,a add x1,a move a,x:(r7+$3e) + move x:(r7+$20),a move x:(r7+$1f),x0 + sub x0,a + asr #4,a,a + add x0,a + move a1,x:(r7+$1f) + move x:(r7+$20),x0 move #>$6ccccd,y1 mpy x0,y1,a - move a,x:(r7+$1f) + move a,x:(r7+$20) ; ---- left's head target, clamped, and its step a sample (a 16th of the way) move x:(r7+$0a),a bsr cbsn @@ -443,7 +466,10 @@ cbw2: bra cbg3 cbg1: move x:(r7+$25),x0 - move #>$0a0000,y1 + move x0,y1 + mpy x0,y1,a + move a,x0 + move #>$008000,y1 mpy x0,y1,a move a,x0 move x:(r7+$04),y1 @@ -472,7 +498,10 @@ cbg1: cbg3: ; ---- a glitch (GLCH x wear): a speed hiccup, or (none under way) a lost head contact move x:(r7+$2a),x0 - move #>$040000,y1 + move x0,y1 + mpy x0,y1,a + move a,x0 + move #>$004000,y1 mpy x0,y1,a move a,x0 move x:(r7+$04),y1 @@ -492,9 +521,9 @@ cbg3: sub #>$600000,a asl #2,a,a move a,x0 - move #>$040000,y1 + move #>$030000,y1 mpy x0,y1,a - move a,x:(r7+$1f) + move a,x:(r7+$20) bra cbg6 cbg4: move x:(r7+$1d),a @@ -512,7 +541,10 @@ cbg4: cbg6: ; ---- a click (DUST x wear): its size a random word x DUST's loudest move x:(r7+$29),x0 - move #>$100000,y1 + move x0,y1 + mpy x0,y1,a + move a,x0 + move #>$010000,y1 mpy x0,y1,a move a,x0 move x:(r7+$04),y1 @@ -526,7 +558,7 @@ cbg6: cmp x0,a bge cbg7 move x:(r7+$29),x0 - move #>$300000,y1 + move #>$0c0000,y1 mpy x0,y1,a move a,y1 move x:(r7+$38),a @@ -555,7 +587,7 @@ cbf1: move x:(r7+$1e),a move x:(r7+$14),x0 sub x0,a - asr #6,a,a + asr #9,a,a move a,x:(r7+$15) move x:(r7+$26),a move x:(r7+$16),x0 @@ -617,6 +649,21 @@ cbn4: move x0,b add #>$6ef35f,b move b1,x:(r7+$03) +; softened: each noise word averaged with the last (left to $30, right to $31) + move x:(r7+$03),a + move x:(r7+$19),x0 + add x0,a + asr #1,a,a + move a1,x:(r7+$30) + move x:(r7+$03),x0 + move x0,x:(r7+$19) + move x:(r7+$3b),a + move x:(r7+$2f),x0 + add x0,a + asr #1,a,a + move a1,x:(r7+$31) + move x:(r7+$3b),x0 + move x0,x:(r7+$2f) ; the drive, the dropout gain and MIX step; the click falls move x:(r7+$12),a move x:(r7+$13),x0 @@ -683,12 +730,14 @@ cbn4: mpy x0,y1,a sub a,b move b,x0 -; hiss on the tape +; hiss and crackle on the tape move x0,b - move x:(r7+$03),x0 + move x:(r7+$30),x0 move x:(r7+$1c),y1 mpy x0,y1,a add a,b + move x:(r7+$18),a + add a,b move b,x0 ; playback's top (a one-pole low-pass), then the head bump move x0,a @@ -713,11 +762,9 @@ cbn4: mpy x0,y1,a add x1,a move a,x0 -; dropouts, crackle, then MIX against the dry +; dropouts, then MIX against the dry move x:(r7+$14),y1 mpy x0,y1,a - move x:(r7+$18),x1 - add x1,a move a,x0 move x0,a move x:(r7+$3c),x1 @@ -776,12 +823,14 @@ cbn4: mpy x0,y1,a sub a,b move b,x0 -; hiss on the tape +; hiss and crackle on the tape move x0,b - move x:(r7+$3b),x0 + move x:(r7+$31),x0 move x:(r7+$1c),y1 mpy x0,y1,a add a,b + move x:(r7+$18),a + add a,b move b,x0 ; playback's top (a one-pole low-pass), then the head bump move x0,a @@ -806,11 +855,9 @@ cbn4: mpy x0,y1,a add x1,a move a,x0 -; dropouts, crackle, then MIX against the dry +; dropouts, then MIX against the dry move x:(r7+$14),y1 mpy x0,y1,a - move x:(r7+$18),x1 - add x1,a move a,x0 move x0,a move x:(r7+$3c),x1 @@ -870,7 +917,7 @@ cbrn: move x:(r7+$05),a lsr a bcc cbrc - move #>$b40000,x0 + move #>$e10000,x0 eor x0,a cbrc: move a1,x:(r7+$05) diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index 6c8381340d..2e58834a05 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "5c88929aa7333818cfef403eda66db745aa497c78da76dce89767ee78428b4f2", + "sourceSha256": "c0d390345464f9c97eeadacfc05e66cfa1cd69f5c7e826a5f9ad8ce4814f39d5", "kind": "dsp", "cycles": { "unit": "instructions/sample", - "static": 219, - "measured": 270.6, + "static": 233, + "measured": 285.6, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 219 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK, a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 235.9 to 236.4; worst 270.6, the dearest POCKET setting with a split of 1 frame, where the per-call work (the knobs, wear, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 233 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 250.9 to 251.4; worst 285.6, the moving pattern with a split of 1 frame, where the per-call work (the knobs, wear, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", @@ -17,7 +17,7 @@ "dearestWorst": 330.94, "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", - "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 270.60, is 0.86x SPRING REV's 314.19 and 0.82x DJ EQ's 330.94; unsplit 236.4 against 257.50 and 293.38. Per sample and channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds hiss, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; one LCG step and three gain runs are shared." + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 285.60, is 0.91x SPRING REV's 314.19 and 0.86x DJ EQ's 330.94; unsplit 251.4 against 257.50 and 293.38. Per sample and channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; one LCG step and three gain runs are shared." }, "stress": { "instancesPerCore": 4, @@ -29,6 +29,6 @@ "dirty": true, "clobbers": 0, "hangs": 0, - "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1081.6 and 1011.6 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1143.3 and 1073.2 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." } } diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index 7f2fd2e432..c97326ff2b 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -3,7 +3,7 @@ The track goes onto a short tape (a 1,024-word ring in its slot's buffer) and plays back through a moving head: DRFT (a slow drift and wander) and FLUT (fast flutter) bend the speed, DRIV saturates the tape, the playback rolls off the top and lifts a head bump, HISS and DUST (crackle) ride on it, GAPS (dropouts) and GLCH (speed hiccups and -lost head contact) come and go. DECK picks the machine (STUDIO, HOME, POCKET), WIDE parts the channels, TONE +lost head contact) come and go. DECK picks the machine (STUDIO, HOME, POCKET, or VHS for an aged videotape's sound), WIDE parts the channels, TONE darkens it, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape with the dry track, read at the tape's centre delay (5.8 ms) so the two never comb. @@ -27,7 +27,7 @@ name="cassettebox", key="CASSETTEBOX", kind=Kind.DSP_EFFECT, - doc="'80s cassette effect on FX1 or FX2: drift, flutter, saturation, hiss, dropouts and tape wear.", + doc="'80s cassette and VHS tape effect on FX1 or FX2: drift, flutter, saturation, hiss, dropouts and tape wear.", category=Category.TRACK, author="jrs1717", author_url="https://github.com/jrs1717", proof=Proof.RENDER, proof_note="verify.py bit-exact against reference.py in dsp_host; not yet run on a unit", @@ -54,8 +54,8 @@ doc="dropouts: how often the level dips and muffles, as on creased or worn tape; 0 none"), Param(b"MIX", D["MIX"], 128, active=True, formatter=P, doc="dry/tape blend; 127 the tape alone, 0 the dry track (5.8 ms late, as the tape is)"), - Param(b"DECK", D["DECK"], 3, active=True, formatter=S, labels=_ref.DECKS, - doc="the machine: STUDIO (a good deck), HOME (a home stereo) or POCKET (a pocket recorder)"), + Param(b"DECK", D["DECK"], 4, active=True, formatter=S, labels=_ref.DECKS, + doc="the machine: STUDIO (a good deck), HOME (a home stereo), POCKET (a pocket recorder) or VHS (an aged videotape's sound)"), Param(b"WIDE", D["WIDE"], 128, active=True, formatter=P, doc="stereo: left and right drift and flutter apart, the right head slightly misaligned"), Param(b"DUST", D["DUST"], 128, active=True, formatter=P, diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index 2a492289a4..db3731b230 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -15,10 +15,10 @@ "presentation": { "label": "CASS", "family": "Tape", - "summary": "An '80s cassette deck on FX1 or FX2: drift and flutter, tape saturation, hiss, crackle, dropouts and glitches, three decks, and tape that wears as it plays.", - "overview": "Cassettebox puts the track on a short tape and plays it back through a moving head. DRFT and FLUT bend the speed, DRIV saturates the tape, and the playback rolls off the top and lifts a bump in the lows. HISS and DUST ride on it, and GAPS and GLCH bring dropouts, speed hiccups and lost head contact. DECK picks the machine: STUDIO, HOME or POCKET. WIDE parts the channels, TONE darkens the top, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape with the dry track, which is read at the tape's centre delay so the two never comb.", + "summary": "An '80s cassette deck, or an aged VHS tape's sound, on FX1 or FX2: drift and flutter, tape saturation, hiss, crackle, dropouts and glitches, and tape that wears as it plays.", + "overview": "Cassettebox puts the track on a short tape and plays it back through a moving head. DRFT and FLUT bend the speed, DRIV saturates the tape, and the playback rolls off the top and lifts a bump in the lows. HISS and DUST ride on it, and GAPS and GLCH bring dropouts, speed hiccups and lost head contact. DECK picks the machine: STUDIO, HOME, POCKET, or VHS for an aged videotape's narrow, warbly sound. WIDE parts the channels, TONE darkens the top, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape with the dry track, which is read at the tape's centre delay so the two never comb.", "highlights": [ - "Three decks: STUDIO, HOME and POCKET", + "Four decks: STUDIO, HOME, POCKET and VHS", "Drift, flutter, saturation and a head bump, with hiss and crackle on the tape", "Dropouts, speed hiccups and lost head contact, as often as you like", "AGE wears the tape as it plays: duller, noisier and less steady over time", @@ -53,7 +53,7 @@ }, { "name": "HISS", - "default": 24, + "default": 16, "count": 128, "doc": "Tape hiss, shaped by the deck; 0 none.", "labels": null @@ -75,12 +75,13 @@ { "name": "DECK", "default": 1, - "count": 3, - "doc": "The machine: STUDIO (a good deck), HOME (a home stereo) or POCKET (a pocket recorder).", + "count": 4, + "doc": "The machine: STUDIO (a good deck), HOME (a home stereo), POCKET (a pocket recorder) or VHS (an aged videotape's sound).", "labels": [ "STUDIO", "HOME", - "POCKET" + "POCKET", + "VHS" ] }, { diff --git a/sdk/drafts/cassettebox/perf.py b/sdk/drafts/cassettebox/perf.py index 7cedb72e91..d2ac42e755 100644 --- a/sdk/drafts/cassettebox/perf.py +++ b/sdk/drafts/cassettebox/perf.py @@ -39,16 +39,16 @@ def static(asm): def moving(blocks, seed=1): - """Every slot swept by triangles an eighth of a turn apart (DECK 0-2 by its steps), everything jumped at random + """Every slot swept by triangles an eighth of a turn apart (DECK 0-3 by its steps), everything jumped at random every 37 blocks.""" rnd = random.Random(seed) rows = {} for b in range(blocks): row = [min(127, 128 - abs(((b + 32 * k) % 256) - 128)) for k in range(12)] - row[R.DECK_SLOT] = (b // 128) % 3 + row[R.DECK_SLOT] = (b // 128) % 4 if b % 37 == 0: row = [rnd.randrange(128) for _ in range(12)] - row[R.DECK_SLOT] = rnd.randrange(3) + row[R.DECK_SLOT] = rnd.randrange(4) rows[b] = tuple(row) return rows diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index 5e0c03ae33..e0fcc088ee 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -52,40 +52,40 @@ def mpy(x, y): DMIN, DMAX = 2 << 12, 509 << 12 # the head's delay, Q11.12 samples DRY_N5 = -D0 # n5 for the dry read (left; right adds 512) -# DECK: STUDIO, HOME, POCKET -DECKS = ("STUDIO", "HOME", "POCKET") -WOWD = tuple(round(s * 4096) for s in (16, 32, 48)) # drift's swing at DRFT 127, Q11.12 samples (wear doubles it) -FLTD = tuple(round(s * 4096) for s in (3, 6, 12)) # flutter's swing at FLUT 127 (wear doubles it) -WOWR = tuple(round(f * 16 / FS * Q) for f in (0.55, 0.85, 1.3)) # drift's cycle a call (Q23) -FLTR = tuple(round(f * 16 / FS * Q) for f in (9.0, 7.0, 11.0)) # flutter's -DRVB = (0x200000, 0x2a0000, 0x3a0000) # the drive at DRIV 0, x 4 (1, 1.31, 1.81) +# DECK: STUDIO, HOME, POCKET, VHS (an aged videotape's linear audio: narrow, slow and deep warble, hissy) +DECKS = ("STUDIO", "HOME", "POCKET", "VHS") +WOWD = tuple(round(s * 4096) for s in (16, 32, 48, 44)) # drift's swing at DRFT 127, Q11.12 samples (wear doubles it) +FLTD = tuple(round(s * 4096) for s in (3, 6, 12, 5)) # flutter's swing at FLUT 127 (wear doubles it) +WOWR = tuple(round(f * 16 / FS * Q) for f in (0.55, 0.85, 1.3, 0.35)) # drift's cycle a call (Q23) +FLTR = tuple(round(f * 16 / FS * Q) for f in (9.0, 7.0, 11.0, 4.5)) # flutter's +DRVB = (0x200000, 0x2a0000, 0x3a0000, 0x2c0000) # the drive at DRIV 0, x 4 (1, 1.31, 1.81, 1.38) DRVR = 0x3c0000 # what DRIV 127 adds (x 4: +1.88) -HISSB = tuple(round(10 ** (db / 20) * Q) for db in (-56, -47, -38)) # hiss at HISS 127 -HFC = tuple(round((1 - math.exp(-2 * math.pi * fc / FS)) * Q) for fc in (15000, 8500, 4200)) # playback's top -BUMP = (0x2ccccd, 0x200000, 0x000000) # the head bump's level (0.35, 0.25, none) +HISSB = tuple(round(10 ** (db / 20) * Q) for db in (-64, -55, -46, -50)) # hiss at HISS 127 (softened: two noise words averaged) +HFC = tuple(round((1 - math.exp(-2 * math.pi * fc / FS)) * Q) for fc in (15000, 8500, 4200, 6000)) # playback's top +BUMP = (0x2ccccd, 0x200000, 0x000000, -0x5ccccd) # the head bump's level (0.35, 0.25, none; VHS cuts the lows, -0.725) CBUMP = round((1 - math.exp(-2 * math.pi * 110 / FS)) * Q) # the bump's corner, 110 Hz THIRD = 0x2aaaab # the cubic's 1/3 TONE_K = 0x600000 # TONE 127 leaves 0.25 of the playback's corner coefficient WEAR_HF = 0x4ccccd # full wear leaves 0.4 of it WEAR_DRV = 0x140000 # full wear adds this to the drive (x 4: +0.63) -GAPP, DUSTP, GLP = 0x0a0000, 0x100000, 0x040000 # each event's chance a call at its knob's 127 (fresh tape) +GAPP, DUSTP, GLP = 0x008000, 0x010000, 0x004000 # each event's chance a call at its knob's 127 (fresh tape), by the knob squared GAP_LEN, GAP_RANGE = 441, 7938 # a dropout: 10 to 190 ms GAP_DEPTH = 0x600000 # it dips to between 1 and 0.25 -CLICK = 0x300000 # crackle's loudest click +CLICK = 0x0c0000 # crackle's loudest pop (before playback's low-pass softens it) CDECAY = 0x4ccccd # a click falls to 0.6 a sample -HICCUP = 64 << 12 # a speed hiccup's largest jump, Q11.12 samples -GL_DECAY = 0x6ccccd # it settles at 0.85 a call +HICCUP = 48 << 12 # a speed hiccup's largest swoop, Q11.12 samples (the head glides to it) +GL_DECAY = 0x6ccccd # its target settles at 0.85 a call; the head follows a 16th of the way CONTACT = 0x0ccccd # a lost head contact leaves 0.1 WIDE_PH = 0x200000 # WIDE 127 puts the right channel's drift a quarter cycle and its flutter half a cycle away AZ = 3 << 12 # and its head 3 samples late (misaligned azimuth) LCG_A, LCG_C = 1664525, 0x6ef35f SNAP = 64 # a filter state or click this close to zero is zero (once a call) -LFSR_TAPS = 0xb40000 +LFSR_TAPS = 0xe10000 # x^24 + x^23 + x^22 + x^17 + 1, maximal: period 2^24 - 1 SEED = 0x2b1d5f KNOBS = ("DRFT", "FLUT", "DRIV", "HISS", "GAPS", "MIX", "DECK", "WIDE", "DUST", "GLCH", "TONE", "AGE") -DEFAULTS = (32, 24, 32, 24, 0, 127, 1, 32, 0, 0, 0, 0) +DEFAULTS = (32, 24, 32, 16, 0, 127, 1, 32, 0, 0, 0, 0) DEAREST = (127, 127, 127, 127, 127, 96, 2, 127, 127, 127, 64, 127) DECK_SLOT = 6 @@ -148,7 +148,7 @@ def call(self, frames, p): x[0x21], x[0x22], x[0x23], x[0x24], x[0x25] = k[0], k[1], k[2], k[3], k[4] m = k[5] x[0x26] = 0x7fffff if m >= 0x7f0000 else m - x[0x27] = min((p.get(0xc, 0) & 0x7f0000) >> 16, 2) # DECK + x[0x27] = min((p.get(0xc, 0) & 0x7f0000) >> 16, 3) # DECK x[0x28] = (p.get(0xc, 0) & 0x00ff00) << 8 # WIDE x[0x29] = p.get(0xd, 0) & 0x7f0000 # DUST x[0x2a] = (p.get(0xd, 0) & 0x00ff00) << 8 # GLCH @@ -179,12 +179,13 @@ def call(self, frames, p): # ---- the speed: drift (a slow sine and a wandering random), flutter, a hiccup; WIDE parts the channels x[0x0a] = (x[0x0a] + WOWR[deck]) & 0x7fffff x[0x0b] = (x[0x0b] + FLTR[deck]) & 0x7fffff - x[0x0c] = hi(((ld(lim(w56((ld(r_dl) - ld(0x400000)) << 1))) - ld(x[0x0c])) >> 5) + ld(x[0x0c])) - x[0x0d] = hi(((ld(lim(w56((ld(r_dr) - ld(0x400000)) << 1))) - ld(x[0x0d])) >> 5) + ld(x[0x0d])) + x[0x0c] = hi(((ld(lim(w56((ld(r_dl) - ld(0x400000)) << 1))) - ld(x[0x0c])) >> 8) + ld(x[0x0c])) + x[0x0d] = hi(((ld(lim(w56((ld(r_dr) - ld(0x400000)) << 1))) - ld(x[0x0d])) >> 8) + ld(x[0x0d])) wide = x[0x28] off = mpy(wide, WIDE_PH) >> 24 drift_r = lim(ld(x[0x0c]) + mpy(lim(ld(x[0x0d]) - ld(x[0x0c])), wide)) - x[0x1f] = lim(mpy(x[0x1f], GL_DECAY)) + x[0x1f] = hi(((ld(x[0x20]) - ld(x[0x1f])) >> 4) + ld(x[0x1f])) + x[0x20] = lim(mpy(x[0x20], GL_DECAY)) for ch, (dw, ds, dr, wph, fph, az) in enumerate(( (0x06, 0x08, x[0x0c], x[0x0a], x[0x0b], 0), (0x07, 0x09, drift_r, x[0x0a] + off, x[0x0b] + 2 * off, lim(mpy(wide, AZ))))): @@ -199,23 +200,23 @@ def call(self, frames, p): if x[0x1d] <= 0: x[0x1d] = 0 x[0x1e] = 0x7fffff - elif r_gap - more(lim(mpy(x[0x25], GAPP)), 3) < 0: + elif r_gap - more(lim(mpy(lim(mpy(x[0x25], x[0x25])), GAPP)), 3) < 0: x[0x1d] = GAP_LEN + hi(mpy(r_glen, GAP_RANGE)) x[0x1e] = lim(ld(0x7fffff) - mpy(r_gdep, GAP_DEPTH)) - if r_gl - more(lim(mpy(x[0x2a], GLP)), 2) < 0: + if r_gl - more(lim(mpy(lim(mpy(x[0x2a], x[0x2a])), GLP)), 2) < 0: if r_gp & 0x400000: - x[0x1f] = lim(mpy(lim(w56((ld(r_gp) - ld(0x600000)) << 2)), HICCUP)) + x[0x20] = lim(mpy(lim(w56((ld(r_gp) - ld(0x600000)) << 2)), HICCUP)) elif x[0x1d] == 0: x[0x1d] = GAP_LEN + hi(mpy(r_gp, 882)) x[0x1e] = CONTACT - if r_dust - more(lim(mpy(x[0x29], DUSTP)), 3) < 0: + if r_dust - more(lim(mpy(lim(mpy(x[0x29], x[0x29])), DUSTP)), 3) < 0: x[0x18] = lim(mpy(lim(w56((ld(r_damp) - ld(0x400000)) << 1)), lim(mpy(x[0x29], CLICK)))) # ---- the runs: each knob's gain walks a 16th of the way a sample (none snaps but at the first call) if x[0x2e] == 0: x[0x12], x[0x16] = drv, x[0x26] x[0x2e] = 1 x[0x13] = lim(w56((ld(drv) - ld(x[0x12])) >> 4)) - x[0x15] = lim(w56((ld(x[0x1e]) - ld(x[0x14])) >> 6)) + x[0x15] = lim(w56((ld(x[0x1e]) - ld(x[0x14])) >> 9)) x[0x17] = lim(w56((ld(x[0x26]) - ld(x[0x16])) >> 4)) # truncating one-poles and the click's decay can stick a few LSB off zero: within SNAP (-102 dBFS) they are zero for wd in (0x0e, 0x0f, 0x10, 0x11, 0x18): @@ -228,7 +229,9 @@ def sample(self, left, right): v = x[0x03] & 0xffffff pr = s24(v) * LCG_A x[0x03] = s24((pr & 0xffffff) + LCG_C) - noise = (s24(x[0x03]), s24(pr >> 24)) + nl, nr = s24(x[0x03]), s24(pr >> 24) + noise = (hi((ld(nl) + ld(x[0x19])) >> 1), hi((ld(nr) + ld(x[0x2f])) >> 1)) # softened: each word with the last + x[0x19], x[0x2f] = nl, nr x[0x12] = lim(ld(x[0x12]) + ld(x[0x13])) x[0x14] = lim(ld(x[0x14]) + ld(x[0x15])) x[0x16] = lim(ld(x[0x16]) + ld(x[0x17])) @@ -246,13 +249,13 @@ def sample(self, left, right): w = hi(mpy(lim(ld(y1) - ld(y0)), f) + ld(y0)) a = lim(w56(mpy(w, x[0x12]) << 2)) # the drive, x 4 s = lim(ld(a) - mpy(lim(mpy(lim(mpy(a, a)), a)), THIRD)) # the tape's cubic - s = lim(ld(s) + mpy(noise[ch], x[0x1c])) # hiss, on the tape + s = lim(ld(s) + mpy(noise[ch], x[0x1c]) + ld(x[0x18])) # hiss and crackle, on the tape lp = 0x0e + ch x[lp] = hi(mpy(lim(ld(s) - ld(x[lp])), x[0x1a]) + ld(x[lp])) # playback's top bp = 0x10 + ch x[bp] = hi(mpy(lim(ld(x[lp]) - ld(x[bp])), CBUMP) + ld(x[bp])) # the head bump t = lim(ld(x[lp]) + mpy(x[bp], x[0x1b])) - t = lim(mpy(t, x[0x14]) + ld(x[0x18])) # dropouts, then crackle + t = lim(mpy(t, x[0x14])) # dropouts out.append(lim(ld(dry) + mpy(lim(ld(t) - ld(dry)), x[0x16]))) x[0x02] = (p + 1) % RING return tuple(out) diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index 0917c87161..5d85a8edde 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -44,12 +44,12 @@ def test_formulas(self): self.assertEqual(R.CBUMP, round((1 - math.exp(-2 * math.pi * 110 / R.FS)) * R.Q)) self.assertEqual(R.HFC[1], round((1 - math.exp(-2 * math.pi * 8500 / R.FS)) * R.Q)) self.assertEqual(R.WOWR[0], round(0.55 * 16 / R.FS * R.Q)) - self.assertEqual(R.HISSB[2], round(10 ** (-38 / 20) * R.Q)) + self.assertEqual(R.HISSB[2], round(10 ** (-46 / 20) * R.Q)) def test_words_fit(self): for w in (R.THIRD, R.TONE_K, R.WEAR_HF, R.WEAR_DRV, R.DRVR, R.CLICK, R.CDECAY, R.GL_DECAY, R.CONTACT, R.GAP_DEPTH, R.CBUMP, R.LCG_C, R.LFSR_TAPS, *R.WOWD, *R.FLTD, *R.WOWR, *R.FLTR, *R.DRVB, *R.HISSB, *R.HFC, *R.BUMP): - self.assertTrue(0 <= w <= 0xffffff, hex(w)) + self.assertTrue(-0x800000 <= w <= 0xffffff, hex(w)) self.assertLess(R.LCG_A, 0x800000) def test_ring_and_delays(self): @@ -58,11 +58,19 @@ def test_ring_and_delays(self): self.assertGreaterEqual(R.DMIN >> 12, 2) # the largest swing never reaches the clamp: full wear doubles drift and flutter; the sine swings the drift, the # wander half of it, then flutter, the largest hiccup and WIDE's azimuth - for d in range(3): + for d in range(len(R.DECKS)): swing = (2 * R.WOWD[d] + R.WOWD[d] + 2 * R.FLTD[d] + R.HICCUP + R.AZ) >> 12 self.assertLessEqual(swing, R.D0 - (R.DMIN >> 12), R.DECKS[d]) self.assertLessEqual(R.D0 + swing, R.DMAX >> 12, R.DECKS[d]) + def test_the_random_source_is_maximal(self): + # a short cycle would make some events impossible: the LFSR must not repeat within a million steps + m = R.Model() + start = m.x[0x05] + for _ in range(1 << 20): + m.rand() + self.assertNotEqual(m.x[0x05], start) + def test_sine(self): for k in range(16): ph = k / 16 @@ -88,12 +96,12 @@ def test_hiss_and_dust_sound_on_silence(self): def test_the_tail_ends_in_exact_silence(self): x = noise(2, 4410) + [0] * (16 * 6000) - for d in range(3): + for d in range(4): l, r, _m = R.render(x, x, {0: knobs((127,) * 12, hiss=0, dust=0, deck=d)}) self.assertFalse(any(l[-22050:] + r[-22050:]), R.DECKS[d]) def test_every_knob_changes_the_sound(self): - x = tone() + x = tone(n=16 * 8000) # long enough for the rarer events (GAPS, GLCH and DUST go by the knob squared) base = R.render(x, x, {0: knobs(QUIET, deck=1)})[:2] for name in R.KNOBS: if name in ("MIX", "DECK"): @@ -103,12 +111,20 @@ def test_every_knob_changes_the_sound(self): def test_decks_differ(self): x = noise(3) - outs = [R.render(x, x, {0: knobs(deck=d)})[0] for d in range(3)] - self.assertEqual(len({tuple(o) for o in outs}), 3) + outs = [R.render(x, x, {0: knobs(deck=d)})[0] for d in range(4)] + self.assertEqual(len({tuple(o) for o in outs}), 4) # POCKET is the darkest: least energy in the sample-to-sample differences hf = [energy([b - a for a, b in zip(o, o[1:])]) / energy(o) for o in outs] self.assertGreater(hf[0], hf[1]) self.assertGreater(hf[1], hf[2]) + # VHS is thin: the least energy below 150 Hz for its level + lows = [] + for o in outs: + import numpy as np + sp = np.abs(np.fft.rfft(np.array(o, float))) ** 2 + f = np.fft.rfftfreq(len(o), 1 / R.FS) + lows.append(sp[f < 150].sum() / sp.sum()) + self.assertEqual(min(range(4), key=lambda d: lows[d]), 3) def test_wide_parts_the_channels(self): x = tone() @@ -143,12 +159,37 @@ def test_dropouts_and_glitches_happen(self): m = R.Model() dips = hiccups = 0 row = R.pblock(knobs(QUIET, gaps=127, glch=127)) - for _ in range(4000): + for _ in range(20000): m.call([(0, 0)] * 16, row) dips += m.x[0x1e] < 0x7fffff - hiccups += m.x[0x1f] != 0 - self.assertGreater(dips, 100) - self.assertGreater(hiccups, 10) + hiccups += abs(m.x[0x1f]) > 4096 # the head more than a sample off its course + self.assertGreater(dips, 1000) + self.assertGreater(hiccups, 20) + + def test_events_are_rare_at_low_settings(self): + # by the knob squared: at 16 a dropout starts about 64 times less often than at 127 + def starts(gaps): + m, n, prev = R.Model(), 0, 0 + row = R.pblock(knobs(QUIET, gaps=gaps)) + for _ in range(40000): + m.call([(0, 0)] * 16, row) + n += m.x[0x1d] > prev + prev = m.x[0x1d] + return n + hi, lo = starts(127), starts(16) + # at 127 a running dropout holds off the next, so the ratio stays under the squared 64 + self.assertGreater(hi, 15 * max(lo, 1)) + + def test_dropouts_glide(self): + # a dip moves the gain at most about a 512th of the way a sample: no click + m = R.Model() + row = R.pblock(knobs(QUIET, gaps=127, glch=127)) + worst = 0 + for _ in range(20000): + before = m.x[0x14] + m.call([(0, 0)] * 16, row) + worst = max(worst, abs(m.x[0x14] - before)) + self.assertLess(worst, 0x7fffff * 16 // 512 + 64) def test_the_head_stays_in_its_line(self): x = noise(4, 16 * 3000) diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py index 20f36e7499..d142013560 100644 --- a/sdk/drafts/cassettebox/verify.py +++ b/sdk/drafts/cassettebox/verify.py @@ -11,7 +11,7 @@ Gates: 1. Every instruction decodes as written (signed mpy/mac x0,y1, no rep, no mpysu/macsu), no label is a - prefix of another (case-blind), the state stays inside X:(r7+$00..$57), and proc returns with every + prefix of another (case-blind), the state stays inside X:(r7+$00..$5f), and proc returns with every modifier register it set to a modulus linear again. 2. Bit for bit the model: every DECK at its defaults, its dearest and with every knob at 127, each knob alone at 127, every knob swept, AGE wearing a tape for 12 s, a 5-frame trig split every block, a knob word carrying an @@ -40,7 +40,7 @@ def _library(): import reference as R # noqa: E402 SOURCE = HERE / "engine.asm" -STATE_LAST = 0x57 +STATE_LAST = 0x5f NAMES = {name.lower(): i for i, name in enumerate(R.KNOBS)} @@ -82,7 +82,7 @@ def main(): and int(re.search(r"\(r[0-7]\+\$([0-9a-fA-F]+)\)", l).group(1), 16) > 0x3f] gate("1 every lua (Rn+aa) offset is within its 7 bits (at most $3f)", not far, "; ".join(far)) offsets = G.state_offsets(text) - gate("1 state inside X:(r7+$00..$57)", bool(offsets) and offsets[-1] <= STATE_LAST, f"(highest ${offsets[-1]:02x})") + gate("1 state inside X:(r7+$00..$5f)", bool(offsets) and offsets[-1] <= STATE_LAST, f"(highest ${offsets[-1]:02x})") # 2. bit for bit the model n = 16 * 3000 From 48ea15a90d835079c616fd21c1740e1dd6d2d30f Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Thu, 3 Dec 2026 22:42:50 -0600 Subject: [PATCH 03/16] Cassettebox: a worn tape degrades on its own (AGE adds hiss, dropouts, crackle and glitches even from 0) Full wear adds the equivalent of HISS 16, GAPS 20, DUST 20 and GLCH 10, growing with the wear; the knobs still add on top and wear still multiplies them. With AGE at 0, silence in is still exact silence out. verify.py bit-exact; test_reference.py 19/19; worst 288.1, 0.92x SPRING REV. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 6 ++--- sdk/drafts/cassettebox/TESTING.md | 6 ++--- sdk/drafts/cassettebox/engine.asm | 22 +++++++++++++++++++ .../cassettebox/evidence/performance.json | 10 ++++----- sdk/drafts/cassettebox/manifest.py | 2 +- sdk/drafts/cassettebox/octamod.module.json | 2 +- sdk/drafts/cassettebox/reference.py | 4 ++++ sdk/drafts/cassettebox/test_reference.py | 18 +++++++++++++-- sdk/drafts/cassettebox/verify.py | 8 +++---- 9 files changed, 59 insertions(+), 19 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 937ad20a25..161d26b60f 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -26,7 +26,7 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pock | Setup | C | DUST | 0-127 | 0 | Crackle: soft pops, an occasional tick at low settings and a steady crackle near 127. | | Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed swoop or a moment of lost head contact. Rare at low settings. | | Setup | E | TONE | 0-127 | 0 | Darkens the top end, as worn heads or a cheap copy do. 0 is the deck's own. | -| Setup | F | AGE | 0-127 | 0 | Wear over time. 0 keeps the tape fresh; higher wears it faster, about 95 s to worn out at 127 and about 3 minutes at 64. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | +| Setup | F | AGE | 0-127 | 0 | Wear over time. 0 keeps the tape fresh; higher wears it faster, about 95 s to worn out at 127, 3 minutes at 64 and 6 at 32. As it wears the top fades, the tape gets grainier, and hiss, dropouts, crackle, glitches and warble grow from what you set. A worn tape also gains some of each on its own, even with those knobs at 0. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | ## Usage @@ -38,13 +38,13 @@ Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to CASSETTEB 2. Raise DRFT and FLUT for a seasick warble, and DRIV to push the tape into saturation. 3. Hold FUNC and press FX1, and try DECK on STUDIO, POCKET and VHS. 4. Raise GAPS, DUST and GLCH for a worn, dropout-prone tape. -5. Turn AGE up and let the pattern play: over a minute or two the tape wears, darker, noisier and less steady. +5. Turn AGE up and let the pattern play: over a minute or two the tape wears, darker, noisier and less steady, with dropouts and crackle creeping in even if you started clean. ## Compatibility and limitations - FX1 or FX2, any audio track. It uses 1,024 words of its slot's buffer. - The tape sits 5.8 ms (256 samples) behind the track, so the speed can sway both ways. The dry signal is read at the same delay, so MIX blends without combing, and MIX 0 is the dry track 5.8 ms late. -- With HISS and DUST at 0, silence in gives exact silence out. With them up, the tape hisses and crackles when the track is quiet, as real tape does. +- With HISS, DUST and AGE at 0, silence in gives exact silence out. With HISS or DUST up, or once AGE has worn the tape, it hisses and crackles when the track is quiet, as real tape does. - Wear isn't saved: the tape starts fresh when the effect is picked or the Part reloads. - It prefers effect id 10, as Fuzzbox, Glitchbox, Loopbox, Grainbox and Midiverb do. Over USB the base gives each its own id; in a card set only one of them fits. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index 6c10901bc3..df005448c9 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -4,11 +4,11 @@ Record what you ran, on which build and which unit, and what you saw. "Not teste ## In dsp_host (not hardware evidence) -`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and an FX1-sized slot. MIX 0 is the track exactly, 256 samples late. With HISS and DUST at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 18/18. +`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and an FX1-sized slot. MIX 0 is the track exactly, 256 samples late. With HISS, DUST and AGE at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 19/19. ## On the unit -1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). Not yet trialled on the unit. +1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). A trial of that build (`--cycles 286 --state 96`), rolled back clean: "Sounds really good!" The author then asked whether the sound degrades as AGE is turned up, and agreed to wear adding its own share of the artifacts: full wear adds the equivalent of HISS 16, GAPS 20, DUST 20 and GLCH 10, so a worn tape degrades even with those knobs at 0. Not yet trialled on the unit. ## Stock flows @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 233 words; measured unsplit 250.9 to 251.4, worst 285.6 (the moving pattern with a split of 1 frame); stress clean (eight instances, per-core peaks 1143.3 and 1073.2, 0 clobbers, 0 stray writes). 0.91x SPRING REV (314.19). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 233 words; measured unsplit 252.1 to 252.6, worst 288.1 (the moving pattern with a split of 1 frame); stress clean (eight instances, per-core peaks 1153.3 and 1080.8, 0 clobbers, 0 stray writes). 0.92x SPRING REV (314.19). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index 1c7b72de40..2d85999bbc 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -204,6 +204,28 @@ cbw1: move a1,x:(r7+$04) move a0,x:(r7+$2d) cbw2: +; ---- wear's own share of the artifacts: HISS, GAPS, DUST and GLCH each gain wear x a base (a worn tape hisses, +; drops out, crackles and glitches even from 0) + move x:(r7+$24),a + move x:(r7+$04),x0 + move #>$100000,y1 + mac x0,y1,a + move a,x:(r7+$24) + move x:(r7+$25),a + move x:(r7+$04),x0 + move #>$140000,y1 + mac x0,y1,a + move a,x:(r7+$25) + move x:(r7+$29),a + move x:(r7+$04),x0 + move #>$140000,y1 + mac x0,y1,a + move a,x:(r7+$29) + move x:(r7+$2a),a + move x:(r7+$04),x0 + move #>$0a0000,y1 + mac x0,y1,a + move a,x:(r7+$2a) ; ---- the deck's figures: the drive, the hiss, the top, the bump, the swings move x:(r7+$27),a add #>$50,a diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index 2e58834a05..b7e90da2e5 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "c0d390345464f9c97eeadacfc05e66cfa1cd69f5c7e826a5f9ad8ce4814f39d5", + "sourceSha256": "b322256fd5c6d42b0e9f85656f0456aa833562a94eea73a5f55fe59d0b76fd50", "kind": "dsp", "cycles": { "unit": "instructions/sample", "static": 233, - "measured": 285.6, + "measured": 288.1, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 233 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 250.9 to 251.4; worst 285.6, the moving pattern with a split of 1 frame, where the per-call work (the knobs, wear, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 233 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 252.1 to 252.6; worst 288.1, the moving pattern with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", @@ -17,7 +17,7 @@ "dearestWorst": 330.94, "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", - "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 285.60, is 0.91x SPRING REV's 314.19 and 0.86x DJ EQ's 330.94; unsplit 251.4 against 257.50 and 293.38. Per sample and channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; one LCG step and three gain runs are shared." + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 288.10, is 0.92x SPRING REV's 314.19 and 0.87x DJ EQ's 330.94; unsplit 252.6 against 257.50 and 293.38. Per sample and channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; one LCG step and three gain runs are shared." }, "stress": { "instancesPerCore": 4, @@ -29,6 +29,6 @@ "dirty": true, "clobbers": 0, "hangs": 0, - "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1143.3 and 1073.2 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1153.3 and 1080.8 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." } } diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index c97326ff2b..a3f76ce896 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -65,7 +65,7 @@ Param(b"TONE", D["TONE"], 128, active=True, formatter=P, doc="darkens the top end, as worn heads or a cheap copy do; 0 the deck's own"), Param(b"AGE", D["AGE"], 128, active=True, formatter=P, - doc="wear over time: 0 keeps the tape fresh; higher wears it faster (about 95 s to worn out at 127)"), + doc="wear over time: 0 keeps the tape fresh; higher wears it faster (about 95 s to worn out at 127): duller, grainier, hissier, with dropouts, crackle and glitches even from 0"), ), dsp=DspSection( diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index db3731b230..4c64adaba7 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -116,7 +116,7 @@ "name": "AGE", "default": 0, "count": 128, - "doc": "Wear over time: 0 keeps the tape fresh; higher wears it faster (about 95 s to worn out at 127).", + "doc": "Wear over time: 0 keeps the tape fresh; higher wears it faster (about 95 s to worn out at 127): duller, grainier, hissier, with dropouts, crackle and glitches even from 0.", "labels": null } ], diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index e0fcc088ee..1a6c21e480 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -80,6 +80,8 @@ def mpy(x, y): WIDE_PH = 0x200000 # WIDE 127 puts the right channel's drift a quarter cycle and its flutter half a cycle away AZ = 3 << 12 # and its head 3 samples late (misaligned azimuth) LCG_A, LCG_C = 1664525, 0x6ef35f +WEAR_BASE = ((0x24, 16 << 16), (0x25, 20 << 16), (0x29, 20 << 16), (0x2a, 10 << 16)) # what full wear adds to +# HISS, GAPS, DUST and GLCH on its own (a worn tape hisses, drops out, crackles and glitches even from 0) SNAP = 64 # a filter state or click this close to zero is zero (once a call) LFSR_TAPS = 0xe10000 # x^24 + x^23 + x^22 + x^17 + 1, maximal: period 2^24 - 1 SEED = 0x2b1d5f @@ -164,6 +166,8 @@ def call(self, frames, p): wv = 0x7fffff << 24 x[0x04], x[0x2d] = wv >> 24, wv & 0xffffff wear = x[0x04] + for kw, base in WEAR_BASE: # wear's own share of the artifacts + x[kw] = lim(ld(x[kw]) + mpy(wear, base)) more = lambda v, n3: lim(ld(v) + n3 * mpy(v, wear)) # v (1 + n3 wear) # ---- the deck's figures this call drv = lim(ld(DRVB[deck]) + mpy(x[0x23], DRVR) + mpy(wear, WEAR_DRV)) diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index 5d85a8edde..0ff646c0a1 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -85,7 +85,7 @@ def test_mix_0_is_the_dry_256_late(self): def test_silence_stays_silent(self): z = [0] * N - l, r, _m = R.render(z, z, {0: knobs((127,) * 12, hiss=0, dust=0, deck=2)}) + l, r, _m = R.render(z, z, {0: knobs((127,) * 12, hiss=0, dust=0, age=0, deck=2)}) self.assertFalse(any(l + r)) def test_hiss_and_dust_sound_on_silence(self): @@ -97,7 +97,7 @@ def test_hiss_and_dust_sound_on_silence(self): def test_the_tail_ends_in_exact_silence(self): x = noise(2, 4410) + [0] * (16 * 6000) for d in range(4): - l, r, _m = R.render(x, x, {0: knobs((127,) * 12, hiss=0, dust=0, deck=d)}) + l, r, _m = R.render(x, x, {0: knobs((127,) * 12, hiss=0, dust=0, age=0, deck=d)}) self.assertFalse(any(l[-22050:] + r[-22050:]), R.DECKS[d]) def test_every_knob_changes_the_sound(self): @@ -144,6 +144,20 @@ def test_age_wears_and_resets(self): m.call([(0, 0)] * 16, R.pblock(knobs(age=0))) self.assertEqual(m.x[0x04], 0) + def test_a_worn_tape_degrades_from_zero(self): + # every artifact knob at 0: once worn, the tape still hisses, crackles, drops out and glitches + m = R.Model() + m.x[0x04] = 0x7fffff + z = [(0, 0)] * 16 + row = R.pblock(knobs(QUIET, age=127)) + sound = dips = 0 + for _ in range(20000): + out = m.call(z, row) + sound += any(l for l, _r in out) + dips += m.x[0x1e] < 0x7fffff + self.assertGreater(sound, 1000) + self.assertGreater(dips, 100) + def test_wear_darkens_and_raises_hiss(self): m = R.Model() fresh = (m.x[0x1a], m.x[0x1c]) diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py index d142013560..5ad684df57 100644 --- a/sdk/drafts/cassettebox/verify.py +++ b/sdk/drafts/cassettebox/verify.py @@ -16,7 +16,7 @@ 2. Bit for bit the model: every DECK at its defaults, its dearest and with every knob at 127, each knob alone at 127, every knob swept, AGE wearing a tape for 12 s, a 5-frame trig split every block, a knob word carrying an LFO's fraction bits, garbage state before init, state from two seeds, and an FX1-sized slot. - 3. MIX 0 is the track exactly, 256 samples late (the tape's centre, so MIX never combs); with HISS and DUST at 0, + 3. MIX 0 is the track exactly, 256 samples late (the tape's centre, so MIX never combs); with HISS, DUST and AGE at 0, silence in is exact silence out and a burst's tail ends in exact silence, at every DECK. 4. The cycle meter, printed for TESTING.md: every DECK at its defaults, its dearest and every knob at 127. """ @@ -136,11 +136,11 @@ def same(name, inst, raw=None, **kw): z = [0] * n x = G.burst(4410, G.FS * 4) for d, dname in enumerate(R.DECKS): - row = knobs(full, deck=d, hiss=0, dust=0) + row = knobs(full, deck=d, hiss=0, dust=0, age=0) (l, r), = G.run(asm, [G.Instance(z, z, knobs=row)], tag="zero").outputs - gate(f"3 {dname}: silence in, silence out with HISS and DUST at 0, everything else at 127", not any(l + r)) + gate(f"3 {dname}: silence in, silence out with HISS, DUST and AGE at 0, everything else at 127", not any(l + r)) (l, r), = G.run(asm, [G.Instance(x, x, knobs=row)], tag="tail").outputs - gate(f"3 {dname}: a burst's tail ends in exact silence, HISS and DUST at 0", not any(l[-G.FS // 2:] + r[-G.FS // 2:])) + gate(f"3 {dname}: a burst's tail ends in exact silence, HISS, DUST and AGE at 0", not any(l[-G.FS // 2:] + r[-G.FS // 2:])) print("[INFO] cycle meter: " + ", ".join(f"{k} {v}" for k, v in meters.items())) print(f"[INFO] dsp_gate.py {G.provenance(HERE)['dsp_gate.py']}") From 32da9d93a748c45a99ef54835b01e9a025cda7b9 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Thu, 3 Dec 2026 23:04:45 -0600 Subject: [PATCH 04/16] Cassettebox: AGE degrades toward the knobs; loud highs dull out and the hiss breathes With AGE above 0 the tape starts clean: DRFT, FLUT, HISS, GAPS, DUST, GLCH and TONE grow toward their knob positions, reach them at half wear and go on to about twice them worn out (the author's choice); AGE 0 applies them at once. A level follower on the left input closes the playback's top with the level, more with DRIV, and lets the hiss breathe (0.35 in silence, whole at full level). Wear's own dropout share 24. verify.py bit-exact; test_reference.py 21/21; worst 298.3, 0.95x SPRING REV. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 10 +- sdk/drafts/cassettebox/TESTING.md | 6 +- sdk/drafts/cassettebox/engine.asm | 120 ++++++++++++------ .../cassettebox/evidence/performance.json | 12 +- sdk/drafts/cassettebox/manifest.py | 8 +- sdk/drafts/cassettebox/octamod.module.json | 12 +- sdk/drafts/cassettebox/reference.py | 33 +++-- sdk/drafts/cassettebox/test_reference.py | 33 ++++- sdk/drafts/cassettebox/verify.py | 6 +- 9 files changed, 165 insertions(+), 75 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 161d26b60f..956b57e7ee 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -17,8 +17,8 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pock |---|---|---|---|---|---| | Main | A | DRFT | 0-127 | 32 | Drift: the tape speed's slow sway and wander. 0 is steady. | | Main | B | FLUT | 0-127 | 24 | Flutter: the fast shimmering wobble. | -| Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder). | -| Main | D | HISS | 0-127 | 16 | Tape hiss, shaped by the deck. | +| Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder). Loud, bright passages dull out more, as real tape does. | +| Main | D | HISS | 0-127 | 16 | Tape hiss, shaped by the deck. It breathes with the track: full under loud passages, down to about a third in the gaps. | | Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. Rare at low settings, frequent near 127. | | Main | F | MIX | 0-127 | 127 | Dry/tape blend. 127 is the tape alone, 0 the dry track. | | Setup | A | DECK | STUDIO, HOME, POCKET, VHS | HOME | The machine: its tone, head bump, saturation, hiss and how steady it runs. STUDIO is clean and steady, HOME duller with more hiss and a little warble, POCKET narrow, hissy, fluttery and crunchy, VHS an aged videotape: thin lows, a muffled top and a slow, deep warble. | @@ -26,7 +26,7 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pock | Setup | C | DUST | 0-127 | 0 | Crackle: soft pops, an occasional tick at low settings and a steady crackle near 127. | | Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed swoop or a moment of lost head contact. Rare at low settings. | | Setup | E | TONE | 0-127 | 0 | Darkens the top end, as worn heads or a cheap copy do. 0 is the deck's own. | -| Setup | F | AGE | 0-127 | 0 | Wear over time. 0 keeps the tape fresh; higher wears it faster, about 95 s to worn out at 127, 3 minutes at 64 and 6 at 32. As it wears the top fades, the tape gets grainier, and hiss, dropouts, crackle, glitches and warble grow from what you set. A worn tape also gains some of each on its own, even with those knobs at 0. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | +| Setup | F | AGE | 0-127 | 0 | Wear over time. At 0 the knobs apply at once. Above 0 the tape starts clean, and drift, flutter, hiss, dropouts, crackle, glitches and TONE grow toward their knob positions, reaching them at half wear and going on to about twice them when worn out. As it wears the top also fades and the tape gets grainier, and a worn tape gains some hiss, dropouts, crackle and glitches of its own, even with those knobs at 0. Half wear takes about 48 s at 127, 1.5 minutes at 64 and 3 minutes at 32. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | ## Usage @@ -38,7 +38,7 @@ Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to CASSETTEB 2. Raise DRFT and FLUT for a seasick warble, and DRIV to push the tape into saturation. 3. Hold FUNC and press FX1, and try DECK on STUDIO, POCKET and VHS. 4. Raise GAPS, DUST and GLCH for a worn, dropout-prone tape. -5. Turn AGE up and let the pattern play: over a minute or two the tape wears, darker, noisier and less steady, with dropouts and crackle creeping in even if you started clean. +5. Set GAPS, DUST and the others where you'd like the tape to end up, then turn AGE up and let the pattern play. The tape starts clean and degrades toward those settings over a minute or two, then keeps getting worse. ## Compatibility and limitations @@ -62,5 +62,5 @@ None yet. ## Develop -- Hear it: `npm run module:dev -- cassettebox --cycles 286 --cycles-kind executed --state 96 --buffer 1024 --slots both`. +- Hear it: `npm run module:dev -- cassettebox --cycles 299 --cycles-kind executed --state 100 --buffer 1024 --slots both`. - Check it: `npm run module:doctor -- --draft cassettebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`, and `python3 -B test_reference.py` tests the model. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index df005448c9..ee1efb9dbf 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -4,11 +4,11 @@ Record what you ran, on which build and which unit, and what you saw. "Not teste ## In dsp_host (not hardware evidence) -`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and an FX1-sized slot. MIX 0 is the track exactly, 256 samples late. With HISS, DUST and AGE at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 19/19. +`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and an FX1-sized slot. MIX 0 is the track exactly, 256 samples late. With HISS, DUST and AGE at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 21/21. ## On the unit -1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). A trial of that build (`--cycles 286 --state 96`), rolled back clean: "Sounds really good!" The author then asked whether the sound degrades as AGE is turned up, and agreed to wear adding its own share of the artifacts: full wear adds the equivalent of HISS 16, GAPS 20, DUST 20 and GLCH 10, so a worn tape degrades even with those knobs at 0. Not yet trialled on the unit. +1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). A trial of that build (`--cycles 286 --state 96`), rolled back clean: "Sounds really good!" The author then asked whether the sound degrades as AGE is turned up, and agreed to wear adding its own share of the artifacts: full wear adds the equivalent of HISS 16, GAPS 20, DUST 20 and GLCH 10, so a worn tape degrades even with those knobs at 0. A 120 s trial of that build, rolled back clean: "This is dope". The author then asked for degradation over time that depends on the knob positions, and chose "destination, then beyond": with AGE above 0 the tape starts clean, DRFT, FLUT, HISS, GAPS, DUST, GLCH and TONE grow toward their knobs, reach them at half wear and go on to about twice them worn out (AGE 0 applies the knobs at once). Asked for anything else that would help the '80s sound, two were added: loud highs dull out (the top closes with the level, more with DRIV) and the hiss breathes with the level (0.35 in silence, whole at full level). Not yet trialled on the unit. ## Stock flows @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 233 words; measured unsplit 252.1 to 252.6, worst 288.1 (the moving pattern with a split of 1 frame); stress clean (eight instances, per-core peaks 1153.3 and 1080.8, 0 clobbers, 0 stray writes). 0.92x SPRING REV (314.19). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 241 words; measured unsplit 260.1 to 260.4, worst 298.3 (the dearest STUDIO setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1195.0 and 1117.6, 0 clobbers, 0 stray writes). 0.95x SPRING REV (314.19). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index 2d85999bbc..62cc287b21 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -25,7 +25,7 @@ ; 10 (r6+$e 16-23), AGE slot 11 (r6+$e 8-15). ; ; State (X, offsets from r7; init clears $00..$5f): -; $00 the ring's base (Y) $02 the pointer r5 $03 the hiss LCG (left's noise) $04 wear (Q23) +; $00 the ring's base (Y) $01 g, the artifacts' share (Q22) $02 the pointer r5 $03 the hiss LCG (left's noise) $04 wear (Q23) ; $05 LFSR $06/$07 each head's d (Q11.12) $08/$09 its step a sample $0a drift's phase $0b flutter's ; $0c/$0d each channel's wander $0e/$0f playback's low-pass states $10/$11 the bump's states ; $12/$13 the drive and its step $14/$15 the dropout gain and its step $16/$17 MIX and its step @@ -35,14 +35,15 @@ ; $30/$31 drift's and flutter's swings (a call), then each channel's softened noise (a sample) $32-$3a nine random words $3b right's noise ; $3c the dry (scratch) $3d WIDE's phase offset $3e right's wander ; $40-$5f DECK's tables, four words each: drift, flutter, their rates, drive, hiss, top, bump -; Nothing above $5f is touched. Every product is the signed mpy/mac x0,y1 +; $60 the call's loudest left input (halved) $61 the level follower (loud highs dull, the hiss breathes) +; Nothing above $63 is touched. Every product is the signed mpy/mac x0,y1 ; form. Labels are cb and two characters, so none is another's prefix. ; CYCLES_FORWARD_BRANCHES init: clr a move r7,r5 move #>$ffffff,m5 - do #$60,>cbi0 + do #$64,>cbi0 move a,x:(r5)+ cbi0: nop @@ -213,7 +214,7 @@ cbw2: move a,x:(r7+$24) move x:(r7+$25),a move x:(r7+$04),x0 - move #>$140000,y1 + move #>$180000,y1 mac x0,y1,a move a,x:(r7+$25) move x:(r7+$29),a @@ -226,6 +227,33 @@ cbw2: move #>$0a0000,y1 mac x0,y1,a move a,x:(r7+$2a) +; g (Q22) at $01: AGE 0 applies the knobs at once (1); above, a fresh tape starts clean and every artifact grows +; with wear (2 wear): its knob at half wear, twice it worn out + move x:(r7+$04),a + move x:(r7+$2c),b + tst b + move #>$400000,x0 + teq x0,a + move a1,x:(r7+$01) +; the level: the call's loudest left input (halved, $60) into a follower ($61), a quarter of the way up, a 64th down + move x:(r7+$60),a + asl #1,a,a + move a,x1 + move x1,a + move x:(r7+$61),x0 + cmp x0,a + ble cbe1 + sub x0,a + asr #2,a,a + bra cbe2 +cbe1: + sub x0,a + asr #6,a,a +cbe2: + add x0,a + move a1,x:(r7+$61) + clr a + move a,x:(r7+$60) ; ---- the deck's figures: the drive, the hiss, the top, the bump, the swings move x:(r7+$27),a add #>$50,a @@ -248,16 +276,17 @@ cbw2: move x:(r7+$24),x0 mpy x0,y1,a move a,x0 - move x:(r7+$04),y1 - move x0,a - mpy x0,y1,b - add b,a - add b,a - add b,a + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a move a,x0 move x0,x:(r7+$1c) - move #>$7fffff,a move x:(r7+$2b),x0 + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a + move a,x0 + move #>$7fffff,a move #>$600000,y1 mpy x0,y1,b sub b,a @@ -281,7 +310,30 @@ cbw2: move a,x0 move x:(r7+$14),y1 mpy x0,y1,a + move a,x1 +; loud highs dull out: the top x (1 - level x DRIV x HFSAT) + move x:(r7+$23),x0 + move #>$600000,y1 + mpy x0,y1,a + move a,y1 + move x:(r7+$61),x0 + mpy x0,y1,b + move #>$7fffff,a + sub b,a + move a,y1 + move x1,x0 + mpy x0,y1,a move a,x:(r7+$1a) +; the hiss breathes: x (BREATH + level x BREATH_R) + move x:(r7+$61),x0 + move #>$533333,y1 + mpy x0,y1,a + move #>$2ccccd,x0 + add x0,a + move a,y1 + move x:(r7+$1c),x0 + mpy x0,y1,a + move a,x:(r7+$1c) move x:(r7+$27),a add #>$5c,a move a1,n1 @@ -296,10 +348,9 @@ cbw2: move x:(r7+$21),x0 mpy x0,y1,a move a,x0 - move x:(r7+$04),y1 - move x0,a - mpy x0,y1,b - add b,a + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a move a,x0 move x0,x:(r7+$30) move x:(r7+$27),a @@ -310,10 +361,9 @@ cbw2: move x:(r7+$22),x0 mpy x0,y1,a move a,x0 - move x:(r7+$04),y1 - move x0,a - mpy x0,y1,b - add b,a + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a move a,x0 move x0,x:(r7+$31) ; ---- nine random words, always in this order: wander L and R, a dropout's test, length and depth, a click's test and size, a glitch's test and kind @@ -494,12 +544,9 @@ cbg1: move #>$008000,y1 mpy x0,y1,a move a,x0 - move x:(r7+$04),y1 - move x0,a - mpy x0,y1,b - add b,a - add b,a - add b,a + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a move a,x0 move x:(r7+$34),a cmp x0,a @@ -526,11 +573,9 @@ cbg3: move #>$004000,y1 mpy x0,y1,a move a,x0 - move x:(r7+$04),y1 - move x0,a - mpy x0,y1,b - add b,a - add b,a + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a move a,x0 move x:(r7+$39),a cmp x0,a @@ -569,12 +614,9 @@ cbg6: move #>$010000,y1 mpy x0,y1,a move a,x0 - move x:(r7+$04),y1 - move x0,a - mpy x0,y1,b - add b,a - add b,a - add b,a + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a move a,x0 move x:(r7+$37),a cmp x0,a @@ -708,6 +750,12 @@ cbn4: move #>$000000,n5 nop move a,y:(r5+n5) + abs a + asr #1,a,a + move x:(r7+$60),x0 + cmp x0,a + tlt x0,a + move a1,x:(r7+$60) move #>$ffff00,n5 nop move y:(r5+n5),a diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index b7e90da2e5..d65cf537b7 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "b322256fd5c6d42b0e9f85656f0456aa833562a94eea73a5f55fe59d0b76fd50", + "sourceSha256": "5b8e40273430cde4614c4fc0b8d629bd3e6d120359ee721b100d6ebf5542d543", "kind": "dsp", "cycles": { "unit": "instructions/sample", - "static": 233, - "measured": 288.1, + "static": 241, + "measured": 298.3, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 233 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 252.1 to 252.6; worst 288.1, the moving pattern with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 241 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 260.1 to 260.4; worst 298.3, the dearest STUDIO setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", @@ -17,7 +17,7 @@ "dearestWorst": 330.94, "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", - "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 288.10, is 0.92x SPRING REV's 314.19 and 0.87x DJ EQ's 330.94; unsplit 252.6 against 257.50 and 293.38. Per sample and channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; one LCG step and three gain runs are shared." + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 298.30, is 0.95x SPRING REV's 314.19 and 0.90x DJ EQ's 330.94; unsplit 260.4 against 257.50 and 293.38. Per sample it tracks the left input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; one LCG step and three gain runs are shared." }, "stress": { "instancesPerCore": 4, @@ -29,6 +29,6 @@ "dirty": true, "clobbers": 0, "hangs": 0, - "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1153.3 and 1080.8 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1195.0 and 1117.6 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." } } diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index a3f76ce896..22e5258ddf 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -4,7 +4,7 @@ DRFT (a slow drift and wander) and FLUT (fast flutter) bend the speed, DRIV saturates the tape, the playback rolls off the top and lifts a head bump, HISS and DUST (crackle) ride on it, GAPS (dropouts) and GLCH (speed hiccups and lost head contact) come and go. DECK picks the machine (STUDIO, HOME, POCKET, or VHS for an aged videotape's sound), WIDE parts the channels, TONE -darkens it, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape +darkens it, and AGE wears the tape while it plays, as a loop recorded over again and again: the tape starts clean and the artifacts grow toward the knobs' positions. MIX blends the tape with the dry track, read at the tape's centre delay (5.8 ms) so the two never comb. verify.py holds engine.asm to reference.py's model bit for bit in dsp_host. Not yet run on a unit. @@ -47,9 +47,9 @@ Param(b"FLUT", D["FLUT"], 128, active=True, formatter=P, doc="flutter: the fast shimmering wobble; 0 none"), Param(b"DRIV", D["DRIV"], 128, active=True, formatter=P, - doc="drive: saturation and compression, the tape pushed harder (and louder)"), + doc="drive: saturation and compression, the tape pushed harder (and louder); loud highs dull out more"), Param(b"HISS", D["HISS"], 128, active=True, formatter=P, - doc="tape hiss, shaped by the deck; 0 none"), + doc="tape hiss, shaped by the deck; it breathes with the track, quieter in the gaps; 0 none"), Param(b"GAPS", D["GAPS"], 128, active=True, formatter=P, doc="dropouts: how often the level dips and muffles, as on creased or worn tape; 0 none"), Param(b"MIX", D["MIX"], 128, active=True, formatter=P, @@ -65,7 +65,7 @@ Param(b"TONE", D["TONE"], 128, active=True, formatter=P, doc="darkens the top end, as worn heads or a cheap copy do; 0 the deck's own"), Param(b"AGE", D["AGE"], 128, active=True, formatter=P, - doc="wear over time: 0 keeps the tape fresh; higher wears it faster (about 95 s to worn out at 127): duller, grainier, hissier, with dropouts, crackle and glitches even from 0"), + doc="wear over time: 0 applies the knobs at once; above, the tape starts clean and the artifacts grow toward the knobs (reached at half wear, about 48 s at 127), then on to twice them worn out"), ), dsp=DspSection( diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index 4c64adaba7..63ad91b0c9 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -19,9 +19,9 @@ "overview": "Cassettebox puts the track on a short tape and plays it back through a moving head. DRFT and FLUT bend the speed, DRIV saturates the tape, and the playback rolls off the top and lifts a bump in the lows. HISS and DUST ride on it, and GAPS and GLCH bring dropouts, speed hiccups and lost head contact. DECK picks the machine: STUDIO, HOME, POCKET, or VHS for an aged videotape's narrow, warbly sound. WIDE parts the channels, TONE darkens the top, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape with the dry track, which is read at the tape's centre delay so the two never comb.", "highlights": [ "Four decks: STUDIO, HOME, POCKET and VHS", - "Drift, flutter, saturation and a head bump, with hiss and crackle on the tape", - "Dropouts, speed hiccups and lost head contact, as often as you like", - "AGE wears the tape as it plays: duller, noisier and less steady over time", + "Drift, flutter, saturation and a head bump; loud highs dull out and the hiss breathes, as on real tape", + "Dropouts, speed swoops, lost head contact and soft crackle, rare at low settings", + "AGE: the tape starts clean and degrades toward your knob settings, then beyond", "Runs on FX1 or FX2" ], "usage": [ @@ -48,14 +48,14 @@ "name": "DRIV", "default": 32, "count": 128, - "doc": "Drive: saturation and compression, the tape pushed harder (and louder).", + "doc": "Drive: saturation and compression, the tape pushed harder (and louder); loud highs dull out more.", "labels": null }, { "name": "HISS", "default": 16, "count": 128, - "doc": "Tape hiss, shaped by the deck; 0 none.", + "doc": "Tape hiss, shaped by the deck; it breathes with the track, quieter in the gaps; 0 none.", "labels": null }, { @@ -116,7 +116,7 @@ "name": "AGE", "default": 0, "count": 128, - "doc": "Wear over time: 0 keeps the tape fresh; higher wears it faster (about 95 s to worn out at 127): duller, grainier, hissier, with dropouts, crackle and glitches even from 0.", + "doc": "Wear over time: 0 applies the knobs at once; above, the tape starts clean and the artifacts grow toward the knobs (reached at half wear, about 48 s at 127), then on to twice them worn out.", "labels": null } ], diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index 1a6c21e480..1ab51a67d2 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -80,8 +80,10 @@ def mpy(x, y): WIDE_PH = 0x200000 # WIDE 127 puts the right channel's drift a quarter cycle and its flutter half a cycle away AZ = 3 << 12 # and its head 3 samples late (misaligned azimuth) LCG_A, LCG_C = 1664525, 0x6ef35f -WEAR_BASE = ((0x24, 16 << 16), (0x25, 20 << 16), (0x29, 20 << 16), (0x2a, 10 << 16)) # what full wear adds to +WEAR_BASE = ((0x24, 16 << 16), (0x25, 24 << 16), (0x29, 20 << 16), (0x2a, 10 << 16)) # what full wear adds to # HISS, GAPS, DUST and GLCH on its own (a worn tape hisses, drops out, crackles and glitches even from 0) +HFSAT = 0x600000 # loud highs dull out: at full level and DRIV 127 the top's coefficient falls to 0.25 +BREATH, BREATH_R = 0x2ccccd, 0x533333 # the hiss breathes with the level: 0.35 in silence, whole at full level SNAP = 64 # a filter state or click this close to zero is zero (once a call) LFSR_TAPS = 0xe10000 # x^24 + x^23 + x^22 + x^17 + 1, maximal: period 2^24 - 1 SEED = 0x2b1d5f @@ -116,7 +118,7 @@ class Model: block p (offset -> word) and returns [(left, right)].""" def __init__(self, base=0x4000): - self.x = [0] * 0x60 + self.x = [0] * 0x64 self.ring = [0] * RING x = self.x x[0x00] = base @@ -168,16 +170,26 @@ def call(self, frames, p): wear = x[0x04] for kw, base in WEAR_BASE: # wear's own share of the artifacts x[kw] = lim(ld(x[kw]) + mpy(wear, base)) - more = lambda v, n3: lim(ld(v) + n3 * mpy(v, wear)) # v (1 + n3 wear) + # g (Q22): with AGE 0 the knobs apply at once (1); above, a fresh tape starts clean and each artifact grows + # with wear (2 wear), reaching its knob at half wear and twice it worn out + x[0x01] = 0x400000 if x[0x2c] == 0 else wear + more = lambda v: lim(w56(mpy(v, x[0x01]) << 1)) # v g + # the level: the call's loudest left input (halved, $60) into a follower ($61), quick up and slow down + p2 = lim(w56(ld(x[0x60]) << 1)) + x[0x61] = hi(((ld(p2) - ld(x[0x61])) >> (2 if p2 > x[0x61] else 6)) + ld(x[0x61])) + x[0x60] = 0 + env = x[0x61] # ---- the deck's figures this call drv = lim(ld(DRVB[deck]) + mpy(x[0x23], DRVR) + mpy(wear, WEAR_DRV)) - hiss = more(lim(mpy(x[0x24], HISSB[deck])), 3) - tonef = lim(ld(0x7fffff) - mpy(x[0x2b], TONE_K)) + hiss = more(lim(mpy(x[0x24], HISSB[deck]))) + tonef = lim(ld(0x7fffff) - mpy(more(x[0x2b]), TONE_K)) wearf = lim(ld(0x7fffff) - mpy(wear, WEAR_HF)) chf = lim(mpy(lim(mpy(lim(mpy(HFC[deck], tonef)), wearf)), x[0x14])) # muffled as a dropout dips + chf = lim(mpy(chf, lim(ld(0x7fffff) - mpy(env, lim(mpy(x[0x23], HFSAT)))))) # loud highs dull out + hiss = lim(mpy(hiss, lim(ld(BREATH) + mpy(env, BREATH_R)))) # the hiss breathes x[0x1a], x[0x1b], x[0x1c] = chf, BUMP[deck], hiss - wowd = more(lim(mpy(x[0x21], WOWD[deck])), 1) - fltd = more(lim(mpy(x[0x22], FLTD[deck])), 1) + wowd = more(lim(mpy(x[0x21], WOWD[deck]))) + fltd = more(lim(mpy(x[0x22], FLTD[deck]))) # ---- nine random words a call, always in this order r_dl, r_dr, r_gap, r_glen, r_gdep, r_dust, r_damp, r_gl, r_gp = (self.rand() for _ in range(9)) # ---- the speed: drift (a slow sine and a wandering random), flutter, a hiccup; WIDE parts the channels @@ -204,16 +216,16 @@ def call(self, frames, p): if x[0x1d] <= 0: x[0x1d] = 0 x[0x1e] = 0x7fffff - elif r_gap - more(lim(mpy(lim(mpy(x[0x25], x[0x25])), GAPP)), 3) < 0: + elif r_gap - more(lim(mpy(lim(mpy(x[0x25], x[0x25])), GAPP))) < 0: x[0x1d] = GAP_LEN + hi(mpy(r_glen, GAP_RANGE)) x[0x1e] = lim(ld(0x7fffff) - mpy(r_gdep, GAP_DEPTH)) - if r_gl - more(lim(mpy(lim(mpy(x[0x2a], x[0x2a])), GLP)), 2) < 0: + if r_gl - more(lim(mpy(lim(mpy(x[0x2a], x[0x2a])), GLP))) < 0: if r_gp & 0x400000: x[0x20] = lim(mpy(lim(w56((ld(r_gp) - ld(0x600000)) << 2)), HICCUP)) elif x[0x1d] == 0: x[0x1d] = GAP_LEN + hi(mpy(r_gp, 882)) x[0x1e] = CONTACT - if r_dust - more(lim(mpy(lim(mpy(x[0x29], x[0x29])), DUSTP)), 3) < 0: + if r_dust - more(lim(mpy(lim(mpy(x[0x29], x[0x29])), DUSTP))) < 0: x[0x18] = lim(mpy(lim(w56((ld(r_damp) - ld(0x400000)) << 1)), lim(mpy(x[0x29], CLICK)))) # ---- the runs: each knob's gain walks a 16th of the way a sample (none snaps but at the first call) if x[0x2e] == 0: @@ -242,6 +254,7 @@ def sample(self, left, right): x[0x18] = lim(mpy(x[0x18], CDECAY)) p = x[0x02] out = [] + x[0x60] = max(x[0x60], abs(left) >> 1) # the level follower's peak (halved: abs(-1) fits) for ch, inp in enumerate((left, right)): o = OFFS[ch] ring[(p + o) % RING] = inp diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index 0ff646c0a1..531df0180e 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -151,14 +151,43 @@ def test_a_worn_tape_degrades_from_zero(self): z = [(0, 0)] * 16 row = R.pblock(knobs(QUIET, age=127)) sound = dips = 0 - for _ in range(20000): + for _ in range(60000): out = m.call(z, row) sound += any(l for l, _r in out) dips += m.x[0x1e] < 0x7fffff self.assertGreater(sound, 1000) self.assertGreater(dips, 100) - def test_wear_darkens_and_raises_hiss(self): + def test_the_knobs_are_the_destination(self): + # AGE above 0: a fresh tape starts clean, reaches the knobs at half wear and twice them worn out + def hiss_at(wear, age): + m = R.Model() + m.x[0x04] = wear + m.call([(0, 0)] * 16, R.pblock(knobs(QUIET, hiss=64, age=age))) + return m.x[0x1c] + at_once = hiss_at(0, 0) + self.assertEqual(hiss_at(0, 1), 0) + # plus the worn tape's own hiss (16 at full wear): (64 + 8) / 64 at half, (64 + 16) x 2 / 64 worn out + self.assertAlmostEqual(hiss_at(0x400000, 1) / at_once, 72 / 64, delta=0.05) + self.assertAlmostEqual(hiss_at(0x7fffff, 1) / at_once, 160 / 64, delta=0.08) + + def test_loud_highs_dull_and_the_hiss_breathes(self): + # a loud input closes the top (more with DRIV) and lifts the hiss; silence opens the top and lets the hiss fall + def figures(level, driv): + m = R.Model() + amp = int(level * R.Q) + row = R.pblock(knobs(QUIET, hiss=64, driv=driv)) + for _ in range(200): + m.call([(amp, amp)] * 16, row) + return m.x[0x1a], m.x[0x1c] + quiet_top, quiet_hiss = figures(0.0, 127) + loud_top, loud_hiss = figures(0.9, 127) + loud_top_clean, _ = figures(0.9, 0) + self.assertLess(loud_top, quiet_top * 0.5) + self.assertEqual(loud_top_clean, quiet_top) + self.assertGreater(loud_hiss, quiet_hiss * 2) + + def test_wear_darkens_and_raises_hiss(self): # noqa: the wear's darkening and hiss's growth m = R.Model() fresh = (m.x[0x1a], m.x[0x1c]) row = R.pblock(knobs(age=127, hiss=64)) diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py index 5ad684df57..938ebfd275 100644 --- a/sdk/drafts/cassettebox/verify.py +++ b/sdk/drafts/cassettebox/verify.py @@ -11,7 +11,7 @@ Gates: 1. Every instruction decodes as written (signed mpy/mac x0,y1, no rep, no mpysu/macsu), no label is a - prefix of another (case-blind), the state stays inside X:(r7+$00..$5f), and proc returns with every + prefix of another (case-blind), the state stays inside X:(r7+$00..$63), and proc returns with every modifier register it set to a modulus linear again. 2. Bit for bit the model: every DECK at its defaults, its dearest and with every knob at 127, each knob alone at 127, every knob swept, AGE wearing a tape for 12 s, a 5-frame trig split every block, a knob word carrying an @@ -40,7 +40,7 @@ def _library(): import reference as R # noqa: E402 SOURCE = HERE / "engine.asm" -STATE_LAST = 0x5f +STATE_LAST = 0x63 NAMES = {name.lower(): i for i, name in enumerate(R.KNOBS)} @@ -82,7 +82,7 @@ def main(): and int(re.search(r"\(r[0-7]\+\$([0-9a-fA-F]+)\)", l).group(1), 16) > 0x3f] gate("1 every lua (Rn+aa) offset is within its 7 bits (at most $3f)", not far, "; ".join(far)) offsets = G.state_offsets(text) - gate("1 state inside X:(r7+$00..$5f)", bool(offsets) and offsets[-1] <= STATE_LAST, f"(highest ${offsets[-1]:02x})") + gate("1 state inside X:(r7+$00..$63)", bool(offsets) and offsets[-1] <= STATE_LAST, f"(highest ${offsets[-1]:02x})") # 2. bit for bit the model n = 16 * 3000 From 7d086cb9f7d7d3b3b54c7187d7297a9efa5bf336 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Thu, 3 Dec 2026 23:21:03 -0600 Subject: [PATCH 05/16] Cassettebox: the code review's fixes (even stereo hiss, no head lurch, own seeds, both channels' level, split-proof drift) - The right channel's hiss was about 20 dB under the left's: two full LCG steps a sample, one a channel. - A sudden DRFT, FLUT, WIDE or DECK change could lurch the head: its step is at most 6 % speed (STEPMAX). - Every instance shared its seeds: the LCG and LFSR are mixed with the instance's buffer base. - The level follower heard only the left input: now the louder of the two. - Trig splits sped the drift and flutter: their phases advance by the call's length. - verify.py's FX1 gate runs at real FX1 bases ($1c00, $3400); stale comments and TESTING figures corrected; the README states AGE leaving 0, low-AGE timescales and the dropouts' reachable depths. verify.py bit-exact; test_reference.py 26/26; worst 313.2, 1.00x SPRING REV. Not yet on a unit. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 6 +- sdk/drafts/cassettebox/TESTING.md | 6 +- sdk/drafts/cassettebox/engine.asm | 70 +++++++++++++++---- .../cassettebox/evidence/performance.json | 12 ++-- sdk/drafts/cassettebox/reference.py | 22 +++--- sdk/drafts/cassettebox/test_reference.py | 38 ++++++++++ sdk/drafts/cassettebox/verify.py | 8 ++- 7 files changed, 122 insertions(+), 40 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 956b57e7ee..52b34fb09d 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -45,7 +45,9 @@ Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to CASSETTEB - FX1 or FX2, any audio track. It uses 1,024 words of its slot's buffer. - The tape sits 5.8 ms (256 samples) behind the track, so the speed can sway both ways. The dry signal is read at the same delay, so MIX blends without combing, and MIX 0 is the dry track 5.8 ms late. - With HISS, DUST and AGE at 0, silence in gives exact silence out. With HISS or DUST up, or once AGE has worn the tape, it hisses and crackles when the track is quiet, as real tape does. -- Wear isn't saved: the tape starts fresh when the effect is picked or the Part reloads. +- Wear isn't saved: the tape starts fresh when the effect is picked or the Part reloads. Moving AGE off 0 starts a clean tape at once, so the knobs' character fades away and then grows back as it wears; at low AGE that takes a long time (half wear in about 1.7 hours at AGE 1). +- Dropouts and glitches glide in and out over about 10 ms, so short ones are gentler than their full depth: a lost head contact dips to roughly a third or half the level rather than near silence. +- With several Cassettebox instances, each has its own hiss and random events (seeded by its slot), so their dropouts don't line up. - It prefers effect id 10, as Fuzzbox, Glitchbox, Loopbox, Grainbox and Midiverb do. Over USB the base gives each its own id; in a card set only one of them fits. ## Tests and measurements @@ -62,5 +64,5 @@ None yet. ## Develop -- Hear it: `npm run module:dev -- cassettebox --cycles 299 --cycles-kind executed --state 100 --buffer 1024 --slots both`. +- Hear it: `npm run module:dev -- cassettebox --cycles 314 --cycles-kind executed --state 100 --buffer 1024 --slots both`. - Check it: `npm run module:doctor -- --draft cassettebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`, and `python3 -B test_reference.py` tests the model. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index ee1efb9dbf..52058ea378 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -4,11 +4,11 @@ Record what you ran, on which build and which unit, and what you saw. "Not teste ## In dsp_host (not hardware evidence) -`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and an FX1-sized slot. MIX 0 is the track exactly, 256 samples late. With HISS, DUST and AGE at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 21/21. +`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and two real FX1 bases ($1c00, $3400: 1024- but not 2048-aligned). MIX 0 is the track exactly, 256 samples late. With HISS, DUST and AGE at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 26/26. ## On the unit -1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). A trial of that build (`--cycles 286 --state 96`), rolled back clean: "Sounds really good!" The author then asked whether the sound degrades as AGE is turned up, and agreed to wear adding its own share of the artifacts: full wear adds the equivalent of HISS 16, GAPS 20, DUST 20 and GLCH 10, so a worn tape degrades even with those knobs at 0. A 120 s trial of that build, rolled back clean: "This is dope". The author then asked for degradation over time that depends on the knob positions, and chose "destination, then beyond": with AGE above 0 the tape starts clean, DRFT, FLUT, HISS, GAPS, DUST, GLCH and TONE grow toward their knobs, reach them at half wear and go on to about twice them worn out (AGE 0 applies the knobs at once). Asked for anything else that would help the '80s sound, two were added: loud highs dull out (the top closes with the level, more with DRIV) and the hiss breathes with the level (0.35 in silence, whole at full level). Not yet trialled on the unit. +1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). A trial of that build (`--cycles 286 --state 96`), rolled back clean: "Sounds really good!" The author then asked whether the sound degrades as AGE is turned up, and agreed to wear adding its own share of the artifacts: full wear adds the equivalent of HISS 16, GAPS 20 (24 since), DUST 20 and GLCH 10, so a worn tape degrades even with those knobs at 0. A 120 s trial of that build, rolled back clean: "This is dope". The author then asked for degradation over time that depends on the knob positions, and chose "destination, then beyond": with AGE above 0 the tape starts clean, DRFT, FLUT, HISS, GAPS, DUST, GLCH and TONE grow toward their knobs, reach them at half wear and go on to about twice them worn out (AGE 0 applies the knobs at once). Asked for anything else that would help the '80s sound, two were added: loud highs dull out (the top closes with the level, more with DRIV) and the hiss breathes with the level (0.35 in silence, whole at full level). Then a fresh-session code review (10 findings), fixed overnight without the author: the right channel's hiss was about 20 dB under the left's (its noise word came from the high half of the generator's product; now two full generator steps, one a channel); a sudden DRFT, FLUT, WIDE or DECK change could lurch the head within one call (its step is now at most 6 % speed); every instance shared its random seeds (now mixed with the instance's buffer base); the level follower heard only the left input (now the louder of the two); trig splits sped the drift and flutter (their phases now advance by the call's length); verify.py's FX1 gate now runs at real FX1 bases. Documented rather than changed, for the author: AGE leaving 0 starts the tape clean at once, and at low AGE half wear is very slow (AGE 1: about 1.7 hours); the 10 ms dropout glide keeps short dips shallower than their targets (a lost contact reaches about 0.3 to 0.5, not 0.1; a hiccup peaks near a quarter of its 48 samples). Not yet trialled on the unit. ## Stock flows @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 241 words; measured unsplit 260.1 to 260.4, worst 298.3 (the dearest STUDIO setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1195.0 and 1117.6, 0 clobbers, 0 stray writes). 0.95x SPRING REV (314.19). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 256 words; measured unsplit 273.6 to 273.9, worst 313.2 (the moving pattern with a split of 1 frame); stress clean (eight instances, per-core peaks 1254.5 and 1174.7, 0 clobbers, 0 stray writes). 1.00x SPRING REV (314.19). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index 62cc287b21..6878e9ac58 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -10,7 +10,7 @@ ; flutter and a decaying hiccup (WIDE parts the right channel's phases, its ; wander and its azimuth). The dry is read 256 behind, so MIX never combs. ; Each channel: the drive (x 4) and a cubic a - a^3/3, hiss on the tape -; (a 24-bit LCG: its low word left, its high word right), playback's top (a +; (a 24-bit LCG, two steps a sample: left's word, then right's; seeded by the base), playback's top (a ; one-pole low-pass, DECK x TONE x wear x a dropout's dip), a head bump (110 Hz ; one-pole, DECK's level), dropouts' gain and crackle, then MIX. ; DECK: STUDIO, HOME, POCKET, VHS (drift, flutter, drive, hiss, top, bump; VHS's @@ -24,7 +24,7 @@ ; (r6+$c 8-15), DUST slot 8 (r6+$d 16-23), GLCH slot 9 (r6+$d 8-15), TONE slot ; 10 (r6+$e 16-23), AGE slot 11 (r6+$e 8-15). ; -; State (X, offsets from r7; init clears $00..$5f): +; State (X, offsets from r7; init clears $00..$63): ; $00 the ring's base (Y) $01 g, the artifacts' share (Q22) $02 the pointer r5 $03 the hiss LCG (left's noise) $04 wear (Q23) ; $05 LFSR $06/$07 each head's d (Q11.12) $08/$09 its step a sample $0a drift's phase $0b flutter's ; $0c/$0d each channel's wander $0e/$0f playback's low-pass states $10/$11 the bump's states @@ -33,9 +33,9 @@ ; $19 left's last noise word $1d a dropout's frames left $1e its gain $1f the hiccup (Q11.12) $20 its target ; $21-$2c DRFT FLUT DRIV HISS GAPS MIX DECK WIDE DUST GLCH TONE AGE $2d wear's low word $2e seeded $2f right's last noise word ; $30/$31 drift's and flutter's swings (a call), then each channel's softened noise (a sample) $32-$3a nine random words $3b right's noise -; $3c the dry (scratch) $3d WIDE's phase offset $3e right's wander +; $3c the dry (scratch) $3d WIDE's phase offset $3e right's wander $3f the drive's target ; $40-$5f DECK's tables, four words each: drift, flutter, their rates, drive, hiss, top, bump -; $60 the call's loudest left input (halved) $61 the level follower (loud highs dull, the hiss breathes) +; $60 the call's loudest input, either channel (halved) $61 the level follower (loud highs dull, the hiss breathes) ; Nothing above $63 is touched. Every product is the signed mpy/mac x0,y1 ; form. Labels are cb and two characters, so none is another's prefix. ; CYCLES_FORWARD_BRANCHES @@ -59,10 +59,14 @@ cbi0: move a,y:(r3)+ cbi1: nop + move x:(r7+$00),a move #>$5a3c1f,x0 - move x0,x:(r7+$03) + eor x0,a + move a1,x:(r7+$03) + move x:(r7+$00),a move #>$2b1d5f,x0 - move x0,x:(r7+$05) + eor x0,a + move a1,x:(r7+$05) move #>$100000,x0 move x0,x:(r7+$06) move x0,x:(r7+$07) @@ -385,12 +389,16 @@ cbe2: move x0,x:(r7+$39) bsr cbrn move x0,x:(r7+$3a) -; ---- drift's and flutter's phases; each channel's wander a 32nd of the way to a new random word +; ---- drift's and flutter's phases (by the call's length); each channel's wander a 256th of the way to a new random word move x:(r7+$27),a add #>$48,a move a1,n1 nop - move x:(r1+n1),x0 + move x:(r1+n1),y1 + move n7,x0 + mpy x0,y1,a + asr #5,a,a + move a0,x0 move x:(r7+$0a),a add x0,a and #>$7fffff,a @@ -399,7 +407,11 @@ cbe2: add #>$4c,a move a1,n1 nop - move x:(r1+n1),x0 + move x:(r1+n1),y1 + move n7,x0 + mpy x0,y1,a + asr #5,a,a + move a0,x0 move x:(r7+$0b),a add x0,a and #>$7fffff,a @@ -478,6 +490,14 @@ cbe2: move x:(r7+$06),x0 sub x0,a asr #4,a,a + move a,x1 + move x1,a + move #>246,x0 + cmp x0,a + tgt x0,a + move #>$ffff0a,x0 + cmp x0,a + tlt x0,a move a,x:(r7+$08) ; ---- right's head target, clamped, and its step a sample (a 16th of the way) move x:(r7+$0a),a @@ -521,6 +541,14 @@ cbe2: move x:(r7+$07),x0 sub x0,a asr #4,a,a + move a,x1 + move x1,a + move #>246,x0 + cmp x0,a + tgt x0,a + move #>$ffff0a,x0 + cmp x0,a + tlt x0,a move a,x:(r7+$09) ; ---- a dropout: one under way counts down, else GAPS (x wear) may start one move x:(r7+$1d),a @@ -632,7 +660,7 @@ cbg6: mpy x0,y1,a move a,x:(r7+$18) cbg7: -; ---- the runs: the first call snaps them; then the drive and MIX walk a 16th of the way a sample, the dropout gain a 64th +; ---- the runs: the first call snaps them; then the drive and MIX walk a 16th of the way a call, the dropout gain a 32nd move x:(r7+$2e),a tst a bne cbf1 @@ -708,25 +736,31 @@ cbn4: move #>$19660d,y1 mpy x0,y1,a asr #1,a,a - move a1,x:(r7+$3b) + move a0,x0 + move x0,b + add #>$6ef35f,b + move b1,x:(r7+$3b) + move b1,x0 + mpy x0,y1,a + asr #1,a,a move a0,x0 move x0,b add #>$6ef35f,b move b1,x:(r7+$03) ; softened: each noise word averaged with the last (left to $30, right to $31) - move x:(r7+$03),a + move x:(r7+$3b),a move x:(r7+$19),x0 add x0,a asr #1,a,a move a1,x:(r7+$30) - move x:(r7+$03),x0 + move x:(r7+$3b),x0 move x0,x:(r7+$19) - move x:(r7+$3b),a + move x:(r7+$03),a move x:(r7+$2f),x0 add x0,a asr #1,a,a move a1,x:(r7+$31) - move x:(r7+$3b),x0 + move x:(r7+$03),x0 move x0,x:(r7+$2f) ; the drive, the dropout gain and MIX step; the click falls move x:(r7+$12),a @@ -849,6 +883,12 @@ cbn4: move #>$000200,n5 nop move a,y:(r5+n5) + abs a + asr #1,a,a + move x:(r7+$60),x0 + cmp x0,a + tlt x0,a + move a1,x:(r7+$60) move #>$000100,n5 nop move y:(r5+n5),a diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index d65cf537b7..b4245863bd 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "5b8e40273430cde4614c4fc0b8d629bd3e6d120359ee721b100d6ebf5542d543", + "sourceSha256": "410e7f366d13f6b52b6c292b42dd4969ab638af1ebb51171fd6bc3252dd9f8b9", "kind": "dsp", "cycles": { "unit": "instructions/sample", - "static": 241, - "measured": 298.3, + "static": 256, + "measured": 313.2, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 241 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 260.1 to 260.4; worst 298.3, the dearest STUDIO setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 256 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 273.6 to 273.9; worst 313.2, the moving pattern with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", @@ -17,7 +17,7 @@ "dearestWorst": 330.94, "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", - "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 298.30, is 0.95x SPRING REV's 314.19 and 0.90x DJ EQ's 330.94; unsplit 260.4 against 257.50 and 293.38. Per sample it tracks the left input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; one LCG step and three gain runs are shared." + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 313.20, is 1.00x SPRING REV's 314.19 and 0.95x DJ EQ's 330.94; unsplit 273.9 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared." }, "stress": { "instancesPerCore": 4, @@ -29,6 +29,6 @@ "dirty": true, "clobbers": 0, "hangs": 0, - "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1195.0 and 1117.6 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1254.5 and 1174.7 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." } } diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index 1ab51a67d2..ec7d5f1592 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -75,7 +75,7 @@ def mpy(x, y): CLICK = 0x0c0000 # crackle's loudest pop (before playback's low-pass softens it) CDECAY = 0x4ccccd # a click falls to 0.6 a sample HICCUP = 48 << 12 # a speed hiccup's largest swoop, Q11.12 samples (the head glides to it) -GL_DECAY = 0x6ccccd # its target settles at 0.85 a call; the head follows a 16th of the way +GL_DECAY = 0x6ccccd # its target settles at 0.85 a call; the head follows a 16th of the way (peaking near a quarter of HICCUP) CONTACT = 0x0ccccd # a lost head contact leaves 0.1 WIDE_PH = 0x200000 # WIDE 127 puts the right channel's drift a quarter cycle and its flutter half a cycle away AZ = 3 << 12 # and its head 3 samples late (misaligned azimuth) @@ -84,6 +84,7 @@ def mpy(x, y): # HISS, GAPS, DUST and GLCH on its own (a worn tape hisses, drops out, crackles and glitches even from 0) HFSAT = 0x600000 # loud highs dull out: at full level and DRIV 127 the top's coefficient falls to 0.25 BREATH, BREATH_R = 0x2ccccd, 0x533333 # the hiss breathes with the level: 0.35 in silence, whole at full level +STEPMAX = 246 # the head's step a sample at most, Q11.12 (6 % speed): a sudden knob change glides SNAP = 64 # a filter state or click this close to zero is zero (once a call) LFSR_TAPS = 0xe10000 # x^24 + x^23 + x^22 + x^17 + 1, maximal: period 2^24 - 1 SEED = 0x2b1d5f @@ -123,8 +124,8 @@ def __init__(self, base=0x4000): x = self.x x[0x00] = base x[0x02] = 0 # the write index (r5 - base) - x[0x03] = 0x5a3c1f # the hiss generator - x[0x05] = SEED + x[0x03] = s24(0x5a3c1f ^ base) # the hiss generator and the LFSR, each instance its own (by its buffer's base) + x[0x05] = s24(SEED ^ base) x[0x06] = x[0x07] = D0 << 12 x[0x12] = 0 x[0x14] = x[0x1e] = 0x7fffff @@ -193,8 +194,8 @@ def call(self, frames, p): # ---- nine random words a call, always in this order r_dl, r_dr, r_gap, r_glen, r_gdep, r_dust, r_damp, r_gl, r_gp = (self.rand() for _ in range(9)) # ---- the speed: drift (a slow sine and a wandering random), flutter, a hiccup; WIDE parts the channels - x[0x0a] = (x[0x0a] + WOWR[deck]) & 0x7fffff - x[0x0b] = (x[0x0b] + FLTR[deck]) & 0x7fffff + x[0x0a] = (x[0x0a] + ((WOWR[deck] * n) >> 4)) & 0x7fffff # by the call's length: a split doesn't speed it + x[0x0b] = (x[0x0b] + ((FLTR[deck] * n) >> 4)) & 0x7fffff x[0x0c] = hi(((ld(lim(w56((ld(r_dl) - ld(0x400000)) << 1))) - ld(x[0x0c])) >> 8) + ld(x[0x0c])) x[0x0d] = hi(((ld(lim(w56((ld(r_dr) - ld(0x400000)) << 1))) - ld(x[0x0d])) >> 8) + ld(x[0x0d])) wide = x[0x28] @@ -209,7 +210,7 @@ def call(self, frames, p): a = a + ld(x[0x1f]) + ld(az) t = lim(a) t = max(DMIN, min(DMAX, t)) - x[ds] = lim(w56((ld(t) - ld(x[dw])) >> 4)) + x[ds] = max(-STEPMAX, min(STEPMAX, lim(w56((ld(t) - ld(x[dw])) >> 4)))) # the head never lurches # ---- events: a dropout (GAPS), a glitch (GLCH: a hiccup or a lost contact), a click (DUST) if x[0x1d] > 0: x[0x1d] -= n @@ -242,10 +243,9 @@ def call(self, frames, p): def sample(self, left, right): x, ring = self.x, self.ring - v = x[0x03] & 0xffffff - pr = s24(v) * LCG_A - x[0x03] = s24((pr & 0xffffff) + LCG_C) - nl, nr = s24(x[0x03]), s24(pr >> 24) + v1 = s24(((s24(x[0x03]) * LCG_A) & 0xffffff) + LCG_C) # two LCG steps: left's word, then right's + x[0x03] = s24(((v1 * LCG_A) & 0xffffff) + LCG_C) + nl, nr = v1, x[0x03] noise = (hi((ld(nl) + ld(x[0x19])) >> 1), hi((ld(nr) + ld(x[0x2f])) >> 1)) # softened: each word with the last x[0x19], x[0x2f] = nl, nr x[0x12] = lim(ld(x[0x12]) + ld(x[0x13])) @@ -254,7 +254,7 @@ def sample(self, left, right): x[0x18] = lim(mpy(x[0x18], CDECAY)) p = x[0x02] out = [] - x[0x60] = max(x[0x60], abs(left) >> 1) # the level follower's peak (halved: abs(-1) fits) + x[0x60] = max(x[0x60], abs(left) >> 1, abs(right) >> 1) # the level follower's peak (halved: abs(-1) fits) for ch, inp in enumerate((left, right)): o = OFFS[ch] ring[(p + o) % RING] = inp diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index 531df0180e..5bfd19ccb2 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -187,6 +187,44 @@ def figures(level, driv): self.assertEqual(loud_top_clean, quiet_top) self.assertGreater(loud_hiss, quiet_hiss * 2) + def test_the_hiss_is_even_left_and_right(self): + z = [0] * N + l, r, _m = R.render(z, z, {0: knobs(QUIET, hiss=127)}) + self.assertAlmostEqual(energy(l) / energy(r), 1, delta=0.15) + + def test_each_instance_its_own_randomness(self): + z = [0] * N + a = R.render(z, z, {0: knobs(QUIET, hiss=64)}, base=0x4000)[0] + b = R.render(z, z, {0: knobs(QUIET, hiss=64)}, base=0x1c00)[0] + self.assertNotEqual(a, b) + + def test_a_sudden_knob_never_lurches_the_head(self): + # DRFT 0 to 127 on POCKET in one call: the head moves at most STEPMAX a sample + m = R.Model() + for blk in range(600): + row = R.pblock(knobs(QUIET, deck=2, drft=0 if blk < 300 else 127, flut=0 if blk < 300 else 127)) + before = (m.x[0x06], m.x[0x07]) + m.call([(0, 0)] * 16, row) + for ch in (0, 1): + self.assertLessEqual(abs(m.x[0x06 + ch] - before[ch]), 16 * R.STEPMAX) + + def test_splits_do_not_speed_the_drift(self): + m1, m2 = R.Model(), R.Model() + row = R.pblock(knobs(QUIET, drft=64)) + for _ in range(200): + m1.call([(0, 0)] * 16, row) + m2.call([(0, 0)] * 5, row) + m2.call([(0, 0)] * 11, row) + self.assertLess(abs(m1.x[0x0a] - m2.x[0x0a]), 200 * 2) + + def test_the_level_follower_hears_both_channels(self): + m = R.Model() + row = R.pblock(knobs(QUIET, hiss=64, driv=127)) + amp = int(0.9 * R.Q) + for _ in range(200): + m.call([(0, amp)] * 16, row) + self.assertGreater(m.x[0x61], 0x600000) + def test_wear_darkens_and_raises_hiss(self): # noqa: the wear's darkening and hiss's growth m = R.Model() fresh = (m.x[0x1a], m.x[0x1c]) diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py index 938ebfd275..418c28348f 100644 --- a/sdk/drafts/cassettebox/verify.py +++ b/sdk/drafts/cassettebox/verify.py @@ -15,7 +15,7 @@ modifier register it set to a modulus linear again. 2. Bit for bit the model: every DECK at its defaults, its dearest and with every knob at 127, each knob alone at 127, every knob swept, AGE wearing a tape for 12 s, a 5-frame trig split every block, a knob word carrying an - LFO's fraction bits, garbage state before init, state from two seeds, and an FX1-sized slot. + LFO's fraction bits, garbage state before init, state from two seeds, and two real FX1 bases. 3. MIX 0 is the track exactly, 256 samples late (the tape's centre, so MIX never combs); with HISS, DUST and AGE at 0, silence in is exact silence out and a burst's tail ends in exact silence, at every DECK. 4. The cycle meter, printed for TESTING.md: every DECK at its defaults, its dearest and every knob at 127. @@ -126,8 +126,10 @@ def same(name, inst, raw=None, **kw): same("2 garbage state before init", G.Instance(nl, nr, rows=rows), dirty=0x5a5a5a) gate.two_seeds("2 the same output from state filled with two seeds: nothing read before it is written", asm, [G.Instance(nl, nr, rows=rows)]) - same("2 an FX1-sized slot (base $2000) runs the same tape", G.Instance(nl, nr, rows=rows), - image=asm.image(x={G.ALLOC_AT: 0x2000}, name="fx1"), base=0x2000) + # 0x1c00 and 0x3400 are real FX1 bases aligned to 1024 but not 2048: the ring's modulus must hold there + for fx1 in (0x1c00, 0x3400): + same(f"2 an FX1 slot at ${fx1:04x} runs the same tape", G.Instance(nl, nr, rows=rows), + image=asm.image(x={G.ALLOC_AT: fx1}, name=f"fx1-{fx1:x}"), base=fx1) # 3. the dry and silence (l, r), = G.run(asm, [G.Instance(nl, nr, knobs=knobs(mix=0))], tag="dry").outputs From be3376ac0a7e92f093d947edb2ddbe82cd19cf17 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 15:42:39 -0600 Subject: [PATCH 06/16] Cassettebox: a minimum wear speed, a near-silent lost contact, a pinch roller's thump, a worn tape quieter and thinner, dropouts that lose their highs first Wear runs at AGE + 16 (AGE 1: half wear in about 6 minutes, AGE 127 in about 43 s). A lost head contact glides eight times faster and reaches near its 0.1. Once a turn (about 0.9 Hz) a short bump in speed and level, from FLUT (x g) and wear. Full wear leaves the level 0.7 and the head bump 0.3 lower. A dropout's top follows its gain squared. verify.py bit for bit; test_reference.py 29/29; worst 324.4 (1.03x SPRING REV), stamped. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 16 +-- sdk/drafts/cassettebox/TESTING.md | 2 +- sdk/drafts/cassettebox/engine.asm | 107 ++++++++++++++++-- .../cassettebox/evidence/performance.json | 10 +- sdk/drafts/cassettebox/manifest.py | 4 +- sdk/drafts/cassettebox/octamod.module.json | 4 +- sdk/drafts/cassettebox/reference.py | 33 ++++-- sdk/drafts/cassettebox/test_reference.py | 59 ++++++++-- 8 files changed, 193 insertions(+), 42 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 52b34fb09d..f99fdd2fc7 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -16,17 +16,17 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pock | Page | Knob | Name | Range | Default | What it does | |---|---|---|---|---|---| | Main | A | DRFT | 0-127 | 32 | Drift: the tape speed's slow sway and wander. 0 is steady. | -| Main | B | FLUT | 0-127 | 24 | Flutter: the fast shimmering wobble. | +| Main | B | FLUT | 0-127 | 24 | Flutter: the fast shimmering wobble, and a worn pinch roller's faint thump in speed and level about once a second. | | Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder). Loud, bright passages dull out more, as real tape does. | | Main | D | HISS | 0-127 | 16 | Tape hiss, shaped by the deck. It breathes with the track: full under loud passages, down to about a third in the gaps. | -| Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. Rare at low settings, frequent near 127. | +| Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. Each one muffles before it dips and comes back bright last. Rare at low settings, frequent near 127. | | Main | F | MIX | 0-127 | 127 | Dry/tape blend. 127 is the tape alone, 0 the dry track. | | Setup | A | DECK | STUDIO, HOME, POCKET, VHS | HOME | The machine: its tone, head bump, saturation, hiss and how steady it runs. STUDIO is clean and steady, HOME duller with more hiss and a little warble, POCKET narrow, hissy, fluttery and crunchy, VHS an aged videotape: thin lows, a muffled top and a slow, deep warble. | | Setup | B | WIDE | 0-127 | 32 | Stereo: left and right drift and flutter apart, and the right head sits slightly misaligned. | | Setup | C | DUST | 0-127 | 0 | Crackle: soft pops, an occasional tick at low settings and a steady crackle near 127. | -| Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed swoop or a moment of lost head contact. Rare at low settings. | +| Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed swoop, or a moment of lost head contact that drops the sound nearly out. Rare at low settings. | | Setup | E | TONE | 0-127 | 0 | Darkens the top end, as worn heads or a cheap copy do. 0 is the deck's own. | -| Setup | F | AGE | 0-127 | 0 | Wear over time. At 0 the knobs apply at once. Above 0 the tape starts clean, and drift, flutter, hiss, dropouts, crackle, glitches and TONE grow toward their knob positions, reaching them at half wear and going on to about twice them when worn out. As it wears the top also fades and the tape gets grainier, and a worn tape gains some hiss, dropouts, crackle and glitches of its own, even with those knobs at 0. Half wear takes about 48 s at 127, 1.5 minutes at 64 and 3 minutes at 32. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | +| Setup | F | AGE | 0-127 | 0 | Wear over time. At 0 the knobs apply at once. Above 0 the tape starts clean, and drift, flutter, hiss, dropouts, crackle, glitches and TONE grow toward their knob positions, reaching them at half wear and going on to about twice them when worn out. As it wears the top fades, the tape gets grainier, quieter (about 3 dB when worn out) and thinner in the lows, the pinch roller thumps harder, and a worn tape gains some hiss, dropouts, crackle and glitches of its own, even with those knobs at 0. Half wear takes about 43 s at 127, 1.3 minutes at 64, 2 minutes at 32 and 6 minutes at 1. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | ## Usage @@ -38,15 +38,15 @@ Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to CASSETTEB 2. Raise DRFT and FLUT for a seasick warble, and DRIV to push the tape into saturation. 3. Hold FUNC and press FX1, and try DECK on STUDIO, POCKET and VHS. 4. Raise GAPS, DUST and GLCH for a worn, dropout-prone tape. -5. Set GAPS, DUST and the others where you'd like the tape to end up, then turn AGE up and let the pattern play. The tape starts clean and degrades toward those settings over a minute or two, then keeps getting worse. +5. Set GAPS, DUST and the others where you'd like the tape to end up, then turn AGE up and let the pattern play. The tape starts clean and degrades toward those settings over a minute or two (up to about 6 minutes at low AGE), then keeps getting worse. ## Compatibility and limitations - FX1 or FX2, any audio track. It uses 1,024 words of its slot's buffer. - The tape sits 5.8 ms (256 samples) behind the track, so the speed can sway both ways. The dry signal is read at the same delay, so MIX blends without combing, and MIX 0 is the dry track 5.8 ms late. - With HISS, DUST and AGE at 0, silence in gives exact silence out. With HISS or DUST up, or once AGE has worn the tape, it hisses and crackles when the track is quiet, as real tape does. -- Wear isn't saved: the tape starts fresh when the effect is picked or the Part reloads. Moving AGE off 0 starts a clean tape at once, so the knobs' character fades away and then grows back as it wears; at low AGE that takes a long time (half wear in about 1.7 hours at AGE 1). -- Dropouts and glitches glide in and out over about 10 ms, so short ones are gentler than their full depth: a lost head contact dips to roughly a third or half the level rather than near silence. +- Wear isn't saved: the tape starts fresh when the effect is picked or the Part reloads. Moving AGE off 0 starts a clean tape at once, so the knobs' character fades away and then grows back as it wears (half wear in about 6 minutes even at AGE 1). +- Dropouts glide in and out over about 10 ms, so short ones are gentler than their full depth. A lost head contact drops out faster (about 1.5 ms) and reaches near silence, then glides back. - With several Cassettebox instances, each has its own hiss and random events (seeded by its slot), so their dropouts don't line up. - It prefers effect id 10, as Fuzzbox, Glitchbox, Loopbox, Grainbox and Midiverb do. Over USB the base gives each its own id; in a card set only one of them fits. @@ -64,5 +64,5 @@ None yet. ## Develop -- Hear it: `npm run module:dev -- cassettebox --cycles 314 --cycles-kind executed --state 100 --buffer 1024 --slots both`. +- Hear it: `npm run module:dev -- cassettebox --cycles 325 --cycles-kind executed --state 100 --buffer 1024 --slots both`. - Check it: `npm run module:doctor -- --draft cassettebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`, and `python3 -B test_reference.py` tests the model. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index 52058ea378..16bdeef1bc 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 256 words; measured unsplit 273.6 to 273.9, worst 313.2 (the moving pattern with a split of 1 frame); stress clean (eight instances, per-core peaks 1254.5 and 1174.7, 0 clobbers, 0 stray writes). 1.00x SPRING REV (314.19). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 256 words; measured unsplit 279.1 to 279.5, worst 324.4 (the dearest POCKET setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1299.5 and 1208.4, 0 clobbers, 0 stray writes). 1.03x SPRING REV (314.19), 0.98x DJ EQ (330.94). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index 6878e9ac58..12b20bb576 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -15,9 +15,10 @@ ; one-pole, DECK's level), dropouts' gain and crackle, then MIX. ; DECK: STUDIO, HOME, POCKET, VHS (drift, flutter, drive, hiss, top, bump; VHS's ; negative bump cuts the lows). -; AGE: 0 keeps the tape fresh; above it wears AGE << 6 a call (48-bit), full in -; about 95 s at 127; wear lifts the drive, darkens the top and multiplies the -; drift, flutter, hiss, dropouts, glitches and crackle. +; AGE: 0 keeps the tape fresh; above it wears (AGE + 16) << 6 a call (48-bit); +; wear lifts the drive, darkens the top, lowers the level and the bump, and +; scales the drift, flutter, hiss, dropouts, glitches, crackle and the pinch +; roller's thump (once a turn, about 0.9 Hz, a bump in speed and level). ; ; Knobs (value<<16): page 1 DRFT r6+0, FLUT r6+1, DRIV r6+2, HISS r6+3, GAPS ; r6+4, MIX r6+5; page 2 DECK slot 6 (r6+$c bits 16-23, 0-3), WIDE slot 7 @@ -36,6 +37,7 @@ ; $3c the dry (scratch) $3d WIDE's phase offset $3e right's wander $3f the drive's target ; $40-$5f DECK's tables, four words each: drift, flutter, their rates, drive, hiss, top, bump ; $60 the call's loudest input, either channel (halved) $61 the level follower (loud highs dull, the hiss breathes) +; $62 the pinch roller's phase $63 the level (the roller's dip and wear's sag; it scales the dropout gain) ; Nothing above $63 is touched. Every product is the signed mpy/mac x0,y1 ; form. Labels are cb and two characters, so none is another's prefix. ; CYCLES_FORWARD_BRANCHES @@ -201,6 +203,7 @@ proc: cbw1: move x:(r7+$04),a move x:(r7+$2d),a0 + add #>$100000,b asr #18,b,b add b,a move #>$7fffff,b @@ -258,6 +261,63 @@ cbe2: move a1,x:(r7+$61) clr a move a,x:(r7+$60) +; ---- the pinch roller: its phase (by the call's length); a pulse an eighth of a turn wide ($3c); the speed bump +; ($3b, from FLUT x g and wear) and the level ($63: 1 less the bump's dip and wear's sag) + move #>$000ab3,y1 + move n7,x0 + mpy x0,y1,a + asr #5,a,a + move a0,x0 + move x:(r7+$62),a + add x0,a + and #>$7fffff,a + move a1,x:(r7+$62) + bsr cbtr + move x0,a + sub #>$600000,a + asl #2,a,a + clr b + cmp b,a + tlt b,a + move a,x:(r7+$3c) + move x:(r7+$22),x0 + move #>$00c000,y1 + mpy x0,y1,a + move a,x0 + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a + move a,x0 + move x0,b + move x:(r7+$04),x0 + move #>$008000,y1 + mac x0,y1,b + move b,y1 + move x:(r7+$3c),x0 + mpy x0,y1,a + move a,x:(r7+$3b) + move x:(r7+$22),x0 + move #>$07ae14,y1 + mpy x0,y1,a + move a,x0 + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a + move a,x0 + move x0,b + move x:(r7+$04),x0 + move #>$0a3d71,y1 + mac x0,y1,b + move b,y1 + move x:(r7+$3c),x0 + mpy x0,y1,b + move #>$7fffff,a + sub b,a + move x:(r7+$04),x0 + move #>$266666,y1 + mpy x0,y1,b + sub b,a + move a,x:(r7+$63) ; ---- the deck's figures: the drive, the hiss, the top, the bump, the swings move x:(r7+$27),a add #>$50,a @@ -312,7 +372,14 @@ cbe2: move x:(r7+$3d),y1 mpy x0,y1,a move a,x0 - move x:(r7+$14),y1 +; a dropout muffles before it dips: x f twice, f = the dropout gain without the level's sag + move x:(r7+$14),b + add #>$7fffff,b + move x:(r7+$63),y1 + sub y1,b + move b,y1 + mpy x0,y1,a + move a,x0 mpy x0,y1,a move a,x1 ; loud highs dull out: the top x (1 - level x DRIV x HFSAT) @@ -343,7 +410,12 @@ cbe2: move a1,n1 nop move x:(r1+n1),x0 - move x0,x:(r7+$1b) + move x0,a + move x:(r7+$04),x0 + move #>$266666,y1 + mpy x0,y1,b + sub b,a + move a,x:(r7+$1b) move x:(r7+$27),a add #>$40,a move a1,n1 @@ -459,6 +531,10 @@ cbe2: move #>$6ccccd,y1 mpy x0,y1,a move a,x:(r7+$20) + move x:(r7+$1f),a + move x:(r7+$3b),x0 + add x0,a + move a,x:(r7+$3b) ; ---- left's head target, clamped, and its step a sample (a 16th of the way) move x:(r7+$0a),a bsr cbsn @@ -473,7 +549,7 @@ cbe2: bsr cbtr move x:(r7+$31),y1 mac x0,y1,b - move x:(r7+$1f),x0 + move x:(r7+$3b),x0 move x0,a add a,b move #>$100000,x0 @@ -518,7 +594,7 @@ cbe2: bsr cbtr move x:(r7+$31),y1 mac x0,y1,b - move x:(r7+$1f),x0 + move x:(r7+$3b),x0 move x0,a add a,b move x:(r7+$28),x0 @@ -660,7 +736,8 @@ cbg6: mpy x0,y1,a move a,x:(r7+$18) cbg7: -; ---- the runs: the first call snaps them; then the drive and MIX walk a 16th of the way a call, the dropout gain a 32nd +; ---- the runs: the first call snaps them; then the drive and MIX walk a 16th of the way a call, the dropout gain +; (x the level) a 32nd, a lost contact a quarter move x:(r7+$2e),a tst a bne cbf1 @@ -676,10 +753,20 @@ cbf1: sub x0,a asr #4,a,a move a,x:(r7+$13) - move x:(r7+$1e),a + move x:(r7+$1e),x0 + move x:(r7+$63),y1 + mpy x0,y1,a + move a,x1 + move x1,a move x:(r7+$14),x0 sub x0,a - asr #9,a,a + move x:(r7+$1e),b + move #>$0ccccd,y1 + cmp y1,b + beq cbf2 + asr #3,a,a +cbf2: + asr #6,a,a move a,x:(r7+$15) move x:(r7+$26),a move x:(r7+$16),x0 diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index b4245863bd..cd0995e641 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "410e7f366d13f6b52b6c292b42dd4969ab638af1ebb51171fd6bc3252dd9f8b9", + "sourceSha256": "713b297fe860b6e08dc7e6bf14545feb79d06111a8daf11c7bb20e74c68155d9", "kind": "dsp", "cycles": { "unit": "instructions/sample", "static": 256, - "measured": 313.2, + "measured": 324.4, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 256 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 273.6 to 273.9; worst 313.2, the moving pattern with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 256 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 279.1 to 279.5; worst 324.4, the dearest POCKET setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", @@ -17,7 +17,7 @@ "dearestWorst": 330.94, "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", - "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 313.20, is 1.00x SPRING REV's 314.19 and 0.95x DJ EQ's 330.94; unsplit 273.9 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared." + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 324.40, is 1.03x SPRING REV's 314.19 and 0.98x DJ EQ's 330.94 (the extra over SPRING REV is per-call work, wear, the pinch roller and the events, which a trig split of 1 frame runs twice a block); unsplit 279.5 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared." }, "stress": { "instancesPerCore": 4, @@ -29,6 +29,6 @@ "dirty": true, "clobbers": 0, "hangs": 0, - "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1254.5 and 1174.7 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1299.5 and 1208.4 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." } } diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index 22e5258ddf..761bdae7ad 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -45,7 +45,7 @@ Param(b"DRFT", D["DRFT"], 128, active=True, formatter=P, doc="drift: the tape speed's slow wander and sway; 0 steady"), Param(b"FLUT", D["FLUT"], 128, active=True, formatter=P, - doc="flutter: the fast shimmering wobble; 0 none"), + doc="flutter: the fast shimmering wobble and a worn pinch roller's thump; 0 none"), Param(b"DRIV", D["DRIV"], 128, active=True, formatter=P, doc="drive: saturation and compression, the tape pushed harder (and louder); loud highs dull out more"), Param(b"HISS", D["HISS"], 128, active=True, formatter=P, @@ -65,7 +65,7 @@ Param(b"TONE", D["TONE"], 128, active=True, formatter=P, doc="darkens the top end, as worn heads or a cheap copy do; 0 the deck's own"), Param(b"AGE", D["AGE"], 128, active=True, formatter=P, - doc="wear over time: 0 applies the knobs at once; above, the tape starts clean and the artifacts grow toward the knobs (reached at half wear, about 48 s at 127), then on to twice them worn out"), + doc="wear over time: 0 applies the knobs at once; above, the tape starts clean and the artifacts grow toward the knobs (reached at half wear: about 43 s at 127, 6 minutes at 1), then on to twice them worn out, quieter and thinner"), ), dsp=DspSection( diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index 63ad91b0c9..a53e1d5567 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -41,7 +41,7 @@ "name": "FLUT", "default": 24, "count": 128, - "doc": "Flutter: the fast shimmering wobble; 0 none.", + "doc": "Flutter: the fast shimmering wobble and a worn pinch roller's thump; 0 none.", "labels": null }, { @@ -116,7 +116,7 @@ "name": "AGE", "default": 0, "count": 128, - "doc": "Wear over time: 0 applies the knobs at once; above, the tape starts clean and the artifacts grow toward the knobs (reached at half wear, about 48 s at 127), then on to twice them worn out.", + "doc": "Wear over time: 0 applies the knobs at once; above, the tape starts clean and the artifacts grow toward the knobs (reached at half wear, about 43 s at 127, 6 minutes at 1), then on to twice them worn out, quieter and thinner.", "labels": null } ], diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index ec7d5f1592..c384716c8d 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -76,7 +76,7 @@ def mpy(x, y): CDECAY = 0x4ccccd # a click falls to 0.6 a sample HICCUP = 48 << 12 # a speed hiccup's largest swoop, Q11.12 samples (the head glides to it) GL_DECAY = 0x6ccccd # its target settles at 0.85 a call; the head follows a 16th of the way (peaking near a quarter of HICCUP) -CONTACT = 0x0ccccd # a lost head contact leaves 0.1 +CONTACT = 0x0ccccd # a lost head contact leaves 0.1, reached quickly (its glide 8 times a dropout's) WIDE_PH = 0x200000 # WIDE 127 puts the right channel's drift a quarter cycle and its flutter half a cycle away AZ = 3 << 12 # and its head 3 samples late (misaligned azimuth) LCG_A, LCG_C = 1664525, 0x6ef35f @@ -85,6 +85,12 @@ def mpy(x, y): HFSAT = 0x600000 # loud highs dull out: at full level and DRIV 127 the top's coefficient falls to 0.25 BREATH, BREATH_R = 0x2ccccd, 0x533333 # the hiss breathes with the level: 0.35 in silence, whole at full level STEPMAX = 246 # the head's step a sample at most, Q11.12 (6 % speed): a sudden knob change glides +AGE_MIN = 16 << 16 # wear's speed is AGE + 16: AGE 1 reaches half wear in about 6 minutes, AGE 127 in about 43 s +THR = round(0.9 * 16 / FS * Q) # the pinch roller turns about 0.9 times a second +TH_S, TH_SW = 12 << 12, 8 << 12 # its speed bump at FLUT 127 (x g), and what full wear adds, Q11.12 samples +TH_L, TH_LW = 0x07ae14, 0x0a3d71 # its level dip at FLUT 127 (x g, 0.06), and what full wear adds (0.08) +WEAR_LVL = 0x266666 # full wear leaves the tape 0.7 as loud (-3 dB) +WEAR_BUMP = 0x266666 # and its head bump 0.3 lower (thinner lows) SNAP = 64 # a filter state or click this close to zero is zero (once a call) LFSR_TAPS = 0xe10000 # x^24 + x^23 + x^22 + x^17 + 1, maximal: period 2^24 - 1 SEED = 0x2b1d5f @@ -160,11 +166,11 @@ def call(self, frames, p): x[0x2b] = p.get(0xe, 0) & 0x7f0000 # TONE x[0x2c] = (p.get(0xe, 0) & 0x00ff00) << 8 # AGE deck = x[0x27] - # ---- wear: AGE 0 keeps the tape fresh; above, it wears AGE << 6 a call (48-bit), full in about 95 s at 127 + # ---- wear: AGE 0 keeps the tape fresh; above, it wears (AGE + 16) << 6 a call (48-bit) if x[0x2c] == 0: x[0x04] = x[0x2d] = 0 else: - wv = (x[0x04] << 24 | (x[0x2d] & 0xffffff)) + (x[0x2c] << 6) + wv = (x[0x04] << 24 | (x[0x2d] & 0xffffff)) + ((x[0x2c] + AGE_MIN) << 6) if wv > 0x7fffff << 24: wv = 0x7fffff << 24 x[0x04], x[0x2d] = wv >> 24, wv & 0xffffff @@ -180,15 +186,26 @@ def call(self, frames, p): x[0x61] = hi(((ld(p2) - ld(x[0x61])) >> (2 if p2 > x[0x61] else 6)) + ld(x[0x61])) x[0x60] = 0 env = x[0x61] + # ---- the pinch roller: once a turn a short bump (an eighth of the turn) in speed and level, from FLUT (x g) + # and wear; the level ($63) also sags with wear + x[0x62] = (x[0x62] + ((THR * n) >> 4)) & 0x7fffff + pulse = max(0, lim(w56((ld(tri(x[0x62])) - ld(0x600000)) << 2))) + amt_s = lim(ld(more(lim(mpy(x[0x22], TH_S)))) + mpy(wear, TH_SW)) + sp = lim(mpy(pulse, amt_s)) + amt_l = lim(ld(more(lim(mpy(x[0x22], TH_L)))) + mpy(wear, TH_LW)) + x[0x63] = lim(ld(0x7fffff) - mpy(pulse, amt_l) - mpy(wear, WEAR_LVL)) # ---- the deck's figures this call drv = lim(ld(DRVB[deck]) + mpy(x[0x23], DRVR) + mpy(wear, WEAR_DRV)) hiss = more(lim(mpy(x[0x24], HISSB[deck]))) tonef = lim(ld(0x7fffff) - mpy(more(x[0x2b]), TONE_K)) wearf = lim(ld(0x7fffff) - mpy(wear, WEAR_HF)) - chf = lim(mpy(lim(mpy(lim(mpy(HFC[deck], tonef)), wearf)), x[0x14])) # muffled as a dropout dips + # a dropout muffles before it dips and comes back bright last: the top follows its gain (without the level's + # sag) squared + f = lim(ld(x[0x14]) + ld(0x7fffff) - ld(x[0x63])) + chf = lim(mpy(lim(mpy(lim(mpy(lim(mpy(HFC[deck], tonef)), wearf)), f)), f)) chf = lim(mpy(chf, lim(ld(0x7fffff) - mpy(env, lim(mpy(x[0x23], HFSAT)))))) # loud highs dull out hiss = lim(mpy(hiss, lim(ld(BREATH) + mpy(env, BREATH_R)))) # the hiss breathes - x[0x1a], x[0x1b], x[0x1c] = chf, BUMP[deck], hiss + x[0x1a], x[0x1b], x[0x1c] = chf, lim(ld(BUMP[deck]) - mpy(wear, WEAR_BUMP)), hiss wowd = more(lim(mpy(x[0x21], WOWD[deck]))) fltd = more(lim(mpy(x[0x22], FLTD[deck]))) # ---- nine random words a call, always in this order @@ -203,11 +220,12 @@ def call(self, frames, p): drift_r = lim(ld(x[0x0c]) + mpy(lim(ld(x[0x0d]) - ld(x[0x0c])), wide)) x[0x1f] = hi(((ld(x[0x20]) - ld(x[0x1f])) >> 4) + ld(x[0x1f])) x[0x20] = lim(mpy(x[0x20], GL_DECAY)) + hs = lim(ld(x[0x1f]) + ld(sp)) # the hiccup and the pinch roller's bump for ch, (dw, ds, dr, wph, fph, az) in enumerate(( (0x06, 0x08, x[0x0c], x[0x0a], x[0x0b], 0), (0x07, 0x09, drift_r, x[0x0a] + off, x[0x0b] + 2 * off, lim(mpy(wide, AZ))))): a = ld(D0 << 12) + mpy(wowd, sine(wph)) + mpy(lim(w56(ld(wowd) >> 1)), dr) + mpy(fltd, tri(fph)) - a = a + ld(x[0x1f]) + ld(az) + a = a + ld(hs) + ld(az) t = lim(a) t = max(DMIN, min(DMAX, t)) x[ds] = max(-STEPMAX, min(STEPMAX, lim(w56((ld(t) - ld(x[dw])) >> 4)))) # the head never lurches @@ -233,7 +251,8 @@ def call(self, frames, p): x[0x12], x[0x16] = drv, x[0x26] x[0x2e] = 1 x[0x13] = lim(w56((ld(drv) - ld(x[0x12])) >> 4)) - x[0x15] = lim(w56((ld(x[0x1e]) - ld(x[0x14])) >> 9)) + tgt = lim(mpy(x[0x1e], x[0x63])) # the dropout's gain x the level + x[0x15] = lim(w56((ld(tgt) - ld(x[0x14])) >> (6 if x[0x1e] == CONTACT else 9))) x[0x17] = lim(w56((ld(x[0x26]) - ld(x[0x16])) >> 4)) # truncating one-poles and the click's decay can stick a few LSB off zero: within SNAP (-102 dBFS) they are zero for wd in (0x0e, 0x0f, 0x10, 0x11, 0x18): diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index 5bfd19ccb2..f80b710dfb 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -262,15 +262,60 @@ def starts(gaps): self.assertGreater(hi, 15 * max(lo, 1)) def test_dropouts_glide(self): - # a dip moves the gain at most about a 512th of the way a sample: no click + # a dropout moves the gain at most about a 512th of the way a sample (no click); a lost head contact glides + # eight times faster, at most a 64th, and so reaches near its 0.1 + def worst_step(**kw): + m = R.Model() + row = R.pblock(knobs(QUIET, **kw)) + worst, low = 0, 0x7fffff + for _ in range(20000): + before = m.x[0x14] + m.call([(0, 0)] * 16, row) + worst = max(worst, abs(m.x[0x14] - before)) + low = min(low, m.x[0x14]) + return worst, low + gap, _ = worst_step(gaps=127) + self.assertLess(gap, 0x7fffff * 16 // 512 + 64) + contact, low = worst_step(glch=127) + self.assertLess(contact, 0x7fffff * 16 // 64 + 64) + self.assertGreater(contact, 0x7fffff * 16 // 512 + 64) + self.assertLess(low, 0x1c0000) # a lost contact dips below 0.22 (it reached 0.3 to 0.5 at the slow glide) + + def test_low_age_still_wears(self): + # wear's speed is AGE + 16: AGE 1 wears 17/143 as fast as 127, so half wear takes about 6 minutes, not hours + def wear(age, calls=2000): + m = R.Model() + row = R.pblock(knobs(QUIET, age=age)) + for _ in range(calls): + m.call([(0, 0)] * 16, row) + return m.x[0x04] + self.assertAlmostEqual(wear(1) / wear(127), 17 / 143, places=2) + half = 0x400000 / (wear(1) / 2000) * 16 / R.FS + self.assertTrue(300 < half < 420, half) + + def test_pinch_roller_thumps(self): + # FLUT 127 on a fresh tape: the level dips about 6 % once a turn (about 0.9 Hz), and rests at 1 between m = R.Model() - row = R.pblock(knobs(QUIET, gaps=127, glch=127)) - worst = 0 - for _ in range(20000): - before = m.x[0x14] + row = R.pblock(knobs(QUIET, flut=127)) + levels = [] + for _ in range(int(R.FS / 16 * 3)): m.call([(0, 0)] * 16, row) - worst = max(worst, abs(m.x[0x14] - before)) - self.assertLess(worst, 0x7fffff * 16 // 512 + 64) + levels.append(m.x[0x63]) + lo = min(levels) + self.assertTrue(0x7fffff * 0.93 < lo < 0x7fffff * 0.96, lo / 0x7fffff) + self.assertEqual(max(levels), 0x7fffff) + dips = sum(1 for a, b in zip(levels, levels[1:]) if a == 0x7fffff and b < a) + self.assertIn(dips, (2, 3)) + + def test_a_worn_tape_is_quieter_and_thinner(self): + # full wear: the level at most 0.7 plus the roller's dip, and the bump 0.3 lower + m = R.Model() + m.x[0x04] = 0x7fffff + m.x[0x2d] = 0xffffff + row = R.pblock(knobs(QUIET, age=127, deck=1)) + m.call([(0, 0)] * 16, row) + self.assertLessEqual(m.x[0x63], 0x7fffff * 0.7 + 2) + self.assertLess(m.x[0x1b], R.BUMP[1] - 0x260000) def test_the_head_stays_in_its_line(self): x = noise(4, 16 * 3000) From 36bb82a5efab06ad643843a51b1079a35acec03a Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 16:29:24 -0600 Subject: [PATCH 07/16] Cassettebox: tape's even harmonic, uneven worn heads, creases passing the head The cubic gains k a^2 (k 0.06 at DRIV 0 to 0.2 at 127), its offset followed at about 3.4 Hz and taken off. As the tape wears, the right head dulls and quietens, wandering on a 20 s cycle (exactly the left's with no wear). With GAPS, now and then a crease crosses the head for 70-130 ms: the top flickers and the head jitters. The words the samples read sit at short offsets; state /bin/zsh-. verify.py bit for bit; test_reference.py 32/32; worst 357.8 (1.14x SPRING REV, 1.08x DJ EQ), stamped. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 8 +- sdk/drafts/cassettebox/TESTING.md | 2 +- sdk/drafts/cassettebox/engine.asm | 182 ++++++++++++++++-- .../cassettebox/evidence/performance.json | 12 +- sdk/drafts/cassettebox/manifest.py | 4 +- sdk/drafts/cassettebox/octamod.module.json | 4 +- sdk/drafts/cassettebox/reference.py | 65 +++++-- sdk/drafts/cassettebox/test_reference.py | 47 +++++ sdk/drafts/cassettebox/verify.py | 4 +- 9 files changed, 280 insertions(+), 48 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index f99fdd2fc7..72eb4bdc32 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -17,16 +17,16 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pock |---|---|---|---|---|---| | Main | A | DRFT | 0-127 | 32 | Drift: the tape speed's slow sway and wander. 0 is steady. | | Main | B | FLUT | 0-127 | 24 | Flutter: the fast shimmering wobble, and a worn pinch roller's faint thump in speed and level about once a second. | -| Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder). Loud, bright passages dull out more, as real tape does. | +| Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder), with more of tape's warm, uneven 2nd harmonic. Loud, bright passages dull out more, as real tape does. | | Main | D | HISS | 0-127 | 16 | Tape hiss, shaped by the deck. It breathes with the track: full under loud passages, down to about a third in the gaps. | -| Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. Each one muffles before it dips and comes back bright last. Rare at low settings, frequent near 127. | +| Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. Each one muffles before it dips and comes back bright last. Now and then a crease crosses the head too: a tenth of a second of crinkly wobble and flickering muffle. Rare at low settings, frequent near 127. | | Main | F | MIX | 0-127 | 127 | Dry/tape blend. 127 is the tape alone, 0 the dry track. | | Setup | A | DECK | STUDIO, HOME, POCKET, VHS | HOME | The machine: its tone, head bump, saturation, hiss and how steady it runs. STUDIO is clean and steady, HOME duller with more hiss and a little warble, POCKET narrow, hissy, fluttery and crunchy, VHS an aged videotape: thin lows, a muffled top and a slow, deep warble. | | Setup | B | WIDE | 0-127 | 32 | Stereo: left and right drift and flutter apart, and the right head sits slightly misaligned. | | Setup | C | DUST | 0-127 | 0 | Crackle: soft pops, an occasional tick at low settings and a steady crackle near 127. | | Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed swoop, or a moment of lost head contact that drops the sound nearly out. Rare at low settings. | | Setup | E | TONE | 0-127 | 0 | Darkens the top end, as worn heads or a cheap copy do. 0 is the deck's own. | -| Setup | F | AGE | 0-127 | 0 | Wear over time. At 0 the knobs apply at once. Above 0 the tape starts clean, and drift, flutter, hiss, dropouts, crackle, glitches and TONE grow toward their knob positions, reaching them at half wear and going on to about twice them when worn out. As it wears the top fades, the tape gets grainier, quieter (about 3 dB when worn out) and thinner in the lows, the pinch roller thumps harder, and a worn tape gains some hiss, dropouts, crackle and glitches of its own, even with those knobs at 0. Half wear takes about 43 s at 127, 1.3 minutes at 64, 2 minutes at 32 and 6 minutes at 1. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | +| Setup | F | AGE | 0-127 | 0 | Wear over time. At 0 the knobs apply at once. Above 0 the tape starts clean, and drift, flutter, hiss, dropouts, crackle, glitches and TONE grow toward their knob positions, reaching them at half wear and going on to about twice them when worn out. As it wears the top fades, the tape gets grainier, quieter (about 3 dB when worn out) and thinner in the lows, the pinch roller thumps harder, the two heads wear unevenly (the right one slowly drifts duller and a little quieter), and a worn tape gains some hiss, dropouts, crackle and glitches of its own, even with those knobs at 0. Half wear takes about 43 s at 127, 1.3 minutes at 64, 2 minutes at 32 and 6 minutes at 1. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | ## Usage @@ -64,5 +64,5 @@ None yet. ## Develop -- Hear it: `npm run module:dev -- cassettebox --cycles 325 --cycles-kind executed --state 100 --buffer 1024 --slots both`. +- Hear it: `npm run module:dev -- cassettebox --cycles 358 --cycles-kind executed --state 113 --buffer 1024 --slots both`. - Check it: `npm run module:doctor -- --draft cassettebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`, and `python3 -B test_reference.py` tests the model. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index 16bdeef1bc..521283c08b 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 256 words; measured unsplit 279.1 to 279.5, worst 324.4 (the dearest POCKET setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1299.5 and 1208.4, 0 clobbers, 0 stray writes). 1.03x SPRING REV (314.19), 0.98x DJ EQ (330.94). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 278 words; measured unsplit 306.7 to 307.1, worst 357.8 (the dearest POCKET setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1433.0 and 1330.2, 0 clobbers, 0 stray writes). 1.14x SPRING REV (314.19), 1.08x DJ EQ (330.94). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index 12b20bb576..0f3ca20567 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -25,27 +25,31 @@ ; (r6+$c 8-15), DUST slot 8 (r6+$d 16-23), GLCH slot 9 (r6+$d 8-15), TONE slot ; 10 (r6+$e 16-23), AGE slot 11 (r6+$e 8-15). ; -; State (X, offsets from r7; init clears $00..$63): +; State (X, offsets from r7; init clears $00..$70): ; $00 the ring's base (Y) $01 g, the artifacts' share (Q22) $02 the pointer r5 $03 the hiss LCG (left's noise) $04 wear (Q23) ; $05 LFSR $06/$07 each head's d (Q11.12) $08/$09 its step a sample $0a drift's phase $0b flutter's ; $0c/$0d each channel's wander $0e/$0f playback's low-pass states $10/$11 the bump's states ; $12/$13 the drive and its step $14/$15 the dropout gain and its step $16/$17 MIX and its step ; $18 the click $1a the top's coefficient $1b the bump's level $1c the hiss level -; $19 left's last noise word $1d a dropout's frames left $1e its gain $1f the hiccup (Q11.12) $20 its target -; $21-$2c DRFT FLUT DRIV HISS GAPS MIX DECK WIDE DUST GLCH TONE AGE $2d wear's low word $2e seeded $2f right's last noise word +; $19 left's last noise word $1d a dropout's frames left $1e its gain $1f the hiccup (Q11.12) $20 the right head's dropout gain +; $21-$2c DRFT FLUT DRIV HISS GAPS MIX DECK WIDE DUST GLCH TONE AGE $2d/$2e each channel's even-harmonic offset $2f right's last noise word ; $30/$31 drift's and flutter's swings (a call), then each channel's softened noise (a sample) $32-$3a nine random words $3b right's noise -; $3c the dry (scratch) $3d WIDE's phase offset $3e right's wander $3f the drive's target +; $3c the dry (scratch) $3d WIDE's phase offset, then the right head's gain step $3e right's wander, then the even +; harmonic's k $3f the drive's target, then the right head's top (the samples read these at short offsets) ; $40-$5f DECK's tables, four words each: drift, flutter, their rates, drive, hiss, top, bump ; $60 the call's loudest input, either channel (halved) $61 the level follower (loud highs dull, the hiss breathes) ; $62 the pinch roller's phase $63 the level (the roller's dip and wear's sag; it scales the dropout gain) -; Nothing above $63 is touched. Every product is the signed mpy/mac x0,y1 +; $64 wear's low word $65 seeded $66 the right head's top $67 the hiccup's target +; $69 the right head's wear phase $6a a crease's frames left $6d its chance's random word +; $6f what the right head's level loses $70 the even harmonic's k +; Nothing above $70 is touched. Every product is the signed mpy/mac x0,y1 ; form. Labels are cb and two characters, so none is another's prefix. ; CYCLES_FORWARD_BRANCHES init: clr a move r7,r5 move #>$ffffff,m5 - do #$64,>cbi0 + do #$71,>cbi0 move a,x:(r5)+ cbi0: nop @@ -75,6 +79,7 @@ cbi1: move #>$7fffff,x0 move x0,x:(r7+$14) move x0,x:(r7+$1e) + move x0,x:(r7+$20) move #>$010000,x0 move x0,x:(r7+$40) move #>$020000,x0 @@ -198,11 +203,11 @@ proc: bne cbw1 clr a move a,x:(r7+$04) - move a,x:(r7+$2d) + move a,x:(r7+$64) bra cbw2 cbw1: move x:(r7+$04),a - move x:(r7+$2d),a0 + move x:(r7+$64),a0 add #>$100000,b asr #18,b,b add b,a @@ -210,7 +215,7 @@ cbw1: cmp b,a tgt b,a move a1,x:(r7+$04) - move a0,x:(r7+$2d) + move a0,x:(r7+$64) cbw2: ; ---- wear's own share of the artifacts: HISS, GAPS, DUST and GLCH each gain wear x a base (a worn tape hisses, ; drops out, crackles and glitches even from 0) @@ -332,6 +337,11 @@ cbe2: move #>$140000,y1 mac x0,y1,b move b,x:(r7+$3f) + move x:(r7+$23),x0 + move #>$11eb85,y1 + mpy x0,y1,a + add #>$07ae14,a + move a,x:(r7+$70) move x:(r7+$27),a add #>$54,a move a1,n1 @@ -395,6 +405,34 @@ cbe2: move x1,x0 mpy x0,y1,a move a,x:(r7+$1a) +; uneven heads: the right head's wear wanders ($69); its top less top x dull to $66, its level's loss dull x LVL_IMB to $6f + move #>$000098,y1 + move n7,x0 + mpy x0,y1,a + asr #5,a,a + move a0,x0 + move x:(r7+$69),a + add x0,a + and #>$7fffff,a + move a1,x:(r7+$69) + bsr cbtr + move #>$19999a,y1 + mpy x0,y1,a + add #>$200000,a + move a,x0 + move x:(r7+$04),y1 + mpy x0,y1,b + move b,x1 + move x1,y1 + move x:(r7+$1a),x0 + mpy x0,y1,b + move x0,a + sub b,a + move a,x:(r7+$66) + move x1,x0 + move #>$266666,y1 + mpy x0,y1,a + move a,x:(r7+$6f) ; the hiss breathes: x (BREATH + level x BREATH_R) move x:(r7+$61),x0 move #>$533333,y1 @@ -461,6 +499,9 @@ cbe2: move x0,x:(r7+$39) bsr cbrn move x0,x:(r7+$3a) +; and a crease's chance (its flicker, jitter and length share the click's size, a dropout's depth and its length) + bsr cbrn + move x0,x:(r7+$6d) ; ---- drift's and flutter's phases (by the call's length); each channel's wander a 256th of the way to a new random word move x:(r7+$27),a add #>$48,a @@ -521,20 +562,46 @@ cbe2: mpy x0,y1,a add x1,a move a,x:(r7+$3e) - move x:(r7+$20),a + move x:(r7+$67),a move x:(r7+$1f),x0 sub x0,a asr #4,a,a add x0,a move a1,x:(r7+$1f) - move x:(r7+$20),x0 + move x:(r7+$67),x0 move #>$6ccccd,y1 mpy x0,y1,a - move a,x:(r7+$20) + move a,x:(r7+$67) move x:(r7+$1f),a move x:(r7+$3b),x0 add x0,a move a,x:(r7+$3b) +; a crease passing: both tops flicker (x 1 - a random word x CR_HF), the head jitters (a random word x CR_D) + move x:(r7+$6a),a + tst a + ble cbk1 + move x:(r7+$38),x0 + move #>$666666,y1 + mpy x0,y1,b + move #>$7fffff,a + sub b,a + move a,y1 + move x:(r7+$1a),x0 + mpy x0,y1,a + move a,x:(r7+$1a) + move x:(r7+$66),x0 + mpy x0,y1,a + move a,x:(r7+$66) + move x:(r7+$36),a + sub #>$400000,a + asl #1,a,a + move a,x0 + move #>$001800,y1 + mpy x0,y1,a + move x:(r7+$3b),x0 + add x0,a + move a,x:(r7+$3b) +cbk1: ; ---- left's head target, clamped, and its step a sample (a 16th of the way) move x:(r7+$0a),a bsr cbsn @@ -694,7 +761,7 @@ cbg3: move a,x0 move #>$030000,y1 mpy x0,y1,a - move a,x:(r7+$20) + move a,x:(r7+$67) bra cbg6 cbg4: move x:(r7+$1d),a @@ -736,9 +803,44 @@ cbg6: mpy x0,y1,a move a,x:(r7+$18) cbg7: +; ---- a crease (GAPS x wear): one passing counts down, else one may start + move x:(r7+$6a),a + tst a + ble cbk2 + move n7,x0 + sub x0,a + move a1,x:(r7+$6a) + tst a + bgt cbk3 + clr a + move a,x:(r7+$6a) + bra cbk3 +cbk2: + move x:(r7+$25),x0 + move x0,y1 + mpy x0,y1,a + move a,x0 + move #>$004000,y1 + mpy x0,y1,a + move a,x0 + move x:(r7+$01),y1 + mpy x0,y1,a + asl #1,a,a + move a,x0 + move x:(r7+$6d),a + cmp x0,a + bge cbk3 + move x:(r7+$35),x0 + move #>2646,y1 + mpy x0,y1,a + move a1,x0 + move #>3087,a + add x0,a + move a1,x:(r7+$6a) +cbk3: ; ---- the runs: the first call snaps them; then the drive and MIX walk a 16th of the way a call, the dropout gain ; (x the level) a 32nd, a lost contact a quarter - move x:(r7+$2e),a + move x:(r7+$65),a tst a bne cbf1 move x:(r7+$3f),x0 @@ -746,7 +848,7 @@ cbg7: move x:(r7+$26),x0 move x0,x:(r7+$16) move #>$1,x0 - move x0,x:(r7+$2e) + move x0,x:(r7+$65) cbf1: move x:(r7+$3f),a move x:(r7+$12),x0 @@ -768,11 +870,33 @@ cbf1: cbf2: asr #6,a,a move a,x:(r7+$15) + move x:(r7+$6f),y1 + move x1,x0 + mpy x0,y1,b + move x1,a + sub b,a + move a,x1 + move x1,a + move x:(r7+$20),x0 + sub x0,a + move x:(r7+$1e),b + move #>$0ccccd,y1 + cmp y1,b + beq cbf3 + asr #3,a,a +cbf3: + asr #6,a,a + move a,x:(r7+$3d) move x:(r7+$26),a move x:(r7+$16),x0 sub x0,a asr #4,a,a move a,x:(r7+$17) +; for the samples, at short offsets: the even harmonic's k ($3e) and the right head's top ($3f; $3d holds its gain's step) + move x:(r7+$70),x0 + move x0,x:(r7+$3e) + move x:(r7+$66),x0 + move x0,x:(r7+$3f) ; ---- a filter state or click within SNAP of zero is zero (truncation would hold it a few LSB off) move x:(r7+$0e),a abs a @@ -862,6 +986,10 @@ cbn4: move x:(r7+$17),x0 add x0,a move a,x:(r7+$16) + move x:(r7+$20),a + move x:(r7+$3d),x0 + add x0,a + move a,x:(r7+$20) move x:(r7+$18),x0 move #>$4ccccd,y1 mpy x0,y1,a @@ -916,6 +1044,16 @@ cbn4: mpy x0,y1,a move a,x1 move x0,b +; the even harmonic, k a^2, less its offset (followed at 5 Hz) + move x:(r7+$3e),x0 + mpy x0,y1,a + move x:(r7+$2d),y0 + add a,b + sub y0,b + sub y0,a + asr #11,a,a + add y0,a + move a1,x:(r7+$2d) move x1,x0 move #>$2aaaab,y1 mpy x0,y1,a @@ -1015,6 +1153,16 @@ cbn4: mpy x0,y1,a move a,x1 move x0,b +; the even harmonic, k a^2, less its offset (followed at 5 Hz) + move x:(r7+$3e),x0 + mpy x0,y1,a + move x:(r7+$2e),y0 + add a,b + sub y0,b + sub y0,a + asr #11,a,a + add y0,a + move a1,x:(r7+$2e) move x1,x0 move #>$2aaaab,y1 mpy x0,y1,a @@ -1034,7 +1182,7 @@ cbn4: move x:(r7+$0f),x1 sub x1,a move a,x0 - move x:(r7+$1a),y1 + move x:(r7+$3f),y1 mpy x0,y1,a add x1,a move a1,x:(r7+$0f) @@ -1053,7 +1201,7 @@ cbn4: add x1,a move a,x0 ; dropouts, then MIX against the dry - move x:(r7+$14),y1 + move x:(r7+$20),y1 mpy x0,y1,a move a,x0 move x0,a diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index cd0995e641..b0d38f6597 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "713b297fe860b6e08dc7e6bf14545feb79d06111a8daf11c7bb20e74c68155d9", + "sourceSha256": "1e8121160f783b1d86d28a0cdb9e4c4c066dcbf60fa41f9600756c4de4d4e910", "kind": "dsp", "cycles": { "unit": "instructions/sample", - "static": 256, - "measured": 324.4, + "static": 278, + "measured": 357.8, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 256 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 279.1 to 279.5; worst 324.4, the dearest POCKET setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the deck's figures, nine random words, two head targets with their sine and triangle, the events and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 278 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 306.7 to 307.1; worst 357.8, the dearest POCKET setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the uneven heads, the deck's figures, nine random words, two head targets with their sine and triangle, the events (a crease among them) and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", @@ -17,7 +17,7 @@ "dearestWorst": 330.94, "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", - "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 324.40, is 1.03x SPRING REV's 314.19 and 0.98x DJ EQ's 330.94 (the extra over SPRING REV is per-call work, wear, the pinch roller and the events, which a trig split of 1 frame runs twice a block); unsplit 279.5 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared." + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 357.80, is 1.14x SPRING REV's 314.19 and 1.08x DJ EQ's 330.94 (the extra is the tape's even harmonic with its offset follower on each channel, the right head's own gain, and per-call work, wear, the pinch roller, uneven heads and the events, which a trig split of 1 frame runs twice a block); unsplit 307.1 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic with an even harmonic (its offset followed and taken off), adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared and the right head has its own dropout gain." }, "stress": { "instancesPerCore": 4, @@ -29,6 +29,6 @@ "dirty": true, "clobbers": 0, "hangs": 0, - "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1299.5 and 1208.4 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1433.0 and 1330.2 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." } } diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index 761bdae7ad..247ad83be6 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -47,11 +47,11 @@ Param(b"FLUT", D["FLUT"], 128, active=True, formatter=P, doc="flutter: the fast shimmering wobble and a worn pinch roller's thump; 0 none"), Param(b"DRIV", D["DRIV"], 128, active=True, formatter=P, - doc="drive: saturation and compression, the tape pushed harder (and louder); loud highs dull out more"), + doc="drive: saturation, compression and tape's warm 2nd harmonic, the tape pushed harder (and louder); loud highs dull out more"), Param(b"HISS", D["HISS"], 128, active=True, formatter=P, doc="tape hiss, shaped by the deck; it breathes with the track, quieter in the gaps; 0 none"), Param(b"GAPS", D["GAPS"], 128, active=True, formatter=P, - doc="dropouts: how often the level dips and muffles, as on creased or worn tape; 0 none"), + doc="dropouts and creases: how often the level dips and muffles, or a crease crinkles past the head; 0 none"), Param(b"MIX", D["MIX"], 128, active=True, formatter=P, doc="dry/tape blend; 127 the tape alone, 0 the dry track (5.8 ms late, as the tape is)"), Param(b"DECK", D["DECK"], 4, active=True, formatter=S, labels=_ref.DECKS, diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index a53e1d5567..cba514d592 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -48,7 +48,7 @@ "name": "DRIV", "default": 32, "count": 128, - "doc": "Drive: saturation and compression, the tape pushed harder (and louder); loud highs dull out more.", + "doc": "Drive: saturation, compression and tape's warm 2nd harmonic, the tape pushed harder (and louder); loud highs dull out more.", "labels": null }, { @@ -62,7 +62,7 @@ "name": "GAPS", "default": 0, "count": 128, - "doc": "Dropouts: how often the level dips and muffles, as on creased or worn tape; 0 none.", + "doc": "Dropouts and creases: how often the level dips and muffles, or a crease crinkles past the head; 0 none.", "labels": null }, { diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index c384716c8d..ec94024155 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -91,6 +91,15 @@ def mpy(x, y): TH_L, TH_LW = 0x07ae14, 0x0a3d71 # its level dip at FLUT 127 (x g, 0.06), and what full wear adds (0.08) WEAR_LVL = 0x266666 # full wear leaves the tape 0.7 as loud (-3 dB) WEAR_BUMP = 0x266666 # and its head bump 0.3 lower (thinner lows) +WARM_B, WARM_R = 0x07ae14, 0x11eb85 # the tape's even harmonic: k a^2 added to the cubic, k 0.06 at DRIV 0 to 0.2 at 127 +DC_SHIFT = 11 # and the offset it makes, followed at about 3.4 Hz (a 2048th of the way a sample) and taken off +HPR = round(0.05 * 16 / FS * Q) # uneven heads: the right head's wear wanders on a 20 s cycle +IMB0, IMBW = 0x200000, 0x19999a # full wear dulls its top by 0.25, wandering 0.2 either way +LVL_IMB = 0x266666 # and lowers its level by 0.3 of that +CREASEP = 0x004000 # a crease's chance a call at GAPS 127 (fresh tape), by GAPS squared +CR_LEN, CR_RANGE = 3087, 2646 # it crosses the head in 70 to 130 ms +CR_HF = 0x666666 # each call while it passes, the top flickers down to between 1 and 0.2 +CR_D = 0x1800 # and the head jitters up to 1.5 samples (the step clamp turns it into a crinkle) SNAP = 64 # a filter state or click this close to zero is zero (once a call) LFSR_TAPS = 0xe10000 # x^24 + x^23 + x^22 + x^17 + 1, maximal: period 2^24 - 1 SEED = 0x2b1d5f @@ -125,7 +134,7 @@ class Model: block p (offset -> word) and returns [(left, right)].""" def __init__(self, base=0x4000): - self.x = [0] * 0x64 + self.x = [0] * 0x71 self.ring = [0] * RING x = self.x x[0x00] = base @@ -134,7 +143,7 @@ def __init__(self, base=0x4000): x[0x05] = s24(SEED ^ base) x[0x06] = x[0x07] = D0 << 12 x[0x12] = 0 - x[0x14] = x[0x1e] = 0x7fffff + x[0x14] = x[0x1e] = x[0x20] = 0x7fffff x[0x16] = 0 def rand(self): @@ -168,12 +177,12 @@ def call(self, frames, p): deck = x[0x27] # ---- wear: AGE 0 keeps the tape fresh; above, it wears (AGE + 16) << 6 a call (48-bit) if x[0x2c] == 0: - x[0x04] = x[0x2d] = 0 + x[0x04] = x[0x64] = 0 else: - wv = (x[0x04] << 24 | (x[0x2d] & 0xffffff)) + ((x[0x2c] + AGE_MIN) << 6) + wv = (x[0x04] << 24 | (x[0x64] & 0xffffff)) + ((x[0x2c] + AGE_MIN) << 6) if wv > 0x7fffff << 24: wv = 0x7fffff << 24 - x[0x04], x[0x2d] = wv >> 24, wv & 0xffffff + x[0x04], x[0x64] = wv >> 24, wv & 0xffffff wear = x[0x04] for kw, base in WEAR_BASE: # wear's own share of the artifacts x[kw] = lim(ld(x[kw]) + mpy(wear, base)) @@ -196,6 +205,7 @@ def call(self, frames, p): x[0x63] = lim(ld(0x7fffff) - mpy(pulse, amt_l) - mpy(wear, WEAR_LVL)) # ---- the deck's figures this call drv = lim(ld(DRVB[deck]) + mpy(x[0x23], DRVR) + mpy(wear, WEAR_DRV)) + x[0x70] = lim(mpy(x[0x23], WARM_R) + ld(WARM_B)) # the even harmonic's k hiss = more(lim(mpy(x[0x24], HISSB[deck]))) tonef = lim(ld(0x7fffff) - mpy(more(x[0x2b]), TONE_K)) wearf = lim(ld(0x7fffff) - mpy(wear, WEAR_HF)) @@ -204,12 +214,20 @@ def call(self, frames, p): f = lim(ld(x[0x14]) + ld(0x7fffff) - ld(x[0x63])) chf = lim(mpy(lim(mpy(lim(mpy(lim(mpy(HFC[deck], tonef)), wearf)), f)), f)) chf = lim(mpy(chf, lim(ld(0x7fffff) - mpy(env, lim(mpy(x[0x23], HFSAT)))))) # loud highs dull out + # uneven heads: as the tape wears the right head dulls and quietens, wandering on a slow cycle ($69) + x[0x69] = (x[0x69] + ((HPR * n) >> 4)) & 0x7fffff + dull = lim(mpy(lim(mpy(tri(x[0x69]), IMBW) + ld(IMB0)), wear)) + chf_r = lim(ld(chf) - mpy(chf, dull)) # exactly the left's on a fresh tape + x[0x6f] = lim(mpy(dull, LVL_IMB)) # what the right head's level loses hiss = lim(mpy(hiss, lim(ld(BREATH) + mpy(env, BREATH_R)))) # the hiss breathes + x[0x1a], x[0x66] = chf, chf_r x[0x1a], x[0x1b], x[0x1c] = chf, lim(ld(BUMP[deck]) - mpy(wear, WEAR_BUMP)), hiss wowd = more(lim(mpy(x[0x21], WOWD[deck]))) fltd = more(lim(mpy(x[0x22], FLTD[deck]))) # ---- nine random words a call, always in this order r_dl, r_dr, r_gap, r_glen, r_gdep, r_dust, r_damp, r_gl, r_gp = (self.rand() for _ in range(9)) + r_c = self.rand() # a crease's chance; its flicker, jitter and length + r_cf, r_cj, r_clen = r_damp, r_gdep, r_glen # share words only rare events read # ---- the speed: drift (a slow sine and a wandering random), flutter, a hiccup; WIDE parts the channels x[0x0a] = (x[0x0a] + ((WOWR[deck] * n) >> 4)) & 0x7fffff # by the call's length: a split doesn't speed it x[0x0b] = (x[0x0b] + ((FLTR[deck] * n) >> 4)) & 0x7fffff @@ -218,9 +236,14 @@ def call(self, frames, p): wide = x[0x28] off = mpy(wide, WIDE_PH) >> 24 drift_r = lim(ld(x[0x0c]) + mpy(lim(ld(x[0x0d]) - ld(x[0x0c])), wide)) - x[0x1f] = hi(((ld(x[0x20]) - ld(x[0x1f])) >> 4) + ld(x[0x1f])) - x[0x20] = lim(mpy(x[0x20], GL_DECAY)) + x[0x1f] = hi(((ld(x[0x67]) - ld(x[0x1f])) >> 4) + ld(x[0x1f])) + x[0x67] = lim(mpy(x[0x67], GL_DECAY)) hs = lim(ld(x[0x1f]) + ld(sp)) # the hiccup and the pinch roller's bump + if x[0x6a] > 0: # a crease passing: the top flickers, the head jitters + flick = lim(ld(0x7fffff) - mpy(r_cf, CR_HF)) + x[0x1a] = lim(mpy(x[0x1a], flick)) + x[0x66] = lim(mpy(x[0x66], flick)) + hs = lim(mpy(lim(w56((ld(r_cj) - ld(0x400000)) << 1)), CR_D) + ld(hs)) for ch, (dw, ds, dr, wph, fph, az) in enumerate(( (0x06, 0x08, x[0x0c], x[0x0a], x[0x0b], 0), (0x07, 0x09, drift_r, x[0x0a] + off, x[0x0b] + 2 * off, lim(mpy(wide, AZ))))): @@ -240,19 +263,28 @@ def call(self, frames, p): x[0x1e] = lim(ld(0x7fffff) - mpy(r_gdep, GAP_DEPTH)) if r_gl - more(lim(mpy(lim(mpy(x[0x2a], x[0x2a])), GLP))) < 0: if r_gp & 0x400000: - x[0x20] = lim(mpy(lim(w56((ld(r_gp) - ld(0x600000)) << 2)), HICCUP)) + x[0x67] = lim(mpy(lim(w56((ld(r_gp) - ld(0x600000)) << 2)), HICCUP)) elif x[0x1d] == 0: x[0x1d] = GAP_LEN + hi(mpy(r_gp, 882)) x[0x1e] = CONTACT if r_dust - more(lim(mpy(lim(mpy(x[0x29], x[0x29])), DUSTP))) < 0: x[0x18] = lim(mpy(lim(w56((ld(r_damp) - ld(0x400000)) << 1)), lim(mpy(x[0x29], CLICK)))) + if x[0x6a] > 0: # a crease (GAPS): one passing counts down, else one may start + x[0x6a] -= n + if x[0x6a] <= 0: + x[0x6a] = 0 + elif r_c - more(lim(mpy(lim(mpy(x[0x25], x[0x25])), CREASEP))) < 0: + x[0x6a] = CR_LEN + hi(mpy(r_clen, CR_RANGE)) # ---- the runs: each knob's gain walks a 16th of the way a sample (none snaps but at the first call) - if x[0x2e] == 0: + if x[0x65] == 0: x[0x12], x[0x16] = drv, x[0x26] - x[0x2e] = 1 + x[0x65] = 1 x[0x13] = lim(w56((ld(drv) - ld(x[0x12])) >> 4)) tgt = lim(mpy(x[0x1e], x[0x63])) # the dropout's gain x the level - x[0x15] = lim(w56((ld(tgt) - ld(x[0x14])) >> (6 if x[0x1e] == CONTACT else 9))) + sh = 6 if x[0x1e] == CONTACT else 9 + x[0x15] = lim(w56((ld(tgt) - ld(x[0x14])) >> sh)) + tgt_r = lim(ld(tgt) - mpy(tgt, x[0x6f])) # the right head's own level + x[0x68] = lim(w56((ld(tgt_r) - ld(x[0x20])) >> sh)) x[0x17] = lim(w56((ld(x[0x26]) - ld(x[0x16])) >> 4)) # truncating one-poles and the click's decay can stick a few LSB off zero: within SNAP (-102 dBFS) they are zero for wd in (0x0e, 0x0f, 0x10, 0x11, 0x18): @@ -270,6 +302,7 @@ def sample(self, left, right): x[0x12] = lim(ld(x[0x12]) + ld(x[0x13])) x[0x14] = lim(ld(x[0x14]) + ld(x[0x15])) x[0x16] = lim(ld(x[0x16]) + ld(x[0x17])) + x[0x20] = lim(ld(x[0x20]) + ld(x[0x68])) x[0x18] = lim(mpy(x[0x18], CDECAY)) p = x[0x02] out = [] @@ -284,14 +317,18 @@ def sample(self, left, right): y0, y1 = ring[(p + o - i) % RING], ring[(p + o - i - 1) % RING] w = hi(mpy(lim(ld(y1) - ld(y0)), f) + ld(y0)) a = lim(w56(mpy(w, x[0x12]) << 2)) # the drive, x 4 - s = lim(ld(a) - mpy(lim(mpy(lim(mpy(a, a)), a)), THIRD)) # the tape's cubic + a2 = lim(mpy(a, a)) + w = mpy(x[0x70], a2) # the even harmonic, k a^2 + z = x[0x2d + ch] + x[0x2d + ch] = hi(w56((w - ld(z)) >> DC_SHIFT) + ld(z)) # its offset, followed at about 3.4 Hz + s = lim(ld(a) + w - ld(z) - mpy(lim(mpy(a2, a)), THIRD)) # the tape's cubic, the even harmonic less its offset s = lim(ld(s) + mpy(noise[ch], x[0x1c]) + ld(x[0x18])) # hiss and crackle, on the tape lp = 0x0e + ch - x[lp] = hi(mpy(lim(ld(s) - ld(x[lp])), x[0x1a]) + ld(x[lp])) # playback's top + x[lp] = hi(mpy(lim(ld(s) - ld(x[lp])), x[0x66 if ch else 0x1a]) + ld(x[lp])) # playback's top bp = 0x10 + ch x[bp] = hi(mpy(lim(ld(x[lp]) - ld(x[bp])), CBUMP) + ld(x[bp])) # the head bump t = lim(ld(x[lp]) + mpy(x[bp], x[0x1b])) - t = lim(mpy(t, x[0x14])) # dropouts + t = lim(mpy(t, x[0x20 if ch else 0x14])) # dropouts (the right head its own level) out.append(lim(ld(dry) + mpy(lim(ld(t) - ld(dry)), x[0x16]))) x[0x02] = (p + 1) % RING return tuple(out) diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index f80b710dfb..656f77d97b 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -317,6 +317,53 @@ def test_a_worn_tape_is_quieter_and_thinner(self): self.assertLessEqual(m.x[0x63], 0x7fffff * 0.7 + 2) self.assertLess(m.x[0x1b], R.BUMP[1] - 0x260000) + def test_even_harmonic_warmth(self): + # a sine through the tape gains a 2nd harmonic that grows with DRIV, and the offset it makes is taken off + import numpy as np + n = 16 * 4000 + x = [round(0.5 * R.Q * math.sin(2 * math.pi * 441 * i / R.FS)) for i in range(n)] + def h2(driv): + l, _, _ = R.render(x, x, {0: knobs(QUIET, driv=driv, deck=0)}) + y = np.array(l[n // 2:], float) + s = np.abs(np.fft.rfft(y * np.hanning(len(y)))) + f = lambda hz: s[round(hz * len(y) / R.FS)] + return f(882) / f(441), abs(y.mean()) / R.Q + lo, dc_lo = h2(0) + hi, dc_hi = h2(127) + self.assertGreater(lo, 0.005) + self.assertGreater(hi, 2 * lo) + self.assertLess(max(dc_lo, dc_hi), 0.002) + + def test_uneven_heads(self): + # a fresh tape: both heads alike; worn out: the right head's top and level lower than the left's + m = R.Model() + m.call([(0, 0)] * 16, R.pblock(knobs(QUIET))) # AGE 0: no wear + self.assertEqual(m.x[0x66], m.x[0x1a]) + self.assertEqual(m.x[0x6f], 0) + row = R.pblock(knobs(QUIET, age=127)) + m.x[0x04], m.x[0x2d] = 0x7fffff, 0xffffff + for _ in range(int(R.FS / 16 * 25)): + m.call([(0, 0)] * 16, row) + self.assertLess(m.x[0x66], m.x[0x1a]) + self.assertGreater(m.x[0x6f], 0) + + def test_creases_pass_with_gaps(self): + # GAPS 127 on a fresh tape: creases come by now and then, each 70 to 130 ms; GAPS 0, none + def creases(gaps): + m = R.Model() + row = R.pblock(knobs(QUIET, gaps=gaps)) + n, prev, longest = 0, 0, 0 + for _ in range(int(R.FS / 16 * 60)): + m.call([(0, 0)] * 16, row) + n += m.x[0x6a] > prev + longest = max(longest, m.x[0x6a]) + prev = m.x[0x6a] + return n, longest + n, longest = creases(127) + self.assertGreater(n, 3) + self.assertLessEqual(longest, R.CR_LEN + R.CR_RANGE) + self.assertEqual(creases(0)[0], 0) + def test_the_head_stays_in_its_line(self): x = noise(4, 16 * 3000) m = R.Model() diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py index 418c28348f..9858e84ae0 100644 --- a/sdk/drafts/cassettebox/verify.py +++ b/sdk/drafts/cassettebox/verify.py @@ -11,7 +11,7 @@ Gates: 1. Every instruction decodes as written (signed mpy/mac x0,y1, no rep, no mpysu/macsu), no label is a - prefix of another (case-blind), the state stays inside X:(r7+$00..$63), and proc returns with every + prefix of another (case-blind), the state stays inside X:(r7+$00..$70), and proc returns with every modifier register it set to a modulus linear again. 2. Bit for bit the model: every DECK at its defaults, its dearest and with every knob at 127, each knob alone at 127, every knob swept, AGE wearing a tape for 12 s, a 5-frame trig split every block, a knob word carrying an @@ -40,7 +40,7 @@ def _library(): import reference as R # noqa: E402 SOURCE = HERE / "engine.asm" -STATE_LAST = 0x63 +STATE_LAST = 0x70 NAMES = {name.lower(): i for i, name in enumerate(R.KNOBS)} From 0b0448ecd04845a7a89a03a6d81127e608cdbaf4 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 16:55:25 -0600 Subject: [PATCH 08/16] Cassettebox: the even harmonic removed (the author: not worth its cost) Uneven heads and creases stay. State back to $00-$6f (wear's low word and the seeded flag at $2d/$2e again). verify.py bit for bit; test_reference.py 31/31; worst 338.9 (1.08x SPRING REV, 1.02x DJ EQ), stamped. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 4 +- sdk/drafts/cassettebox/TESTING.md | 2 +- sdk/drafts/cassettebox/engine.asm | 55 +++++-------------- .../cassettebox/evidence/performance.json | 12 ++-- sdk/drafts/cassettebox/manifest.py | 2 +- sdk/drafts/cassettebox/octamod.module.json | 2 +- sdk/drafts/cassettebox/reference.py | 21 +++---- sdk/drafts/cassettebox/test_reference.py | 17 ------ sdk/drafts/cassettebox/verify.py | 4 +- 9 files changed, 34 insertions(+), 85 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 72eb4bdc32..db3c601600 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -17,7 +17,7 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pock |---|---|---|---|---|---| | Main | A | DRFT | 0-127 | 32 | Drift: the tape speed's slow sway and wander. 0 is steady. | | Main | B | FLUT | 0-127 | 24 | Flutter: the fast shimmering wobble, and a worn pinch roller's faint thump in speed and level about once a second. | -| Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder), with more of tape's warm, uneven 2nd harmonic. Loud, bright passages dull out more, as real tape does. | +| Main | C | DRIV | 0-127 | 32 | Drive: saturation and compression, the tape pushed harder (and louder). Loud, bright passages dull out more, as real tape does. | | Main | D | HISS | 0-127 | 16 | Tape hiss, shaped by the deck. It breathes with the track: full under loud passages, down to about a third in the gaps. | | Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. Each one muffles before it dips and comes back bright last. Now and then a crease crosses the head too: a tenth of a second of crinkly wobble and flickering muffle. Rare at low settings, frequent near 127. | | Main | F | MIX | 0-127 | 127 | Dry/tape blend. 127 is the tape alone, 0 the dry track. | @@ -64,5 +64,5 @@ None yet. ## Develop -- Hear it: `npm run module:dev -- cassettebox --cycles 358 --cycles-kind executed --state 113 --buffer 1024 --slots both`. +- Hear it: `npm run module:dev -- cassettebox --cycles 339 --cycles-kind executed --state 112 --buffer 1024 --slots both`. - Check it: `npm run module:doctor -- --draft cassettebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`, and `python3 -B test_reference.py` tests the model. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index 521283c08b..49c0df2737 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 278 words; measured unsplit 306.7 to 307.1, worst 357.8 (the dearest POCKET setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1433.0 and 1330.2, 0 clobbers, 0 stray writes). 1.14x SPRING REV (314.19), 1.08x DJ EQ (330.94). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 260 words; measured unsplit 288.2 to 288.7, worst 338.9 (the dearest POCKET setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1357.5 and 1255.8, 0 clobbers, 0 stray writes). 1.08x SPRING REV (314.19), 1.02x DJ EQ (330.94). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index 0f3ca20567..88002b6a4b 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -25,31 +25,31 @@ ; (r6+$c 8-15), DUST slot 8 (r6+$d 16-23), GLCH slot 9 (r6+$d 8-15), TONE slot ; 10 (r6+$e 16-23), AGE slot 11 (r6+$e 8-15). ; -; State (X, offsets from r7; init clears $00..$70): +; State (X, offsets from r7; init clears $00..$6f): ; $00 the ring's base (Y) $01 g, the artifacts' share (Q22) $02 the pointer r5 $03 the hiss LCG (left's noise) $04 wear (Q23) ; $05 LFSR $06/$07 each head's d (Q11.12) $08/$09 its step a sample $0a drift's phase $0b flutter's ; $0c/$0d each channel's wander $0e/$0f playback's low-pass states $10/$11 the bump's states ; $12/$13 the drive and its step $14/$15 the dropout gain and its step $16/$17 MIX and its step ; $18 the click $1a the top's coefficient $1b the bump's level $1c the hiss level ; $19 left's last noise word $1d a dropout's frames left $1e its gain $1f the hiccup (Q11.12) $20 the right head's dropout gain -; $21-$2c DRFT FLUT DRIV HISS GAPS MIX DECK WIDE DUST GLCH TONE AGE $2d/$2e each channel's even-harmonic offset $2f right's last noise word +; $21-$2c DRFT FLUT DRIV HISS GAPS MIX DECK WIDE DUST GLCH TONE AGE $2d wear's low word $2e seeded $2f right's last noise word ; $30/$31 drift's and flutter's swings (a call), then each channel's softened noise (a sample) $32-$3a nine random words $3b right's noise -; $3c the dry (scratch) $3d WIDE's phase offset, then the right head's gain step $3e right's wander, then the even -; harmonic's k $3f the drive's target, then the right head's top (the samples read these at short offsets) +; $3c the dry (scratch) $3d WIDE's phase offset, then the right head's gain step $3e right's wander +; $3f the drive's target, then the right head's top (the samples read these at short offsets) ; $40-$5f DECK's tables, four words each: drift, flutter, their rates, drive, hiss, top, bump ; $60 the call's loudest input, either channel (halved) $61 the level follower (loud highs dull, the hiss breathes) ; $62 the pinch roller's phase $63 the level (the roller's dip and wear's sag; it scales the dropout gain) -; $64 wear's low word $65 seeded $66 the right head's top $67 the hiccup's target +; $66 the right head's top $67 the hiccup's target ; $69 the right head's wear phase $6a a crease's frames left $6d its chance's random word -; $6f what the right head's level loses $70 the even harmonic's k -; Nothing above $70 is touched. Every product is the signed mpy/mac x0,y1 +; $6f what the right head's level loses +; Nothing above $6f is touched. Every product is the signed mpy/mac x0,y1 ; form. Labels are cb and two characters, so none is another's prefix. ; CYCLES_FORWARD_BRANCHES init: clr a move r7,r5 move #>$ffffff,m5 - do #$71,>cbi0 + do #$70,>cbi0 move a,x:(r5)+ cbi0: nop @@ -203,11 +203,11 @@ proc: bne cbw1 clr a move a,x:(r7+$04) - move a,x:(r7+$64) + move a,x:(r7+$2d) bra cbw2 cbw1: move x:(r7+$04),a - move x:(r7+$64),a0 + move x:(r7+$2d),a0 add #>$100000,b asr #18,b,b add b,a @@ -215,7 +215,7 @@ cbw1: cmp b,a tgt b,a move a1,x:(r7+$04) - move a0,x:(r7+$64) + move a0,x:(r7+$2d) cbw2: ; ---- wear's own share of the artifacts: HISS, GAPS, DUST and GLCH each gain wear x a base (a worn tape hisses, ; drops out, crackles and glitches even from 0) @@ -337,11 +337,6 @@ cbe2: move #>$140000,y1 mac x0,y1,b move b,x:(r7+$3f) - move x:(r7+$23),x0 - move #>$11eb85,y1 - mpy x0,y1,a - add #>$07ae14,a - move a,x:(r7+$70) move x:(r7+$27),a add #>$54,a move a1,n1 @@ -840,7 +835,7 @@ cbk2: cbk3: ; ---- the runs: the first call snaps them; then the drive and MIX walk a 16th of the way a call, the dropout gain ; (x the level) a 32nd, a lost contact a quarter - move x:(r7+$65),a + move x:(r7+$2e),a tst a bne cbf1 move x:(r7+$3f),x0 @@ -848,7 +843,7 @@ cbk3: move x:(r7+$26),x0 move x0,x:(r7+$16) move #>$1,x0 - move x0,x:(r7+$65) + move x0,x:(r7+$2e) cbf1: move x:(r7+$3f),a move x:(r7+$12),x0 @@ -892,9 +887,7 @@ cbf3: sub x0,a asr #4,a,a move a,x:(r7+$17) -; for the samples, at short offsets: the even harmonic's k ($3e) and the right head's top ($3f; $3d holds its gain's step) - move x:(r7+$70),x0 - move x0,x:(r7+$3e) +; for the samples, at a short offset: the right head's top ($3f; $3d holds its gain's step) move x:(r7+$66),x0 move x0,x:(r7+$3f) ; ---- a filter state or click within SNAP of zero is zero (truncation would hold it a few LSB off) @@ -1044,16 +1037,6 @@ cbn4: mpy x0,y1,a move a,x1 move x0,b -; the even harmonic, k a^2, less its offset (followed at 5 Hz) - move x:(r7+$3e),x0 - mpy x0,y1,a - move x:(r7+$2d),y0 - add a,b - sub y0,b - sub y0,a - asr #11,a,a - add y0,a - move a1,x:(r7+$2d) move x1,x0 move #>$2aaaab,y1 mpy x0,y1,a @@ -1153,16 +1136,6 @@ cbn4: mpy x0,y1,a move a,x1 move x0,b -; the even harmonic, k a^2, less its offset (followed at 5 Hz) - move x:(r7+$3e),x0 - mpy x0,y1,a - move x:(r7+$2e),y0 - add a,b - sub y0,b - sub y0,a - asr #11,a,a - add y0,a - move a1,x:(r7+$2e) move x1,x0 move #>$2aaaab,y1 mpy x0,y1,a diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index b0d38f6597..5504e42475 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "1e8121160f783b1d86d28a0cdb9e4c4c066dcbf60fa41f9600756c4de4d4e910", + "sourceSha256": "c988bb955c93805bf08796fbd89735cc392d7bca0d5da30764cf7419961f0013", "kind": "dsp", "cycles": { "unit": "instructions/sample", - "static": 278, - "measured": 357.8, + "static": 260, + "measured": 338.9, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 278 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 306.7 to 307.1; worst 357.8, the dearest POCKET setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the uneven heads, the deck's figures, nine random words, two head targets with their sine and triangle, the events (a crease among them) and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 260 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 288.2 to 288.7; worst 338.9, the dearest POCKET setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the uneven heads, the deck's figures, nine random words, two head targets with their sine and triangle, the events (a crease among them) and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", @@ -17,7 +17,7 @@ "dearestWorst": 330.94, "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", - "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 357.80, is 1.14x SPRING REV's 314.19 and 1.08x DJ EQ's 330.94 (the extra is the tape's even harmonic with its offset follower on each channel, the right head's own gain, and per-call work, wear, the pinch roller, uneven heads and the events, which a trig split of 1 frame runs twice a block); unsplit 307.1 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic with an even harmonic (its offset followed and taken off), adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared and the right head has its own dropout gain." + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 338.90, is 1.08x SPRING REV's 314.19 and 1.02x DJ EQ's 330.94 (the extra is the right head's own gain and per-call work, wear, the pinch roller, uneven heads and the events, which a trig split of 1 frame runs twice a block); unsplit 288.7 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared and the right head has its own dropout gain." }, "stress": { "instancesPerCore": 4, @@ -29,6 +29,6 @@ "dirty": true, "clobbers": 0, "hangs": 0, - "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1433.0 and 1330.2 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1357.5 and 1255.8 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." } } diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index 247ad83be6..fcd89deafc 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -47,7 +47,7 @@ Param(b"FLUT", D["FLUT"], 128, active=True, formatter=P, doc="flutter: the fast shimmering wobble and a worn pinch roller's thump; 0 none"), Param(b"DRIV", D["DRIV"], 128, active=True, formatter=P, - doc="drive: saturation, compression and tape's warm 2nd harmonic, the tape pushed harder (and louder); loud highs dull out more"), + doc="drive: saturation and compression, the tape pushed harder (and louder); loud highs dull out more"), Param(b"HISS", D["HISS"], 128, active=True, formatter=P, doc="tape hiss, shaped by the deck; it breathes with the track, quieter in the gaps; 0 none"), Param(b"GAPS", D["GAPS"], 128, active=True, formatter=P, diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index cba514d592..0b99df949e 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -48,7 +48,7 @@ "name": "DRIV", "default": 32, "count": 128, - "doc": "Drive: saturation, compression and tape's warm 2nd harmonic, the tape pushed harder (and louder); loud highs dull out more.", + "doc": "Drive: saturation and compression, the tape pushed harder (and louder); loud highs dull out more.", "labels": null }, { diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index ec94024155..f00de5fbb7 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -91,8 +91,6 @@ def mpy(x, y): TH_L, TH_LW = 0x07ae14, 0x0a3d71 # its level dip at FLUT 127 (x g, 0.06), and what full wear adds (0.08) WEAR_LVL = 0x266666 # full wear leaves the tape 0.7 as loud (-3 dB) WEAR_BUMP = 0x266666 # and its head bump 0.3 lower (thinner lows) -WARM_B, WARM_R = 0x07ae14, 0x11eb85 # the tape's even harmonic: k a^2 added to the cubic, k 0.06 at DRIV 0 to 0.2 at 127 -DC_SHIFT = 11 # and the offset it makes, followed at about 3.4 Hz (a 2048th of the way a sample) and taken off HPR = round(0.05 * 16 / FS * Q) # uneven heads: the right head's wear wanders on a 20 s cycle IMB0, IMBW = 0x200000, 0x19999a # full wear dulls its top by 0.25, wandering 0.2 either way LVL_IMB = 0x266666 # and lowers its level by 0.3 of that @@ -134,7 +132,7 @@ class Model: block p (offset -> word) and returns [(left, right)].""" def __init__(self, base=0x4000): - self.x = [0] * 0x71 + self.x = [0] * 0x70 self.ring = [0] * RING x = self.x x[0x00] = base @@ -177,12 +175,12 @@ def call(self, frames, p): deck = x[0x27] # ---- wear: AGE 0 keeps the tape fresh; above, it wears (AGE + 16) << 6 a call (48-bit) if x[0x2c] == 0: - x[0x04] = x[0x64] = 0 + x[0x04] = x[0x2d] = 0 else: - wv = (x[0x04] << 24 | (x[0x64] & 0xffffff)) + ((x[0x2c] + AGE_MIN) << 6) + wv = (x[0x04] << 24 | (x[0x2d] & 0xffffff)) + ((x[0x2c] + AGE_MIN) << 6) if wv > 0x7fffff << 24: wv = 0x7fffff << 24 - x[0x04], x[0x64] = wv >> 24, wv & 0xffffff + x[0x04], x[0x2d] = wv >> 24, wv & 0xffffff wear = x[0x04] for kw, base in WEAR_BASE: # wear's own share of the artifacts x[kw] = lim(ld(x[kw]) + mpy(wear, base)) @@ -205,7 +203,6 @@ def call(self, frames, p): x[0x63] = lim(ld(0x7fffff) - mpy(pulse, amt_l) - mpy(wear, WEAR_LVL)) # ---- the deck's figures this call drv = lim(ld(DRVB[deck]) + mpy(x[0x23], DRVR) + mpy(wear, WEAR_DRV)) - x[0x70] = lim(mpy(x[0x23], WARM_R) + ld(WARM_B)) # the even harmonic's k hiss = more(lim(mpy(x[0x24], HISSB[deck]))) tonef = lim(ld(0x7fffff) - mpy(more(x[0x2b]), TONE_K)) wearf = lim(ld(0x7fffff) - mpy(wear, WEAR_HF)) @@ -276,9 +273,9 @@ def call(self, frames, p): elif r_c - more(lim(mpy(lim(mpy(x[0x25], x[0x25])), CREASEP))) < 0: x[0x6a] = CR_LEN + hi(mpy(r_clen, CR_RANGE)) # ---- the runs: each knob's gain walks a 16th of the way a sample (none snaps but at the first call) - if x[0x65] == 0: + if x[0x2e] == 0: x[0x12], x[0x16] = drv, x[0x26] - x[0x65] = 1 + x[0x2e] = 1 x[0x13] = lim(w56((ld(drv) - ld(x[0x12])) >> 4)) tgt = lim(mpy(x[0x1e], x[0x63])) # the dropout's gain x the level sh = 6 if x[0x1e] == CONTACT else 9 @@ -317,11 +314,7 @@ def sample(self, left, right): y0, y1 = ring[(p + o - i) % RING], ring[(p + o - i - 1) % RING] w = hi(mpy(lim(ld(y1) - ld(y0)), f) + ld(y0)) a = lim(w56(mpy(w, x[0x12]) << 2)) # the drive, x 4 - a2 = lim(mpy(a, a)) - w = mpy(x[0x70], a2) # the even harmonic, k a^2 - z = x[0x2d + ch] - x[0x2d + ch] = hi(w56((w - ld(z)) >> DC_SHIFT) + ld(z)) # its offset, followed at about 3.4 Hz - s = lim(ld(a) + w - ld(z) - mpy(lim(mpy(a2, a)), THIRD)) # the tape's cubic, the even harmonic less its offset + s = lim(ld(a) - mpy(lim(mpy(lim(mpy(a, a)), a)), THIRD)) # the tape's cubic s = lim(ld(s) + mpy(noise[ch], x[0x1c]) + ld(x[0x18])) # hiss and crackle, on the tape lp = 0x0e + ch x[lp] = hi(mpy(lim(ld(s) - ld(x[lp])), x[0x66 if ch else 0x1a]) + ld(x[lp])) # playback's top diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index 656f77d97b..4fcd558612 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -317,23 +317,6 @@ def test_a_worn_tape_is_quieter_and_thinner(self): self.assertLessEqual(m.x[0x63], 0x7fffff * 0.7 + 2) self.assertLess(m.x[0x1b], R.BUMP[1] - 0x260000) - def test_even_harmonic_warmth(self): - # a sine through the tape gains a 2nd harmonic that grows with DRIV, and the offset it makes is taken off - import numpy as np - n = 16 * 4000 - x = [round(0.5 * R.Q * math.sin(2 * math.pi * 441 * i / R.FS)) for i in range(n)] - def h2(driv): - l, _, _ = R.render(x, x, {0: knobs(QUIET, driv=driv, deck=0)}) - y = np.array(l[n // 2:], float) - s = np.abs(np.fft.rfft(y * np.hanning(len(y)))) - f = lambda hz: s[round(hz * len(y) / R.FS)] - return f(882) / f(441), abs(y.mean()) / R.Q - lo, dc_lo = h2(0) - hi, dc_hi = h2(127) - self.assertGreater(lo, 0.005) - self.assertGreater(hi, 2 * lo) - self.assertLess(max(dc_lo, dc_hi), 0.002) - def test_uneven_heads(self): # a fresh tape: both heads alike; worn out: the right head's top and level lower than the left's m = R.Model() diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py index 9858e84ae0..a1aaa673d9 100644 --- a/sdk/drafts/cassettebox/verify.py +++ b/sdk/drafts/cassettebox/verify.py @@ -11,7 +11,7 @@ Gates: 1. Every instruction decodes as written (signed mpy/mac x0,y1, no rep, no mpysu/macsu), no label is a - prefix of another (case-blind), the state stays inside X:(r7+$00..$70), and proc returns with every + prefix of another (case-blind), the state stays inside X:(r7+$00..$6f), and proc returns with every modifier register it set to a modulus linear again. 2. Bit for bit the model: every DECK at its defaults, its dearest and with every knob at 127, each knob alone at 127, every knob swept, AGE wearing a tape for 12 s, a 5-frame trig split every block, a knob word carrying an @@ -40,7 +40,7 @@ def _library(): import reference as R # noqa: E402 SOURCE = HERE / "engine.asm" -STATE_LAST = 0x70 +STATE_LAST = 0x6f NAMES = {name.lower(): i for i, name in enumerate(R.KNOBS)} From 28afe6c886db2a4320af37e0a8fb6ced5240f689 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 17:30:23 -0600 Subject: [PATCH 09/16] Cassettebox: AGE 1-10 hold the tape as worn as it is Let it wear, then turn AGE into 1-10 to keep that sound; 11-127 wear at AGE + 16 (half wear 3.8 minutes at 11, 43 s at 127); 0 resets. verify.py gains the hold (1, 10, 11, 127, 0) bit for bit; test_reference.py 32/32; worst 339.2 (1.08x SPRING REV), stamped. Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 8 ++--- sdk/drafts/cassettebox/TESTING.md | 2 +- sdk/drafts/cassettebox/engine.asm | 7 +++-- .../cassettebox/evidence/performance.json | 10 +++---- sdk/drafts/cassettebox/manifest.py | 2 +- sdk/drafts/cassettebox/octamod.module.json | 4 +-- sdk/drafts/cassettebox/reference.py | 8 +++-- sdk/drafts/cassettebox/test_reference.py | 29 ++++++++++++++++--- sdk/drafts/cassettebox/verify.py | 6 +++- 9 files changed, 54 insertions(+), 22 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index db3c601600..10a837d5f8 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -26,7 +26,7 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pock | Setup | C | DUST | 0-127 | 0 | Crackle: soft pops, an occasional tick at low settings and a steady crackle near 127. | | Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed swoop, or a moment of lost head contact that drops the sound nearly out. Rare at low settings. | | Setup | E | TONE | 0-127 | 0 | Darkens the top end, as worn heads or a cheap copy do. 0 is the deck's own. | -| Setup | F | AGE | 0-127 | 0 | Wear over time. At 0 the knobs apply at once. Above 0 the tape starts clean, and drift, flutter, hiss, dropouts, crackle, glitches and TONE grow toward their knob positions, reaching them at half wear and going on to about twice them when worn out. As it wears the top fades, the tape gets grainier, quieter (about 3 dB when worn out) and thinner in the lows, the pinch roller thumps harder, the two heads wear unevenly (the right one slowly drifts duller and a little quieter), and a worn tape gains some hiss, dropouts, crackle and glitches of its own, even with those knobs at 0. Half wear takes about 43 s at 127, 1.3 minutes at 64, 2 minutes at 32 and 6 minutes at 1. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | +| Setup | F | AGE | 0-127 | 0 | Wear over time. At 0 the knobs apply at once. From 11 up the tape starts clean and wears as it plays, and drift, flutter, hiss, dropouts, crackle, glitches and TONE grow toward their knob positions, reaching them at half wear and going on to about twice them when worn out. As it wears the top fades, the tape gets grainier, quieter (about 3 dB when worn out) and thinner in the lows, the pinch roller thumps harder, the two heads wear unevenly (the right one slowly drifts duller and a little quieter), and a worn tape gains some hiss, dropouts, crackle and glitches of its own, even with those knobs at 0. Half wear takes about 43 s at 127, 1.3 minutes at 64, 2 minutes at 32 and 3.8 minutes at 11. 1 to 10 hold the tape as worn as it is: let it wear to a sound you like, then turn AGE down into 1-10 to keep it there. The tape starts fresh when the effect is picked, the Part reloads or AGE goes back to 0. | ## Usage @@ -38,14 +38,14 @@ Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to CASSETTEB 2. Raise DRFT and FLUT for a seasick warble, and DRIV to push the tape into saturation. 3. Hold FUNC and press FX1, and try DECK on STUDIO, POCKET and VHS. 4. Raise GAPS, DUST and GLCH for a worn, dropout-prone tape. -5. Set GAPS, DUST and the others where you'd like the tape to end up, then turn AGE up and let the pattern play. The tape starts clean and degrades toward those settings over a minute or two (up to about 6 minutes at low AGE), then keeps getting worse. +5. Set GAPS, DUST and the others where you'd like the tape to end up, then turn AGE up and let the pattern play. The tape starts clean and degrades toward those settings over a minute or two (up to about 4 minutes at low AGE), then keeps getting worse. When it sounds right, turn AGE down to between 1 and 10 to hold it there. ## Compatibility and limitations - FX1 or FX2, any audio track. It uses 1,024 words of its slot's buffer. - The tape sits 5.8 ms (256 samples) behind the track, so the speed can sway both ways. The dry signal is read at the same delay, so MIX blends without combing, and MIX 0 is the dry track 5.8 ms late. - With HISS, DUST and AGE at 0, silence in gives exact silence out. With HISS or DUST up, or once AGE has worn the tape, it hisses and crackles when the track is quiet, as real tape does. -- Wear isn't saved: the tape starts fresh when the effect is picked or the Part reloads. Moving AGE off 0 starts a clean tape at once, so the knobs' character fades away and then grows back as it wears (half wear in about 6 minutes even at AGE 1). +- Wear isn't saved: the tape starts fresh when the effect is picked or the Part reloads. Moving AGE off 0 starts a clean tape at once, so the knobs' character fades away and then grows back as it wears (half wear in about 4 minutes even at AGE 11). AGE 1 to 10 hold a tape as it is, so a fresh tape held there stays fresh; turning AGE through 0 resets it. - Dropouts glide in and out over about 10 ms, so short ones are gentler than their full depth. A lost head contact drops out faster (about 1.5 ms) and reaches near silence, then glides back. - With several Cassettebox instances, each has its own hiss and random events (seeded by its slot), so their dropouts don't line up. - It prefers effect id 10, as Fuzzbox, Glitchbox, Loopbox, Grainbox and Midiverb do. Over USB the base gives each its own id; in a card set only one of them fits. @@ -64,5 +64,5 @@ None yet. ## Develop -- Hear it: `npm run module:dev -- cassettebox --cycles 339 --cycles-kind executed --state 112 --buffer 1024 --slots both`. +- Hear it: `npm run module:dev -- cassettebox --cycles 340 --cycles-kind executed --state 112 --buffer 1024 --slots both`. - Check it: `npm run module:doctor -- --draft cassettebox`; `python3 -B verify.py` holds the engine to `reference.py` in `dsp_host`, and `python3 -B test_reference.py` tests the model. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index 49c0df2737..f2b76a5c8a 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 260 words; measured unsplit 288.2 to 288.7, worst 338.9 (the dearest POCKET setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1357.5 and 1255.8, 0 clobbers, 0 stray writes). 1.08x SPRING REV (314.19), 1.02x DJ EQ (330.94). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 260 words; measured unsplit 288.2 to 288.9, worst 339.2 (the dearest STUDIO setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1359.0 and 1256.9, 0 clobbers, 0 stray writes). 1.08x SPRING REV (314.19), 1.02x DJ EQ (330.94). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index 88002b6a4b..b5e00f181a 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -15,7 +15,7 @@ ; one-pole, DECK's level), dropouts' gain and crackle, then MIX. ; DECK: STUDIO, HOME, POCKET, VHS (drift, flutter, drive, hiss, top, bump; VHS's ; negative bump cuts the lows). -; AGE: 0 keeps the tape fresh; above it wears (AGE + 16) << 6 a call (48-bit); +; AGE: 0 keeps the tape fresh; 1-10 hold the wear; above it wears (AGE + 16) << 6 a call; ; wear lifts the drive, darkens the top, lowers the level and the bump, and ; scales the drift, flutter, hiss, dropouts, glitches, crackle and the pinch ; roller's thump (once a turn, about 0.9 Hz, a bump in speed and level). @@ -197,7 +197,7 @@ proc: and #>$00ff00,a asl #8,a,a move a1,x:(r7+$2c) -; ---- wear: AGE 0 keeps the tape fresh; above, AGE << 6 a call into wear's 48 bits, at most whole +; ---- wear: AGE 0 keeps the tape fresh; AGE 1-10 hold it; above, (AGE + 16) << 6 a call into wear's 48 bits, at most whole move x:(r7+$2c),b tst b bne cbw1 @@ -206,6 +206,9 @@ proc: move a,x:(r7+$2d) bra cbw2 cbw1: + move #>$0a0000,x0 + cmp x0,b + ble cbw2 move x:(r7+$04),a move x:(r7+$2d),a0 add #>$100000,b diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index 5504e42475..593d5a7e19 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "c988bb955c93805bf08796fbd89735cc392d7bca0d5da30764cf7419961f0013", + "sourceSha256": "a28e12e38f3b50a828d06c011f2e7327bfc08171a11f71578828ce20bc1d8d24", "kind": "dsp", "cycles": { "unit": "instructions/sample", "static": 260, - "measured": 338.9, + "measured": 339.2, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 260 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 288.2 to 288.7; worst 338.9, the dearest POCKET setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the uneven heads, the deck's figures, nine random words, two head targets with their sine and triangle, the events (a crease among them) and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 260 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 288.2 to 288.9; worst 339.2, the dearest STUDIO setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the uneven heads, the deck's figures, nine random words, two head targets with their sine and triangle, the events (a crease among them) and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", @@ -17,7 +17,7 @@ "dearestWorst": 330.94, "baseline": "E-Verb's record (perf.py bench on the original image): SPRING REV, the cost target for new FX, worst 314.19 with trig splits (257.50 unsplit); DJ EQ, the dearest stock effect, 330.94 (293.38 unsplit), through fixed, moving and trig-split-1-15 cases. Not re-run for Cassettebox; its own cases match those (fixed, moving, a split at every position 1-15).", "stockSha256": "164f31224bf61181e3f50e7dec40df9afcae5b16dbf6e4c0d0cc5e986af0a84e", - "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 338.90, is 1.08x SPRING REV's 314.19 and 1.02x DJ EQ's 330.94 (the extra is the right head's own gain and per-call work, wear, the pinch roller, uneven heads and the events, which a trig split of 1 frame runs twice a block); unsplit 288.7 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared and the right head has its own dropout gain." + "justification": "No stock effect plays a track through a modelled cassette deck. SPRING REV is the cost target for a new FX and, like Cassettebox, reads and writes a delay buffer every sample. Cassettebox's worst, 339.20, is 1.08x SPRING REV's 314.19 and 1.02x DJ EQ's 330.94 (the extra is the right head's own gain and per-call work, wear, the pinch roller, uneven heads and the events, which a trig split of 1 frame runs twice a block); unsplit 288.9 against 257.50 and 293.38. Per sample it runs two hiss-generator steps and tracks the louder input's peak for the level follower (loud highs dull out, the hiss breathes); per channel it writes the track into a 1,024-word ring, reads the dry and an interpolated head, drives a cubic, adds softened hiss and crackle, runs a low-pass and a head bump, applies the dropout gain and crackle, and blends with MIX; three gain runs are shared and the right head has its own dropout gain." }, "stress": { "instancesPerCore": 4, @@ -29,6 +29,6 @@ "dirty": true, "clobbers": 0, "hangs": 0, - "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1357.5 and 1255.8 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." + "method": "perf.py --stress: the load is driven straight into dsp_host on verify.py's synthetic image with both cores: eight Cassettebox instances, four a core, each on its own stem (decaying noise bursts, a full-scale square, a 20 Hz-20 kHz sweep, full-scale noise, impulses, full-scale DC steps, silence, a three-note chord) for 2 s plus a 2 s tail; all twelve parameter words given a new value every block through the moving pattern, trig splits of 1, 3, 7, 8, 12 and 15 frames, -guard 0x4000 -guard-shared and -dirty: dsp_host exit 0, 0 stray writes, 0 clobbers, per-core peaks 1359.0 and 1256.9 of 3120. dsp_host hands every instance the same allocator entry, so the eight rings overlap here; on a unit each slot has its own buffer." } } diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index fcd89deafc..fe70017a0c 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -65,7 +65,7 @@ Param(b"TONE", D["TONE"], 128, active=True, formatter=P, doc="darkens the top end, as worn heads or a cheap copy do; 0 the deck's own"), Param(b"AGE", D["AGE"], 128, active=True, formatter=P, - doc="wear over time: 0 applies the knobs at once; above, the tape starts clean and the artifacts grow toward the knobs (reached at half wear: about 43 s at 127, 6 minutes at 1), then on to twice them worn out, quieter and thinner"), + doc="wear over time: 0 applies the knobs at once; 1-10 hold the tape as worn as it is; from 11 the tape starts clean and the artifacts grow toward the knobs (reached at half wear: about 43 s at 127, 4 minutes at 11), then on to twice them worn out, quieter and thinner"), ), dsp=DspSection( diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index 0b99df949e..2dc50a899c 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -26,7 +26,7 @@ ], "usage": [ "Start on HOME with the defaults on a pad, a drum loop or a whole mix, then raise DRFT and FLUT for warble and DRIV for saturation.", - "Turn up AGE and let it play: the tape wears over a minute or two." + "Turn up AGE and let it play: the tape wears over a minute or two; turn AGE down to 1-10 to hold it." ] }, "controls": [ @@ -116,7 +116,7 @@ "name": "AGE", "default": 0, "count": 128, - "doc": "Wear over time: 0 applies the knobs at once; above, the tape starts clean and the artifacts grow toward the knobs (reached at half wear, about 43 s at 127, 6 minutes at 1), then on to twice them worn out, quieter and thinner.", + "doc": "Wear over time: 0 applies the knobs at once; 1-10 hold the tape as worn as it is; from 11 the tape starts clean and the artifacts grow toward the knobs (reached at half wear, about 43 s at 127, 4 minutes at 11), then on to twice them worn out, quieter and thinner.", "labels": null } ], diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index f00de5fbb7..3c7f0ba2f8 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -85,7 +85,8 @@ def mpy(x, y): HFSAT = 0x600000 # loud highs dull out: at full level and DRIV 127 the top's coefficient falls to 0.25 BREATH, BREATH_R = 0x2ccccd, 0x533333 # the hiss breathes with the level: 0.35 in silence, whole at full level STEPMAX = 246 # the head's step a sample at most, Q11.12 (6 % speed): a sudden knob change glides -AGE_MIN = 16 << 16 # wear's speed is AGE + 16: AGE 1 reaches half wear in about 6 minutes, AGE 127 in about 43 s +AGE_HOLD = 10 << 16 # AGE 1 to 10 hold the wear where it is +AGE_MIN = 16 << 16 # wear's speed is AGE + 16: AGE 11 reaches half wear in about 3.8 minutes, AGE 127 in about 43 s THR = round(0.9 * 16 / FS * Q) # the pinch roller turns about 0.9 times a second TH_S, TH_SW = 12 << 12, 8 << 12 # its speed bump at FLUT 127 (x g), and what full wear adds, Q11.12 samples TH_L, TH_LW = 0x07ae14, 0x0a3d71 # its level dip at FLUT 127 (x g, 0.06), and what full wear adds (0.08) @@ -173,9 +174,12 @@ def call(self, frames, p): x[0x2b] = p.get(0xe, 0) & 0x7f0000 # TONE x[0x2c] = (p.get(0xe, 0) & 0x00ff00) << 8 # AGE deck = x[0x27] - # ---- wear: AGE 0 keeps the tape fresh; above, it wears (AGE + 16) << 6 a call (48-bit) + # ---- wear: AGE 0 keeps the tape fresh; AGE 1-10 hold it as worn as it is; above, it wears (AGE + 16) << 6 a + # call (48-bit) if x[0x2c] == 0: x[0x04] = x[0x2d] = 0 + elif x[0x2c] <= AGE_HOLD: + pass else: wv = (x[0x04] << 24 | (x[0x2d] & 0xffffff)) + ((x[0x2c] + AGE_MIN) << 6) if wv > 0x7fffff << 24: diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index 4fcd558612..dd206dc50e 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -282,16 +282,37 @@ def worst_step(**kw): self.assertLess(low, 0x1c0000) # a lost contact dips below 0.22 (it reached 0.3 to 0.5 at the slow glide) def test_low_age_still_wears(self): - # wear's speed is AGE + 16: AGE 1 wears 17/143 as fast as 127, so half wear takes about 6 minutes, not hours + # wear's speed is AGE + 16: AGE 11 (the slowest; 1-10 hold) wears 27/143 as fast as 127, half wear in about 3.8 minutes def wear(age, calls=2000): m = R.Model() row = R.pblock(knobs(QUIET, age=age)) for _ in range(calls): m.call([(0, 0)] * 16, row) return m.x[0x04] - self.assertAlmostEqual(wear(1) / wear(127), 17 / 143, places=2) - half = 0x400000 / (wear(1) / 2000) * 16 / R.FS - self.assertTrue(300 < half < 420, half) + self.assertAlmostEqual(wear(11) / wear(127), 27 / 143, places=2) + half = 0x400000 / (wear(11) / 2000) * 16 / R.FS + self.assertTrue(200 < half < 260, half) + + def test_age_1_to_10_hold_the_wear(self): + # wear at 127 for a while; AGE 1 to 10 hold it exactly (and the knobs' share with it); 11 and 127 wear on; 0 resets + m = R.Model() + worn = R.pblock(knobs(QUIET, gaps=64, age=127)) + for _ in range(5000): + m.call([(0, 0)] * 16, worn) + w = m.x[0x04] + self.assertGreater(w, 0) + for age in range(1, 11): + for _ in range(500): + m.call([(0, 0)] * 16, R.pblock(knobs(QUIET, gaps=64, age=age))) + self.assertEqual(m.x[0x04], w) + self.assertEqual(m.x[0x01], w) + m.call([(0, 0)] * 16, R.pblock(knobs(QUIET, gaps=64, age=11))) + self.assertGreater(m.x[0x04], w) + w = m.x[0x04] + m.call([(0, 0)] * 16, worn) + self.assertGreater(m.x[0x04], w) + m.call([(0, 0)] * 16, R.pblock(knobs(QUIET, gaps=64))) + self.assertEqual(m.x[0x04], 0) def test_pinch_roller_thumps(self): # FLUT 127 on a fresh tape: the level dips about 6 % once a turn (about 0.9 Hz), and rests at 1 between diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py index a1aaa673d9..6ee4c217c4 100644 --- a/sdk/drafts/cassettebox/verify.py +++ b/sdk/drafts/cassettebox/verify.py @@ -14,7 +14,7 @@ prefix of another (case-blind), the state stays inside X:(r7+$00..$6f), and proc returns with every modifier register it set to a modulus linear again. 2. Bit for bit the model: every DECK at its defaults, its dearest and with every knob at 127, each knob alone at - 127, every knob swept, AGE wearing a tape for 12 s, a 5-frame trig split every block, a knob word carrying an + 127, every knob swept, AGE wearing a tape for 12 s, AGE 1 and 10 holding it, a 5-frame trig split every block, a knob word carrying an LFO's fraction bits, garbage state before init, state from two seeds, and two real FX1 bases. 3. MIX 0 is the track exactly, 256 samples late (the tape's centre, so MIX never combs); with HISS, DUST and AGE at 0, silence in is exact silence out and a burst's tail ends in exact silence, at every DECK. @@ -120,6 +120,10 @@ def same(name, inst, raw=None, **kw): ll, lr = G.noise(long_n, 0.5, 5), G.noise(long_n, 0.5, 6) same("2 AGE 127 wearing the tape for 12 s, HOME, every artifact up", G.Instance(ll, lr, knobs=knobs( drft=64, flut=64, hiss=64, gaps=64, dust=64, glch=64, age=127))) + hold = knobs(drft=64, flut=64, hiss=64, gaps=64, dust=64, glch=64, age=127) + same("2 AGE 1 and 10 hold a worn tape, 11 and 127 wear it on, 0 resets it", G.Instance(ll, lr, rows={ + 0: hold, 6000: knobs(hold, age=1), 10000: knobs(hold, age=10), 14000: knobs(hold, age=11), + 17000: knobs(hold, age=127), 22000: knobs(hold, age=0)})) same("2 a trig split every block", G.Instance(nl, nr, rows=rows), split=5) word = (100 << 16) | 0xb700 same("2 a knob word with an LFO's fraction bits", G.Instance(nl, nr, knobs=R.DEFAULTS), pwords=[(0, 0, word)], raw={0: word}) From 37a9987f300a6b4df1dcfbe00f8aacd124e9287d Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 17:55:44 -0600 Subject: [PATCH 10/16] Cassettebox: DECK names fit the Octatrack's five letters (HIFI, HOME, POCKT, VHS) The unit showed STUDIO as STUDI and POCKET as POCKE in the setup page's header (step 11 of the procedure). Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 6 +++--- sdk/drafts/cassettebox/TESTING.md | 2 +- sdk/drafts/cassettebox/engine.asm | 2 +- sdk/drafts/cassettebox/evidence/performance.json | 4 ++-- sdk/drafts/cassettebox/manifest.py | 4 ++-- sdk/drafts/cassettebox/octamod.module.json | 10 +++++----- sdk/drafts/cassettebox/reference.py | 6 +++--- sdk/drafts/cassettebox/test_reference.py | 4 ++-- sdk/drafts/cassettebox/verify.py | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 10a837d5f8..61fae0a1a5 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -9,7 +9,7 @@ Cassettebox is an '80s cassette deck, or an aged VHS tape's sound, for an audio - **The tape colours it:** DRIV saturates it, and the playback rolls off the top and lifts a bump in the lows. - **The tape is imperfect:** HISS and DUST (crackle) ride on it, GAPS brings dropouts, and GLCH brings speed hiccups and lost head contact. -DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pocket recorder; or VHS, the sound of an old videotape. WIDE parts the left and right channels, and TONE darkens the top. AGE wears the tape while it plays, as a loop recorded over again and again: the top fades, the hiss and crackle grow, dropouts come more often and the speed grows less steady. MIX blends the tape with the dry track. +DECK picks the machine: HIFI, a good deck; HOME, a home stereo; POCKT, a pocket recorder; or VHS, the sound of an old videotape. WIDE parts the left and right channels, and TONE darkens the top. AGE wears the tape while it plays, as a loop recorded over again and again: the top fades, the hiss and crackle grow, dropouts come more often and the speed grows less steady. MIX blends the tape with the dry track. ## Controls @@ -21,7 +21,7 @@ DECK picks the machine: STUDIO, a good deck; HOME, a home stereo; POCKET, a pock | Main | D | HISS | 0-127 | 16 | Tape hiss, shaped by the deck. It breathes with the track: full under loud passages, down to about a third in the gaps. | | Main | E | GAPS | 0-127 | 0 | Dropouts: how often the level dips and muffles, as on creased or worn tape. Each one muffles before it dips and comes back bright last. Now and then a crease crosses the head too: a tenth of a second of crinkly wobble and flickering muffle. Rare at low settings, frequent near 127. | | Main | F | MIX | 0-127 | 127 | Dry/tape blend. 127 is the tape alone, 0 the dry track. | -| Setup | A | DECK | STUDIO, HOME, POCKET, VHS | HOME | The machine: its tone, head bump, saturation, hiss and how steady it runs. STUDIO is clean and steady, HOME duller with more hiss and a little warble, POCKET narrow, hissy, fluttery and crunchy, VHS an aged videotape: thin lows, a muffled top and a slow, deep warble. | +| Setup | A | DECK | HIFI, HOME, POCKT, VHS | HOME | The machine: its tone, head bump, saturation, hiss and how steady it runs. HIFI is clean and steady, HOME duller with more hiss and a little warble, POCKT narrow, hissy, fluttery and crunchy, VHS an aged videotape: thin lows, a muffled top and a slow, deep warble. | | Setup | B | WIDE | 0-127 | 32 | Stereo: left and right drift and flutter apart, and the right head sits slightly misaligned. | | Setup | C | DUST | 0-127 | 0 | Crackle: soft pops, an occasional tick at low settings and a steady crackle near 127. | | Setup | D | GLCH | 0-127 | 0 | Glitches: now and then a speed swoop, or a moment of lost head contact that drops the sound nearly out. Rare at low settings. | @@ -36,7 +36,7 @@ Select an audio track, hold FUNC and press FX1 (or FX2), turn LEVEL to CASSETTEB 1. Put Cassettebox on FX1 of a track playing a pad, a drum loop or a whole mix. At the defaults it is a HOME deck with a little warble and hiss. 2. Raise DRFT and FLUT for a seasick warble, and DRIV to push the tape into saturation. -3. Hold FUNC and press FX1, and try DECK on STUDIO, POCKET and VHS. +3. Hold FUNC and press FX1, and try DECK on HIFI, POCKT and VHS. 4. Raise GAPS, DUST and GLCH for a worn, dropout-prone tape. 5. Set GAPS, DUST and the others where you'd like the tape to end up, then turn AGE up and let the pattern play. The tape starts clean and degrades toward those settings over a minute or two (up to about 4 minutes at low AGE), then keeps getting worse. When it sounds right, turn AGE down to between 1 and 10 to hold it there. diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index f2b76a5c8a..2e8ce83de3 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -20,4 +20,4 @@ Not tested. npm run fx:audit checks aliasing, DC, clipping and idle behaviour (d ## Performance -`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 260 words; measured unsplit 288.2 to 288.9, worst 339.2 (the dearest STUDIO setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1359.0 and 1256.9, 0 clobbers, 0 stray writes). 1.08x SPRING REV (314.19), 1.02x DJ EQ (330.94). +`python3 -B perf.py` in dsp_host, then `npm run perf:audit -- check evidence/performance.json --stamp`, 4 December 2026: static loop 260 words; measured unsplit 288.2 to 288.9, worst 339.2 (the dearest HIFI setting with a split of 1 frame); stress clean (eight instances, per-core peaks 1359.0 and 1256.9, 0 clobbers, 0 stray writes). 1.08x SPRING REV (314.19), 1.02x DJ EQ (330.94). diff --git a/sdk/drafts/cassettebox/engine.asm b/sdk/drafts/cassettebox/engine.asm index b5e00f181a..b88239f48d 100644 --- a/sdk/drafts/cassettebox/engine.asm +++ b/sdk/drafts/cassettebox/engine.asm @@ -13,7 +13,7 @@ ; (a 24-bit LCG, two steps a sample: left's word, then right's; seeded by the base), playback's top (a ; one-pole low-pass, DECK x TONE x wear x a dropout's dip), a head bump (110 Hz ; one-pole, DECK's level), dropouts' gain and crackle, then MIX. -; DECK: STUDIO, HOME, POCKET, VHS (drift, flutter, drive, hiss, top, bump; VHS's +; DECK: HIFI, HOME, POCKT, VHS (drift, flutter, drive, hiss, top, bump; VHS's ; negative bump cuts the lows). ; AGE: 0 keeps the tape fresh; 1-10 hold the wear; above it wears (AGE + 16) << 6 a call; ; wear lifts the drive, darkens the top, lowers the level and the bump, and diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index 593d5a7e19..4acd1f8988 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,14 +2,14 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "a28e12e38f3b50a828d06c011f2e7327bfc08171a11f71578828ce20bc1d8d24", + "sourceSha256": "a004a83027bbb56515ef40a2d68f2d27c92fea9b41b3a4ac5a372637deeba6f8", "kind": "dsp", "cycles": { "unit": "instructions/sample", "static": 260, "measured": 339.2, "instancesPerCore": 4, - "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 260 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 288.2 to 288.9; worst 339.2, the dearest STUDIO setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the uneven heads, the deck's figures, nine random words, two head targets with their sine and triangle, the events (a crease among them) and the runs) runs twice a block." + "method": "static: perf.py, by the rule tools/build/cycle_count.py prices straight-line code (one cycle a word): the per-sample loop between `do n7,>cbsl` and cbsl, 260 words; it has no branch, bsr, nested do or rep, so every sample runs every word. measured: perf.py in dsp_host on verify.py's synthetic image, executed instructions a sample from dsp_host's meter, 80 cases (the defaults, the dearest setting for each DECK (four), a moving pattern, each unsplit and with a trig split at every position 1-15): unsplit 288.2 to 288.9; worst 339.2, the dearest HIFI setting with a split of 1 frame, where the per-call work (the knobs, wear and its share of the artifacts, the level follower, the pinch roller, the uneven heads, the deck's figures, nine random words, two head targets with their sine and triangle, the events (a crease among them) and the runs) runs twice a block." }, "stock": { "comparator": "SPRING REV", diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index fe70017a0c..0df497433d 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -3,7 +3,7 @@ The track goes onto a short tape (a 1,024-word ring in its slot's buffer) and plays back through a moving head: DRFT (a slow drift and wander) and FLUT (fast flutter) bend the speed, DRIV saturates the tape, the playback rolls off the top and lifts a head bump, HISS and DUST (crackle) ride on it, GAPS (dropouts) and GLCH (speed hiccups and -lost head contact) come and go. DECK picks the machine (STUDIO, HOME, POCKET, or VHS for an aged videotape's sound), WIDE parts the channels, TONE +lost head contact) come and go. DECK picks the machine (HIFI, HOME, POCKT, or VHS for an aged videotape's sound), WIDE parts the channels, TONE darkens it, and AGE wears the tape while it plays, as a loop recorded over again and again: the tape starts clean and the artifacts grow toward the knobs' positions. MIX blends the tape with the dry track, read at the tape's centre delay (5.8 ms) so the two never comb. @@ -55,7 +55,7 @@ Param(b"MIX", D["MIX"], 128, active=True, formatter=P, doc="dry/tape blend; 127 the tape alone, 0 the dry track (5.8 ms late, as the tape is)"), Param(b"DECK", D["DECK"], 4, active=True, formatter=S, labels=_ref.DECKS, - doc="the machine: STUDIO (a good deck), HOME (a home stereo), POCKET (a pocket recorder) or VHS (an aged videotape's sound)"), + doc="the machine: HIFI (a good deck), HOME (a home stereo), POCKT (a pocket recorder) or VHS (an aged videotape's sound)"), Param(b"WIDE", D["WIDE"], 128, active=True, formatter=P, doc="stereo: left and right drift and flutter apart, the right head slightly misaligned"), Param(b"DUST", D["DUST"], 128, active=True, formatter=P, diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index 2dc50a899c..d0d8545741 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -16,9 +16,9 @@ "label": "CASS", "family": "Tape", "summary": "An '80s cassette deck, or an aged VHS tape's sound, on FX1 or FX2: drift and flutter, tape saturation, hiss, crackle, dropouts and glitches, and tape that wears as it plays.", - "overview": "Cassettebox puts the track on a short tape and plays it back through a moving head. DRFT and FLUT bend the speed, DRIV saturates the tape, and the playback rolls off the top and lifts a bump in the lows. HISS and DUST ride on it, and GAPS and GLCH bring dropouts, speed hiccups and lost head contact. DECK picks the machine: STUDIO, HOME, POCKET, or VHS for an aged videotape's narrow, warbly sound. WIDE parts the channels, TONE darkens the top, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape with the dry track, which is read at the tape's centre delay so the two never comb.", + "overview": "Cassettebox puts the track on a short tape and plays it back through a moving head. DRFT and FLUT bend the speed, DRIV saturates the tape, and the playback rolls off the top and lifts a bump in the lows. HISS and DUST ride on it, and GAPS and GLCH bring dropouts, speed hiccups and lost head contact. DECK picks the machine: HIFI, HOME, POCKT, or VHS for an aged videotape's narrow, warbly sound. WIDE parts the channels, TONE darkens the top, and AGE wears the tape while it plays, as a loop recorded over again and again. MIX blends the tape with the dry track, which is read at the tape's centre delay so the two never comb.", "highlights": [ - "Four decks: STUDIO, HOME, POCKET and VHS", + "Four decks: HIFI, HOME, POCKT and VHS", "Drift, flutter, saturation and a head bump; loud highs dull out and the hiss breathes, as on real tape", "Dropouts, speed swoops, lost head contact and soft crackle, rare at low settings", "AGE: the tape starts clean and degrades toward your knob settings, then beyond", @@ -76,11 +76,11 @@ "name": "DECK", "default": 1, "count": 4, - "doc": "The machine: STUDIO (a good deck), HOME (a home stereo), POCKET (a pocket recorder) or VHS (an aged videotape's sound).", + "doc": "The machine: HIFI (a good deck), HOME (a home stereo), POCKT (a pocket recorder) or VHS (an aged videotape's sound).", "labels": [ - "STUDIO", + "HIFI", "HOME", - "POCKET", + "POCKT", "VHS" ] }, diff --git a/sdk/drafts/cassettebox/reference.py b/sdk/drafts/cassettebox/reference.py index 3c7f0ba2f8..c450ecc4bc 100644 --- a/sdk/drafts/cassettebox/reference.py +++ b/sdk/drafts/cassettebox/reference.py @@ -4,7 +4,7 @@ must match it to the bit (verify.py). The design is original: an '80s cassette deck on an insert. The track goes onto a short tape (a ring in the slot's buffer) and is played back through a moving head: slow drift and fast flutter bend the speed, the tape saturates, the playback rolls off the top and lifts a bump in the lows, hiss and -crackle ride on it, and dropouts and glitches come and go. DECK picks the machine (STUDIO, HOME, POCKET); AGE +crackle ride on it, and dropouts and glitches come and go. DECK picks the machine (HIFI, HOME, POCKT); AGE wears the tape while it plays, as a loop recorded over again and again. No product's code, tables or names. """ import math @@ -52,8 +52,8 @@ def mpy(x, y): DMIN, DMAX = 2 << 12, 509 << 12 # the head's delay, Q11.12 samples DRY_N5 = -D0 # n5 for the dry read (left; right adds 512) -# DECK: STUDIO, HOME, POCKET, VHS (an aged videotape's linear audio: narrow, slow and deep warble, hissy) -DECKS = ("STUDIO", "HOME", "POCKET", "VHS") +# DECK: HIFI, HOME, POCKT, VHS (an aged videotape's linear audio: narrow, slow and deep warble, hissy) +DECKS = ("HIFI", "HOME", "POCKT", "VHS") WOWD = tuple(round(s * 4096) for s in (16, 32, 48, 44)) # drift's swing at DRFT 127, Q11.12 samples (wear doubles it) FLTD = tuple(round(s * 4096) for s in (3, 6, 12, 5)) # flutter's swing at FLUT 127 (wear doubles it) WOWR = tuple(round(f * 16 / FS * Q) for f in (0.55, 0.85, 1.3, 0.35)) # drift's cycle a call (Q23) diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index dd206dc50e..9b0707359b 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -113,7 +113,7 @@ def test_decks_differ(self): x = noise(3) outs = [R.render(x, x, {0: knobs(deck=d)})[0] for d in range(4)] self.assertEqual(len({tuple(o) for o in outs}), 4) - # POCKET is the darkest: least energy in the sample-to-sample differences + # POCKT is the darkest: least energy in the sample-to-sample differences hf = [energy([b - a for a, b in zip(o, o[1:])]) / energy(o) for o in outs] self.assertGreater(hf[0], hf[1]) self.assertGreater(hf[1], hf[2]) @@ -199,7 +199,7 @@ def test_each_instance_its_own_randomness(self): self.assertNotEqual(a, b) def test_a_sudden_knob_never_lurches_the_head(self): - # DRFT 0 to 127 on POCKET in one call: the head moves at most STEPMAX a sample + # DRFT 0 to 127 on POCKT in one call: the head moves at most STEPMAX a sample m = R.Model() for blk in range(600): row = R.pblock(knobs(QUIET, deck=2, drft=0 if blk < 300 else 127, flut=0 if blk < 300 else 127)) diff --git a/sdk/drafts/cassettebox/verify.py b/sdk/drafts/cassettebox/verify.py index 6ee4c217c4..2e809b7402 100644 --- a/sdk/drafts/cassettebox/verify.py +++ b/sdk/drafts/cassettebox/verify.py @@ -107,7 +107,7 @@ def same(name, inst, raw=None, **kw): for name in R.KNOBS: if name in ("DECK", "MIX"): continue - same(f"2 {name} alone at 127 (STUDIO)", G.Instance(tl, nl, knobs=knobs(quiet, **{name.lower(): 127}))) + same(f"2 {name} alone at 127 (HIFI)", G.Instance(tl, nl, knobs=knobs(quiet, **{name.lower(): 127}))) rows, block = {0: R.DEFAULTS}, 40 for slot, values in (("drft", (0, 127, 60)), ("flut", (0, 127, 40)), ("driv", (0, 127, 50)), ("hiss", (127, 0, 30)), ("gaps", (127, 0, 40)), ("mix", (0, 127, 90)), ("deck", (0, 2, 1)), ("wide", (127, 0, 50)), From d745607a6a61126730bc1672010a256b5b821d79 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 18:12:13 -0600 Subject: [PATCH 11/16] Cassettebox: the test procedure's record on package 534be9f6 (steps 1-11 passed) and its edge cases Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/TESTING.md | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index 2e8ce83de3..e9f2baffff 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -8,6 +8,66 @@ Record what you ran, on which build and which unit, and what you saw. "Not teste ## On the unit +### Test procedure: cassettebox 0.1.0-experimental, 2026-12-04 + +Build: revision `37a9987f300a`, package `cassettebox.mwrm` SHA-256 `534be9f61d75498f0a5f30960c9aedc217e0ae6f1eb454de2733f0150f5399d6`. `npm run test:procedure -- cassettebox --package /../cassettebox.mwrm --share /tmp/modwerk-share.sock --no-emulator --soak-pc-channel 11 --soak-auto-channel 11 --out `, 642 s. Emulator results are not hardware evidence; only what ran on the unit is. + +| # | Step | Layer | Result | Command | Evidence | +|---|---|---|---|---|---| +| 1 | Software checks | host | passed | `npm run module:doctor -- --draft cassettebox` | logs/01-software.log | +| 2 | Beside every other module | contract | not run: a draft is judged beside every other module by module:doctor --draft (its compatibility line, step 1) | | | +| 3 | Name the build | host | passed | | logs/03-build.log | +| 4 | DSP cost model | contract | passed | `node scripts/cycle-scan.mjs check` | logs/04-cost-model.log | +| 5 | Emulator rehearsal | emulator | not run: no emulator session: left out with --no-emulator | | | +| 6 | Read the unit | unit | passed: Part 1 on A01: working = saved, saved once so that RELOAD works at the end | `node scripts/device.mjs status --socket /tmp/modwerk-share.sock`
`node scripts/octatrack-part-state.mjs read --socket /tmp/modwerk-share.sock --out /part-start.json`
`node scripts/device.mjs do inventory --socket /tmp/modwerk-share.sock` | logs/06-unit-read.log | +| 7 | Scripted unit pass | unit | passed | `npm run device:test -- --share /tmp/modwerk-share.sock --testing-entry /device-test.md /../cassettebox.mwrm` | logs/07-unit-pass.log | +| 8 | Soak | unit | passed: Part 1 on A01: transport stopped, Part 1 on A01 reloaded; working = saved | `node scripts/device.mjs try /../cassettebox.mwrm --seconds 420 --socket /tmp/modwerk-share.sock`
`node scripts/octatrack-soak.mjs --seconds 120 --programs 0-3 --pc-channel 11 --auto-channel 11 --log /soak.json`
`node scripts/octatrack-part-state.mjs restore --socket /tmp/modwerk-share.sock --start /part-start.json` | logs/08-soak.log | +| 9 | Cost on the unit | unit | passed | `npm run device:price -- --share /tmp/modwerk-share.sock --out /price.json --scene 'the bank, pattern and Part the unit was on, transport stopped (test:procedure)' --curve T1,T3,T6,T7 /../cassettebox.mwrm` | logs/09-cost-unit.log | +| 10 | Put back | unit | passed: Part 1 on A01: nothing to put back; working = saved | `node scripts/device.mjs do inventory --socket /tmp/modwerk-share.sock`
`node scripts/octatrack-part-state.mjs restore --socket /tmp/modwerk-share.sock --start /part-start.json` | logs/10-restore.log | +| 11 | Agent by hand | unit | passed: on 534be9f6, Cassettebox on T1 FX1, T2 FX2 and T5 FX1 at once (both slots, both cores) while the pattern played: the defaults; every knob at 127 with DECK VHS; AGE to 7 (held); DECK HIFI and POCKT; MIX 0. Health after each: 0 stalls, 0 errors, no crash, CPU 614-658. After STOP: stall none recorded, latest entry 34.1 us late (0 in the guard's 80-190 us window). Main and setup pages match the README; each DECK name fits the header (HIFI, HOME, POCKT, VHS); the first run of this step, on 32b766b8, found STUDIO and POCKET cut to five letters (renamed, build 534be9f6). The sound not judged (the author's stage). STOP, Part reloaded, the trial rolled back. MAIN and CUE not recorded over USB: the recorder is not built on this computer | `device try`, `pick:T1:FX1:CASSETTEBOX`, `pick:T2:FX2:CASSETTEBOX`, `pick:T5:FX1:CASSETTEBOX`, `png:`, `health`, `stats`, `stall`, `late`, `reload` | main.png, setup.png, setup-full.png, age-hold.png, deck-hifi.png, deck-pockt.png | +| 12 | Submitter's own stage | unit | to do: the author's Keep and power cycle on 534be9f6 | | | + +#### Edge cases for this change + +Derive them from what the change touches and run each one (docs/TEST_PROCEDURE.md#edge-cases). A start, from the manifest and the changed files: + +- an effect slot: FX1 and FX2, both DSP cores, eight instances at once; one edited while another plays (docs/MODULE_QUALIFICATION.md#essential-persistence-and-instance-checks--8-october-2026) +- persistence: saved in a Part, then a Part reload, a project reload and a power cycle; removed while a saved Part still names it (docs/OCTATRACK_MODULE_EDGE_CASES.md#copying-and-saving) +- the loader: install, replace, remove and Undo; a set the base refuses rolls back whole; the pool full; a trial that expires with a page open (docs/OCTATRACK_HARDWARE_TRAPS.md#dsp-loader-dynamic-dsp-code) +- DSP code: DSP FULL; both cores; the receiver window; pipeline stalls the instruction count hides (docs/OCTATRACK_HARDWARE_TRAPS.md#coldfire-and-dsp-load) +- the USB link: USB unplugged mid-transfer; the host silent until the base rolls back; a reconnect (docs/OCTATRACK_HARDWARE_TRAPS.md#usb-and-ep0) +- load and admission: the pick at the 85 % line with the delays quiet and open; the guard counters while playing (docs/OCTATRACK_HARDWARE_TRAPS.md#coldfire-and-dsp-load) + +| Case | Why this change makes it a risk | How run | Result | +|---|---|---|---| +| FX1 and FX2, both cores | the ring sits in the slot's buffer: an FX1 slot's 1024-aligned 3,072 words, an FX2's 16K | step 7 (T1 and T5 FX2, each alone); step 11 (T1 FX1, T2 FX2, T5 FX1 at once); verify.py at FX1 bases $1c00 and $3400 | passed: T1 admitted in 115 ms (core 1 peak 484 per mille); three at once played clean; bit for bit at both FX1 bases in dsp_host | +| Eight instances at once | each its own ring and 112 state words | step 7: picked on T1-T8 FX2, playing | passed: six placed, CPU 663, core 1 peak 741, core 0 peak 853 per mille; two refused by the base for budget, no crash, stall or dropped frame | +| The frame-cost curve, playing | the per-call work (wear, events, the roller, uneven heads) runs on the ColdFire's frame | step 9: `device:price --curve T1,T3,T6,T7` | passed: at rest frame -0.1, cpu -0.2; adds +1.5, +0, +2.6, +1.7 (first 2.6, each 2.6); medium admitted, longest frame 89.2 %, 0 dropped | +| Every knob at 127 on VHS | the largest head swing, the most events, the deepest wear | step 11, 8 s playing; test_the_head_stays_in_its_line in the model | passed: no stall, error or crash | +| AGE 1-10 hold | new: wear frozen while the knobs keep their share | step 11 (AGE 7, 6 s); verify.py: AGE 1, 10, 11, 127 and 0 bit for bit; test_age_1_to_10_hold_the_wear | passed | +| DECK changed while playing | each deck's tables at once; the head step clamp | step 11: VHS, HIFI, POCKT; test_a_sudden_knob_never_lurches_the_head in the model | passed: no stall, error or crash; whether it zips is the author's to hear | +| MIX 0 | the dry must line up with the tape | step 11; verify.py: MIX 0 is the track exactly, 256 samples late | passed | +| Silence and the tail | one-poles and the click can stick a few LSB off zero | verify.py: exact silence in and after a burst, HISS, DUST and AGE at 0, every DECK | passed in dsp_host; not measured on the unit | +| A trig split every block | the per-call work twice a block | verify.py: a split of 5 frames, bit for bit; perf.py: worst 339.2 at a split of 1 | passed in dsp_host | +| Persistence (Part reload, project, power cycle) | knob bytes saved in the Part | not run by the agent | not run: the Keep and the power cycle are the author's (step 12) | + +#### Left for the submitter at their unit + +- how it sounds and plays, and timing by ear +- MIDI, scenes and recording with it +- it beside the other modules installed on their unit +- two instances with different settings, on both FX slots and both DSP cores where it can (docs/MODULE_QUALIFICATION.md) +- Part reload, project save and reload, and a power cycle with it saved: what survives (the Keep and the power cycle are theirs) + +#### For the pull request + +Tested on a unit: package 534be9f61d75, MKII, OS 1.40C, development twin 117eb07f of base ddb56b72, test:procedure steps 6 to 11; the developer's stage not yet. +Edge cases: the table above, one row a case (or "Edge cases: none, because …"). + +The author's trials of this build's sound (4 December, after the review fixes and the additions): "Sounds super cool" (AGE 1-10 hold, 32b766b8, the same DSP code as 534be9f6). + +#### Earlier trials + 1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). A trial of that build (`--cycles 286 --state 96`), rolled back clean: "Sounds really good!" The author then asked whether the sound degrades as AGE is turned up, and agreed to wear adding its own share of the artifacts: full wear adds the equivalent of HISS 16, GAPS 20 (24 since), DUST 20 and GLCH 10, so a worn tape degrades even with those knobs at 0. A 120 s trial of that build, rolled back clean: "This is dope". The author then asked for degradation over time that depends on the knob positions, and chose "destination, then beyond": with AGE above 0 the tape starts clean, DRFT, FLUT, HISS, GAPS, DUST, GLCH and TONE grow toward their knobs, reach them at half wear and go on to about twice them worn out (AGE 0 applies the knobs at once). Asked for anything else that would help the '80s sound, two were added: loud highs dull out (the top closes with the level, more with DRIV) and the hiss breathes with the level (0.35 in silence, whole at full level). Then a fresh-session code review (10 findings), fixed overnight without the author: the right channel's hiss was about 20 dB under the left's (its noise word came from the high half of the generator's product; now two full generator steps, one a channel); a sudden DRFT, FLUT, WIDE or DECK change could lurch the head within one call (its step is now at most 6 % speed); every instance shared its random seeds (now mixed with the instance's buffer base); the level follower heard only the left input (now the louder of the two); trig splits sped the drift and flutter (their phases now advance by the call's length); verify.py's FX1 gate now runs at real FX1 bases. Documented rather than changed, for the author: AGE leaving 0 starts the tape clean at once, and at low AGE half wear is very slow (AGE 1: about 1.7 hours); the 10 ms dropout glide keeps short dips shallower than their targets (a lost contact reaches about 0.3 to 0.5, not 0.1; a hiccup peaks near a quarter of its 48 samples). Not yet trialled on the unit. ## Stock flows From 22388e1614be9cc09377a84741f3b86370b440c9 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 18:21:55 -0600 Subject: [PATCH 12/16] Cassettebox: README screens captured on the author's unit (flashed base ddb56b72, package 534be9f6, kept beside 20 modules) Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 8 +++- sdk/drafts/cassettebox/media/LICENSE.md | 12 ++++++ sdk/drafts/cassettebox/media/capture.json | 22 +++++++++++ sdk/drafts/cassettebox/media/ot-controls.png | Bin 0 -> 1143 bytes sdk/drafts/cassettebox/media/ot-location.png | Bin 0 -> 1180 bytes sdk/drafts/cassettebox/octamod.module.json | 37 ++++++++++++++++++- 6 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 sdk/drafts/cassettebox/media/LICENSE.md create mode 100644 sdk/drafts/cassettebox/media/capture.json create mode 100644 sdk/drafts/cassettebox/media/ot-controls.png create mode 100644 sdk/drafts/cassettebox/media/ot-location.png diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 61fae0a1a5..338fdb5df3 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -60,7 +60,13 @@ Original code by @jrs1717 under the MIT licence in LICENSE. Inspired by cassette ## Screens and audio -None yet. +Captured on the author's Octatrack (flashed base ddb56b72, package 534be9f6), read over USB. + +![FX1 SETUP page with an effect list ending in Cassettebox, selected; knobs labelled POCKT (DECK), WIDE, DUST, GLCH, TONE and AGE.](media/ot-location.png) + +![FX1 main page titled Cassettebox with knobs DRFT, FLUT, DRIV, HISS, GAPS and MIX.](media/ot-controls.png) + +No audio yet. ## Develop diff --git a/sdk/drafts/cassettebox/media/LICENSE.md b/sdk/drafts/cassettebox/media/LICENSE.md new file mode 100644 index 0000000000..04c53497cb --- /dev/null +++ b/sdk/drafts/cassettebox/media/LICENSE.md @@ -0,0 +1,12 @@ +# OT UI capture rights and attribution + +These original LCD captures were taken on the module author's own Octatrack on 4 December 2026, read over USB from the +running Modwerk base (its screen capture request), for Modwerk module documentation. Credit: jrs1717. + +LicenseRef-OT-UI-Documentation covers the original capture/documentation contribution for use in Modwerk module +documentation. Underlying Octatrack interface artwork, labels and other Elektron material retain their owners' rights; +this declaration does not grant a licence to those underlying works or assert that they are MIT/CC licensed. Reviewer +verification of reuse rights is required before publication and is not automatic legal clearance. + +Only rendered PNG screenshots and capture metadata belong in this folder. No firmware, raw LCD/RAM dump, card, +recording or private log is included. diff --git a/sdk/drafts/cassettebox/media/capture.json b/sdk/drafts/cassettebox/media/capture.json new file mode 100644 index 0000000000..16a23d325b --- /dev/null +++ b/sdk/drafts/cassettebox/media/capture.json @@ -0,0 +1,22 @@ +{ + "firmware": "1.40C", + "baseIdentity": "ddb56b72d1ac0b606f5969bc4984b6b22662e87d1b1d56a480ef0da1aac53b49", + "packageSha256": "534be9f61d75498f0a5f30960c9aedc217e0ae6f1eb454de2733f0150f5399d6", + "setup": "The author's Octatrack on its flashed Modwerk base ddb56b72, Cassettebox 0.1.0-experimental (package 534be9f6) kept beside 20 modules; the author's project, pattern A01, a track's FX1 on Cassettebox with DECK POCKT and the other knobs as the author set them; transport stopped. The author pressed the keys; the agent read each frame over USB. imageSha256 is the MAIN image of base 0.8.5 ddb56b72, as recorded for Fuzzbox's, Glitchbox's, Loopbox's and Grainbox's captures on the same base.", + "method": "python3 -B scripts/device-send.py png:FILE through npm run device -- serve: the base's on-demand screen frame (Screen capability), 256x128, unmodified.", + "screens": [ + { + "path": "media/ot-location.png", + "sha256": "a4e1cb937e4abc531d31e3c808bf50e4223d8409fd183b14f09949450d997fbe", + "keys": "TRACK, FUNC+FX1", + "shows": "FX1 SETUP: Cassettebox selected at the end of the effect list; DECK (POCKT), WIDE, DUST, GLCH, TONE and AGE" + }, + { + "path": "media/ot-controls.png", + "sha256": "856022d522abff134c362b6e16b61f3e6f3dff525ec9da0f96f78783c35cea58", + "keys": "FX1", + "shows": "FX1 main page: DRFT, FLUT, DRIV, HISS, GAPS, MIX" + } + ], + "imageSha256": "2f7286525f0a4e84fc70fc6d48f8dab2171b6afd386be59a40a8b96eecfe3237" +} diff --git a/sdk/drafts/cassettebox/media/ot-controls.png b/sdk/drafts/cassettebox/media/ot-controls.png new file mode 100644 index 0000000000000000000000000000000000000000..ae1ca51c1be31a2b755cb0ce130444433e4a8a6c GIT binary patch literal 1143 zcmV--1c>{IP))2C zH7~7NTH}S17c{+Ug$!H<$itR#>Q>?YTfp+w+9)%LxNdnD0Dxla?Bmn@ zTL1uN0nFJ7fau)kbO5k^5}Yx<2vWcHBFKLNE8so40{{j9=vd_552qK149fcnGIRi- z0nik@MCehccW+N~2Eb0;*8o5c~ETLks8)Zfa^>C$(BhXAk~#4M);dj5Co0ASTsRqq9mZ2({c z_~jxv8*q;9M!P^P;A~wQfJiuZYykkc1At$B03h=u*aMKU2xeRQIiNSq>j9ioT%`km zRafV%H9`^p)=sZfAJbVrX-)tT15h@b1i-&_z;xW&)c9Q~(kB4i7k~`5n57+W6%Caq z4FGWf77l*T1FwJ20g%DUu;pSYOWJ-vr3GFEK&Dj01|o}=Kj#Iy0)XSSN?Xq;&o z@D`wwSQ_hQ2Ydw-Jq7^x0g#<+Oa}mmvk1~~54L>NtM_~j0QJ>R;f!u#7kE7Yy5Z@g zPUJogps-EW3OHK_03!hQN4wzf@$o1CS*TutXXpT6?j+cnp}oSdz55IRJ9S?JfF6Jv z?!k&jU%74$fK|x*#sJ`cN8xC|**XCD9{{q)03Zfnzx56$qwOuCs~XQoGXUs?w$Hr8 zdJ)X&0AL1yE*O2R(f4yH+sW{hwBKF2mN5Xx*LeX^EcTN%(;JhwY~||o2msiR?6T(| z7ISw)zgkCH;CMR#YZ0_sfR0@QAloK(fmZ?061iB&c6dSyd<_6rU7fREw?H!hI0A=@ z=U8|bc&Y^fl!qDs!~yX8qK?IfvsK2gdd6PhUP04@vib!GrC2EdC*fA`A&7cF3+ z^qLs}<^i;lE5`P<-U50?J4xH5Pw7L)1ps3J+Rby!%JuaC{s4iO`bPK|PLcos002ov JPDHLkV1lX|0h<5- literal 0 HcmV?d00001 diff --git a/sdk/drafts/cassettebox/media/ot-location.png b/sdk/drafts/cassettebox/media/ot-location.png new file mode 100644 index 0000000000000000000000000000000000000000..a83c346eb7c5c23201ec2bef60a07107c76edae3 GIT binary patch literal 1180 zcmV;N1Y`S&P)$MdE0q9__+{V7ej-jg( z*uM_o+N67z-MR|A(OdxSq5WLA!m_>8>k>P`oU1h>fLnU;`Xzw#Z-Ki4*_{oT-2}_H zq;^wNS-Xz(sMzCGfB-ffj=r`VSKY07~u&W42uu<(kfJp$GuOIok*!po$WZ`0+`#4mV;1fG);L zz;-?kAX`>=e?}*Ph!WVo4#1lPqh%1U*Gm9l+JejsYz#nR75Ef@NPeARBH9AX#5I2J zh2H`M&;{WAioIlX1mFSaO@i5T>!7C_1>m(0|02|`&PyN$&`JOUdFs%S5kT*sqrF3FdjRxsv6uTzzp#w}I{zHa zErZRiR9i2z0P1!4k_bQsI^t^0BsvcymZjZTVce)~zV)DkN$}$UywI*SJ4qgA4FC%> zHyvxJx?db00Yst2liF@{{*0na2XIHd`_T zU?uki^3**7crSo^`XzwuB-k40rOw-4%mm_v=H0E<5x^(_f3vfi#JaWIhV}fe>j+>L zfKB~60O%=tR-+>T4}kwMv Date: Fri, 4 Dec 2026 18:26:52 -0600 Subject: [PATCH 13/16] Cassettebox: the author's stage on 534be9f6 (kept, played, Part reload and power cycle survived) Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/TESTING.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index e9f2baffff..249988ab08 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -25,7 +25,7 @@ Build: revision `37a9987f300a`, package `cassettebox.mwrm` SHA-256 `534be9f61d75 | 9 | Cost on the unit | unit | passed | `npm run device:price -- --share /tmp/modwerk-share.sock --out /price.json --scene 'the bank, pattern and Part the unit was on, transport stopped (test:procedure)' --curve T1,T3,T6,T7 /../cassettebox.mwrm` | logs/09-cost-unit.log | | 10 | Put back | unit | passed: Part 1 on A01: nothing to put back; working = saved | `node scripts/device.mjs do inventory --socket /tmp/modwerk-share.sock`
`node scripts/octatrack-part-state.mjs restore --socket /tmp/modwerk-share.sock --start /part-start.json` | logs/10-restore.log | | 11 | Agent by hand | unit | passed: on 534be9f6, Cassettebox on T1 FX1, T2 FX2 and T5 FX1 at once (both slots, both cores) while the pattern played: the defaults; every knob at 127 with DECK VHS; AGE to 7 (held); DECK HIFI and POCKT; MIX 0. Health after each: 0 stalls, 0 errors, no crash, CPU 614-658. After STOP: stall none recorded, latest entry 34.1 us late (0 in the guard's 80-190 us window). Main and setup pages match the README; each DECK name fits the header (HIFI, HOME, POCKT, VHS); the first run of this step, on 32b766b8, found STUDIO and POCKET cut to five letters (renamed, build 534be9f6). The sound not judged (the author's stage). STOP, Part reloaded, the trial rolled back. MAIN and CUE not recorded over USB: the recorder is not built on this computer | `device try`, `pick:T1:FX1:CASSETTEBOX`, `pick:T2:FX2:CASSETTEBOX`, `pick:T5:FX1:CASSETTEBOX`, `png:`, `health`, `stats`, `stall`, `late`, `reload` | main.png, setup.png, setup-full.png, age-hold.png, deck-hifi.png, deck-pockt.png | -| 12 | Submitter's own stage | unit | to do: the author's Keep and power cycle on 534be9f6 | | | +| 12 | Submitter's own stage | unit | passed (reported by the author): kept on the flashed base, played, Part saved and reloaded, power cycle; see below | | | #### Edge cases for this change @@ -49,7 +49,7 @@ Derive them from what the change touches and run each one (docs/TEST_PROCEDURE.m | MIX 0 | the dry must line up with the tape | step 11; verify.py: MIX 0 is the track exactly, 256 samples late | passed | | Silence and the tail | one-poles and the click can stick a few LSB off zero | verify.py: exact silence in and after a burst, HISS, DUST and AGE at 0, every DECK | passed in dsp_host; not measured on the unit | | A trig split every block | the per-call work twice a block | verify.py: a split of 5 frames, bit for bit; perf.py: worst 339.2 at a split of 1 | passed in dsp_host | -| Persistence (Part reload, project, power cycle) | knob bytes saved in the Part | not run by the agent | not run: the Keep and the power cycle are the author's (step 12) | +| Persistence (Part reload, power cycle) | knob bytes saved in the Part | step 12, the author on the flashed base | passed (reported by the author): "everything survived"; a project reload not reported | #### Left for the submitter at their unit @@ -61,11 +61,15 @@ Derive them from what the change touches and run each one (docs/TEST_PROCEDURE.m #### For the pull request -Tested on a unit: package 534be9f61d75, MKII, OS 1.40C, development twin 117eb07f of base ddb56b72, test:procedure steps 6 to 11; the developer's stage not yet. +Tested on a unit: package 534be9f61d75, MKII, OS 1.40C, development twin 117eb07f of base ddb56b72, test:procedure steps 6 to 11; the developer's stage on 534be9f6: kept, played, Part reload and power cycle survived. Edge cases: the table above, one row a case (or "Edge cases: none, because …"). The author's trials of this build's sound (4 December, after the review fixes and the additions): "Sounds super cool" (AGE 1-10 hold, 32b766b8, the same DSP code as 534be9f6). +#### The author's stage on 534be9f6 (as reported) + +4 December 2026, the author's MKII on their flashed base ddb56b72 (OS 1.40C): package 534be9f6 kept beside the card's 20 other modules (`npm run device -- try cassettebox.mwrm --seconds 60 --accept`: no crash, stall, freeze or skipped track; the kept set otherwise unchanged, 20 to 21). The author chose Cassettebox on a track's FX1 (the README's screens were read over USB as they did), played it, saved the Part, reloaded it and power-cycled: "everything survived!" + #### Earlier trials 1. 4 December 2026, the author's MKII on development twin 117eb07f of base ddb56b72 (OS 1.40C), two RAM trials of 120 s with `npm run module:dev -- cassettebox --cycles 271 --cycles-kind executed --state 88 --buffer 1024 --slots both` on T1 FX1, each rolled back with no crash, stall, freeze or skipped track logged. Reported, with GAPS, DUST and GLCH varied: "Lots of clicking and background noise"; DUST "seemed extreme vs a more subtle dust on a cassette or tape". Changed, with the author's OK: hiss 8 dB lower, softened (each noise word averaged with the last) and HISS's default 16; crackle much rarer at low settings (the knob squared, at most about 20 pops a second at 127), quieter, and through playback's low-pass; dropouts and glitches rarer at low settings (squared) with the dropout gain gliding over about 10 ms; the speed hiccup a glide; the drift's wander slower; the random source's taps made maximal (it had cycled every 4,599 steps). The author also asked for aged VHS sound: DECK gained VHS (narrow, a low cut in place of the head bump, a slow deep warble, more hiss). A trial of that build (`--cycles 286 --state 96`), rolled back clean: "Sounds really good!" The author then asked whether the sound degrades as AGE is turned up, and agreed to wear adding its own share of the artifacts: full wear adds the equivalent of HISS 16, GAPS 20 (24 since), DUST 20 and GLCH 10, so a worn tape degrades even with those knobs at 0. A 120 s trial of that build, rolled back clean: "This is dope". The author then asked for degradation over time that depends on the knob positions, and chose "destination, then beyond": with AGE above 0 the tape starts clean, DRFT, FLUT, HISS, GAPS, DUST, GLCH and TONE grow toward their knobs, reach them at half wear and go on to about twice them worn out (AGE 0 applies the knobs at once). Asked for anything else that would help the '80s sound, two were added: loud highs dull out (the top closes with the level, more with DRIV) and the hiss breathes with the level (0.35 in silence, whole at full level). Then a fresh-session code review (10 findings), fixed overnight without the author: the right channel's hiss was about 20 dB under the left's (its noise word came from the high half of the generator's product; now two full generator steps, one a channel); a sudden DRFT, FLUT, WIDE or DECK change could lurch the head within one call (its step is now at most 6 % speed); every instance shared its random seeds (now mixed with the instance's buffer base); the level follower heard only the left input (now the louder of the two); trig splits sped the drift and flutter (their phases now advance by the call's length); verify.py's FX1 gate now runs at real FX1 bases. Documented rather than changed, for the author: AGE leaving 0 starts the tape clean at once, and at low AGE half wear is very slow (AGE 1: about 1.7 hours); the 10 ms dropout glide keeps short dips shallower than their targets (a lost contact reaches about 0.3 to 0.5, not 0.1; a hiccup peaks near a quarter of its 48 samples). Not yet trialled on the unit. From a340f044eac9e559145c50651588979182bdb7c9 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 20:28:51 -0600 Subject: [PATCH 14/16] Cassettebox: the maintainer's text fixes (TESTING names 0.1.0-experimental; summary, resources, proof note, README and the first limitation say what ran on 534be9f6) Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/README.md | 2 +- sdk/drafts/cassettebox/TESTING.md | 6 +- .../cassettebox/evidence/cpu-price.json | 146 ++++++++++++++++++ .../cassettebox/evidence/frame-cost.json | 55 +++++++ .../cassettebox/evidence/performance.json | 2 +- sdk/drafts/cassettebox/manifest.py | 4 +- sdk/drafts/cassettebox/octamod.module.json | 41 +++-- 7 files changed, 235 insertions(+), 21 deletions(-) create mode 100644 sdk/drafts/cassettebox/evidence/cpu-price.json create mode 100644 sdk/drafts/cassettebox/evidence/frame-cost.json diff --git a/sdk/drafts/cassettebox/README.md b/sdk/drafts/cassettebox/README.md index 338fdb5df3..c53848eb4c 100644 --- a/sdk/drafts/cassettebox/README.md +++ b/sdk/drafts/cassettebox/README.md @@ -1,6 +1,6 @@ # Cassettebox -Version 0.1.0-experimental · by @jrs1717 · a draft: bit for bit against its model in `dsp_host`, not yet run on a unit. +Version 0.1.0-experimental · by @jrs1717 · the test procedure passed on the author's MKII (package 534be9f6, steps 1-11); the author kept it, played it and power-cycled: "everything survived". ## Overview diff --git a/sdk/drafts/cassettebox/TESTING.md b/sdk/drafts/cassettebox/TESTING.md index 249988ab08..8e82db697c 100644 --- a/sdk/drafts/cassettebox/TESTING.md +++ b/sdk/drafts/cassettebox/TESTING.md @@ -1,10 +1,14 @@ # Cassettebox testing +## 0.1.0-experimental + +The test procedure and the author's stage ran on package 534be9f6 (0.1.0-experimental): steps 1-11 passed, and the author kept it, played it, reloaded the Part and power-cycled. Earlier builds ran only in RAM trials; every change since 534be9f6 is text. + Record what you ran, on which build and which unit, and what you saw. "Not tested" is a valid answer; never write a result you did not observe, and keep emulator runs apart from hardware ones. ## In dsp_host (not hardware evidence) -`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and two real FX1 bases ($1c00, $3400: 1024- but not 2048-aligned). MIX 0 is the track exactly, 256 samples late. With HISS, DUST and AGE at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 26/26. +`python3 -B verify.py`, 4 December 2026: every gate passes. The engine matches `reference.py` bit for bit at every DECK (its defaults, its dearest, every knob at 127), each knob alone at 127, every knob swept, AGE wearing the tape for 12 s, a trig split every block, an LFO's fraction bits, garbage state, two seeds and two real FX1 bases ($1c00, $3400: 1024- but not 2048-aligned). MIX 0 is the track exactly, 256 samples late. With HISS, DUST and AGE at 0, silence in gives exact silence out and a burst's tail ends in exact silence at every DECK. `python3 -B test_reference.py`: 31/31 (5 December, with AGE 1-10 holding). ## On the unit diff --git a/sdk/drafts/cassettebox/evidence/cpu-price.json b/sdk/drafts/cassettebox/evidence/cpu-price.json new file mode 100644 index 0000000000..f65885ef30 --- /dev/null +++ b/sdk/drafts/cassettebox/evidence/cpu-price.json @@ -0,0 +1,146 @@ +{ + "module": "cassettebox", + "version": "0.1.0-experimental", + "base": "development twin 117eb07f of base ddb56b72, MKII, OS 1.40C", + "scene": "the bank, pattern and Part the unit was on, transport stopped (test:procedure)", + "inputs": { + "transport": "playing" + }, + "seconds": 8, + "readings": 3, + "measuredAt": "2026-12-05T00:02:55.396Z", + "result": { + "id": "cassettebox", + "version": "file", + "packageSha256": "534be9f61d75498f0a5f30960c9aedc217e0ae6f1eb454de2733f0150f5399d6", + "before": { + "frame": 50.1, + "frameMax": 86.9, + "frames": 67187, + "skipped": 0, + "cpu": 61.7, + "dsp1to4": 35.6, + "dsp5to8": 46.6, + "dsp1to4Peak": 37.5, + "dsp5to8Peak": 48.4, + "readings": 3, + "spread": { + "frame": 0.2, + "cpu": 0.6, + "dsp1to4": 0, + "dsp5to8": 0, + "frameMax": 0.9, + "dsp1to4Peak": 0, + "dsp5to8Peak": 0.5 + } + }, + "atRest": { + "frame": 50, + "frameMax": 86.4, + "frames": 67188, + "skipped": 0, + "cpu": 61.5, + "dsp1to4": 34.9, + "dsp5to8": 46.6, + "dsp1to4Peak": 37.5, + "dsp5to8Peak": 98.4, + "readings": 3, + "spread": { + "frame": 0.1, + "cpu": 0.8, + "dsp1to4": 0.1, + "dsp5to8": 0, + "frameMax": 0.1, + "dsp1to4Peak": 0, + "dsp5to8Peak": 50.3 + } + }, + "atRestAdds": { + "frame": -0.1, + "cpu": -0.2, + "dsp1to4": -0.7, + "dsp5to8": 0, + "dsp1to4Peak": 0, + "dsp5to8Peak": 50 + }, + "inUse": { + "frame": 50.1, + "frameMax": 87.8, + "frames": 67179, + "skipped": 0, + "cpu": 61.7, + "dsp1to4": 47.2, + "dsp5to8": 43.9, + "dsp1to4Peak": 58.1, + "dsp5to8Peak": 48.2, + "readings": 3, + "spread": { + "frame": 0.1, + "cpu": 0.8, + "dsp1to4": 0, + "dsp5to8": 0, + "frameMax": 1, + "dsp1to4Peak": 9.7, + "dsp5to8Peak": 0.3 + } + }, + "inUseAdds": { + "frame": 0, + "cpu": 0, + "dsp1to4": 11.6, + "dsp5to8": -2.7, + "dsp1to4Peak": 20.6, + "dsp5to8Peak": -0.2 + }, + "inUseOn": "T1 FX2", + "curve": { + "tracks": [ + "T1", + "T3", + "T6", + "T7" + ], + "points": [ + 86.4, + 87.9, + 86.4, + 89, + 88.1 + ], + "adds": [ + 1.5, + 0, + 2.6, + 1.7 + ], + "first": 2.6, + "each": 2.6, + "notes": [], + "admission": [ + { + "pattern": "empty", + "number": 2, + "track": "T1", + "seconds": 8, + "admitted": true, + "frameMax": 36, + "frame": 27.2, + "dropped": 0, + "stalls": 0 + }, + { + "pattern": "medium", + "number": 1, + "track": "T1", + "seconds": 8, + "admitted": true, + "frameMax": 89.2, + "frame": 50.1, + "dropped": 0, + "stalls": 0 + } + ] + }, + "rolledBack": true + } +} diff --git a/sdk/drafts/cassettebox/evidence/frame-cost.json b/sdk/drafts/cassettebox/evidence/frame-cost.json new file mode 100644 index 0000000000..66ce5f2ceb --- /dev/null +++ b/sdk/drafts/cassettebox/evidence/frame-cost.json @@ -0,0 +1,55 @@ +{ + "module": "cassettebox", + "version": "0.1.0-experimental", + "base": "development twin 117eb07f of base ddb56b72, MKII, OS 1.40C", + "scene": "the bank, pattern and Part the unit was on, transport stopped (test:procedure)", + "seconds": 8, + "measuredAt": "2026-12-05T00:02:55.396Z", + "tracks": [ + "T1", + "T3", + "T6", + "T7" + ], + "rest": 0, + "first": 2.6, + "each": 2.6, + "points": [ + 86.4, + 87.9, + 86.4, + 89, + 88.1 + ], + "adds": [ + 1.5, + 0, + 2.6, + 1.7 + ], + "admission": [ + { + "pattern": "empty", + "number": 2, + "track": "T1", + "seconds": 8, + "admitted": true, + "frameMax": 36, + "frame": 27.2, + "dropped": 0, + "stalls": 0 + }, + { + "pattern": "medium", + "number": 1, + "track": "T1", + "seconds": 8, + "admitted": true, + "frameMax": 89.2, + "frame": 50.1, + "dropped": 0, + "stalls": 0 + } + ], + "notes": [] +} diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index 4acd1f8988..b101c1e824 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,7 +2,7 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "a004a83027bbb56515ef40a2d68f2d27c92fea9b41b3a4ac5a372637deeba6f8", + "sourceSha256": "b63e510939b00b8e6ddaa9ad4e4b87bb2eab2d9960940ca3d3152b17d0386e34", "kind": "dsp", "cycles": { "unit": "instructions/sample", diff --git a/sdk/drafts/cassettebox/manifest.py b/sdk/drafts/cassettebox/manifest.py index 0df497433d..01885a1777 100644 --- a/sdk/drafts/cassettebox/manifest.py +++ b/sdk/drafts/cassettebox/manifest.py @@ -7,7 +7,7 @@ darkens it, and AGE wears the tape while it plays, as a loop recorded over again and again: the tape starts clean and the artifacts grow toward the knobs' positions. MIX blends the tape with the dry track, read at the tape's centre delay (5.8 ms) so the two never comb. -verify.py holds engine.asm to reference.py's model bit for bit in dsp_host. Not yet run on a unit. +verify.py holds engine.asm to reference.py's model bit for bit in dsp_host. Tested on the author's MKII: test:procedure 1-11 and the author's stage on package 534be9f6. """ import importlib.util import pathlib @@ -30,7 +30,7 @@ doc="'80s cassette and VHS tape effect on FX1 or FX2: drift, flutter, saturation, hiss, dropouts and tape wear.", category=Category.TRACK, author="jrs1717", author_url="https://github.com/jrs1717", proof=Proof.RENDER, - proof_note="verify.py bit-exact against reference.py in dsp_host; not yet run on a unit", + proof_note="test:procedure steps 1-11 on the author's MKII (package 534be9f6) and the author's Keep, Part reload and power cycle; verify.py bit-exact against reference.py in dsp_host", menu=MenuEntry( fx2_id=0x0a, diff --git a/sdk/drafts/cassettebox/octamod.module.json b/sdk/drafts/cassettebox/octamod.module.json index ccfd7495ee..5436a00fda 100644 --- a/sdk/drafts/cassettebox/octamod.module.json +++ b/sdk/drafts/cassettebox/octamod.module.json @@ -126,37 +126,46 @@ "conflicts": [], "uiClaims": [], "limitations": [ - "A draft: verified bit-exact against its model in dsp_host; not yet run on a unit.", + "Checked only in dsp_host, not measured on the unit: exact silence in and after a burst with HISS, DUST and AGE at 0, and a trig split every block (verify.py, bit for bit). The test procedure and the author's stage ran on the unit (package 534be9f6).", "The tape sits 5.8 ms (256 samples) behind the track, and MIX 0 is the dry track at the same delay, so the two blend without combing." ], "effectId": 10 }, "resources": { - "recorded": "Not measured", + "recorded": "2026-12-04", "storage": { - "label": "Storage", - "display": "Not measured", + "label": "DSP program / state", + "display": "1408 words / 112-word state", "value": null, - "unit": "unknown", - "method": "unmeasured", - "conditions": "No measurements exist yet. Add exact conditions and source evidence when available.", + "unit": "see display", + "method": "static", + "conditions": "The USB package 534be9f6 (ABI 6): 1,408 program words on each DSP core it runs on; 112 words of state per instance in its own r7 block (init clears them); 1,024 words of the slot's own delay buffer per instance (the tape: left and right lines of 512), on FX1 or FX2; 908 bytes of ColdFire code and data (the effect's descriptor and menu), no bss.", "source": "TESTING.md" }, "processing": { - "label": "CPU / DSP load", - "display": "Not measured", + "label": "DSP instruction peak", + "display": "340 instructions/sample per instance", "value": null, - "unit": "unknown", - "method": "unmeasured", - "conditions": "No measurements exist yet. Add exact conditions and source evidence when available.", - "source": "TESTING.md" + "unit": "see display", + "method": "emulator", + "conditions": "perf:audit record (perf.py in dsp_host): worst 339.2 executed instructions a sample at the dearest HIFI setting with a trig split of 1 frame, unsplit 288.2 to 288.9, static loop floor 260; SPRING REV 314.19 and DJ EQ, the dearest stock effect, 330.94 on the same stock image. Executed instructions, not chip cycles. On the author's MKII the DSP load of T1-T4 rose 11.6 points (peak 20.6) with it on T1 FX2.", + "source": "evidence/performance.json" + }, + "cpuPrice": { + "value": 0, + "unit": "percent-of-frame", + "measure": "frame-interrupt", + "tool": "npm run device:price -- --write", + "date": "2026-12-05", + "conditions": "the bank, pattern and Part the unit was on, transport stopped (test:procedure); base development twin 117eb07f of base ddb56b72, MKII, OS 1.40C; 3 readings of 8 s a state. Frame interrupt 50.1 % before, 50 % installed and used nowhere, 50.1 % on T1 FX2; CPU meter 61.7 % before, 61.5 % at rest, 61.7 % in use.", + "source": "evidence/cpu-price.json" } }, "tests": { "report": "TESTING.md", - "summary": "No tests have been run. Add tests.qualification with worst-case cycles, exact memory and attributed owner-reviewed hardware evidence before submitting. This scaffold cannot pass publication checks.", - "hardwareStatus": "untested", - "evidenceRevision": "b8deefc88b2c3e5f3c6158e364eb741df1924e1d", + "summary": "On the author's MKII (OS 1.40C, twin 117eb07f of base ddb56b72): npm run test:procedure on package 534be9f6 built from 37a9987f passed steps 1-11 (both cores, FX1 and FX2, six instances admitted at once, Part switches, a 120 s soak, the price and the curve played; by hand three instances with every knob at 127 on VHS, AGE held, DECK changed, MIX 0); the author kept 534be9f6 beside 20 modules, played, saved and reloaded the Part and power-cycled: \"everything survived\". verify.py is bit-exact against reference.py in dsp_host for every DECK and knob; perf:audit worst 339.2 instructions a sample, 1.08x SPRING REV (evidence/performance.json).", + "hardwareStatus": "reported", + "evidenceRevision": "37a9987f300a6b4df1dcfbe00f8aacd124e9287d", "gates": [ "Worst-case cycles under parameter modulation and maximum load", "Exact memory region and maximum-instance totals", From 4b9a750a3c005dfcfd6673bb506561526c5baef2 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 22:23:00 -0600 Subject: [PATCH 15/16] Cassettebox: the model tests run in about a minute, not four (shorter runs, every assertion kept) The event tests (creases, dropout starts and glides, a worn tape, uneven heads, every knob) ran up to 60 s of simulated silence each; the shorter runs keep every assertion, with the counts they reach noted. module:doctor gives a draft's host tests 120 s and CI's draft-doctor test timed out on them (#2652 fixes that test's own limit). Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/test_reference.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index 9b0707359b..ca50cdbe89 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -101,7 +101,7 @@ def test_the_tail_ends_in_exact_silence(self): self.assertFalse(any(l[-22050:] + r[-22050:]), R.DECKS[d]) def test_every_knob_changes_the_sound(self): - x = tone(n=16 * 8000) # long enough for the rarer events (GAPS, GLCH and DUST go by the knob squared) + x = tone(n=16 * 1500) # long enough for the rarer events (GAPS, GLCH and DUST go by the knob squared) base = R.render(x, x, {0: knobs(QUIET, deck=1)})[:2] for name in R.KNOBS: if name in ("MIX", "DECK"): @@ -151,7 +151,7 @@ def test_a_worn_tape_degrades_from_zero(self): z = [(0, 0)] * 16 row = R.pblock(knobs(QUIET, age=127)) sound = dips = 0 - for _ in range(60000): + for _ in range(10000): out = m.call(z, row) sound += any(l for l, _r in out) dips += m.x[0x1e] < 0x7fffff @@ -252,7 +252,7 @@ def test_events_are_rare_at_low_settings(self): def starts(gaps): m, n, prev = R.Model(), 0, 0 row = R.pblock(knobs(QUIET, gaps=gaps)) - for _ in range(40000): + for _ in range(10000): m.call([(0, 0)] * 16, row) n += m.x[0x1d] > prev prev = m.x[0x1d] @@ -268,7 +268,7 @@ def worst_step(**kw): m = R.Model() row = R.pblock(knobs(QUIET, **kw)) worst, low = 0, 0x7fffff - for _ in range(20000): + for _ in range(5000): before = m.x[0x14] m.call([(0, 0)] * 16, row) worst = max(worst, abs(m.x[0x14] - before)) @@ -346,7 +346,7 @@ def test_uneven_heads(self): self.assertEqual(m.x[0x6f], 0) row = R.pblock(knobs(QUIET, age=127)) m.x[0x04], m.x[0x2d] = 0x7fffff, 0xffffff - for _ in range(int(R.FS / 16 * 25)): + for _ in range(int(R.FS / 16 * 5)): m.call([(0, 0)] * 16, row) self.assertLess(m.x[0x66], m.x[0x1a]) self.assertGreater(m.x[0x6f], 0) @@ -357,7 +357,7 @@ def creases(gaps): m = R.Model() row = R.pblock(knobs(QUIET, gaps=gaps)) n, prev, longest = 0, 0, 0 - for _ in range(int(R.FS / 16 * 60)): + for _ in range(int(R.FS / 16 * 3)): # 3 s: about 11 creases at GAPS 127 m.call([(0, 0)] * 16, row) n += m.x[0x6a] > prev longest = max(longest, m.x[0x6a]) From bed1ba20870ac5bbf5cc731f2b3a430adcf74e34 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 4 Dec 2026 22:24:36 -0600 Subject: [PATCH 16/16] Cassettebox: test_decks_differ measures VHS's lows with a plain two-pole low-pass (CI's host tests have no numpy); performance record re-stamped on the source (tests only changed) Co-Authored-By: Claude Opus 5.5 --- sdk/drafts/cassettebox/evidence/performance.json | 2 +- sdk/drafts/cassettebox/test_reference.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sdk/drafts/cassettebox/evidence/performance.json b/sdk/drafts/cassettebox/evidence/performance.json index b101c1e824..9ecb103950 100644 --- a/sdk/drafts/cassettebox/evidence/performance.json +++ b/sdk/drafts/cassettebox/evidence/performance.json @@ -2,7 +2,7 @@ "schema": 1, "module": "cassettebox", "version": "0.1.0-experimental", - "sourceSha256": "b63e510939b00b8e6ddaa9ad4e4b87bb2eab2d9960940ca3d3152b17d0386e34", + "sourceSha256": "f2cecc0d86333414b91bcf08eed1ca97a0337ba59d74ce364f8aa88d0137fad9", "kind": "dsp", "cycles": { "unit": "instructions/sample", diff --git a/sdk/drafts/cassettebox/test_reference.py b/sdk/drafts/cassettebox/test_reference.py index ca50cdbe89..5ea3c45213 100644 --- a/sdk/drafts/cassettebox/test_reference.py +++ b/sdk/drafts/cassettebox/test_reference.py @@ -118,12 +118,17 @@ def test_decks_differ(self): self.assertGreater(hf[0], hf[1]) self.assertGreater(hf[1], hf[2]) # VHS is thin: the least energy below 150 Hz for its level + # (a two-pole 150 Hz low-pass in plain Python: CI's host tests have no numpy) + k = 1 - math.exp(-2 * math.pi * 150 / R.FS) lows = [] for o in outs: - import numpy as np - sp = np.abs(np.fft.rfft(np.array(o, float))) ** 2 - f = np.fft.rfftfreq(len(o), 1 / R.FS) - lows.append(sp[f < 150].sum() / sp.sum()) + s1 = s2 = 0.0 + low = [] + for v in o: + s1 += k * (v - s1) + s2 += k * (s1 - s2) + low.append(s2) + lows.append(energy(low) / energy(o)) self.assertEqual(min(range(4), key=lambda d: lows[d]), 3) def test_wide_parts_the_channels(self):