Repository navigation
Conversation
|
Sorry if this is explained and I missed it, but where do these band-limited versions of the wavetable come from? I was expecting to see some kind of data prep function that generated low-passed versions of existing wavetables, but is that not included? |
|
Updated the branch and original PR description. Yes, it is in I made it an explicit call rather than something that happens by default because the copies take a lot more memory per wavetable, and spending that on every AMY build felt like your call to make, not mine. The body lists two ways to make it a default under "Not done": a config flag that builds the shipped tables at start, or copies generated into the headers behind a define. A middle road would be to ship the copies for the built-in presets and leave the builder for anything an embedder loads or generates at runtime. Doing it in the import script instead would cover every preset and import that goes through the script, but a wavetable can be made without importing anything, so if it were up to me the runtime builder stays whichever way the default goes. One correction, with the fix pushed. I measured the build on an ESP32-S3 and it was far slower than the body claimed: about a third of a second for a 64-frame table, not tens of milliseconds, and the builder was float, so a board without an FPU would have taken seconds. The third commit on the branch replaces it with an FFT per frame in fixed point: about 90 ms for a 64-frame table on the S3, no float anywhere in it, and the copies within 1 LSB of before. The body is updated with the method and the cost, default mode is up to you; building the five shipped tables at start is now about half a second on that board. For what it is worth, my own firmware builds a preset's copies when a patch on it loads and frees them when the last synth using it is gone. That works, with a pause on the patch change that is exactly this cost, which is what started the rework. The updated shape makes both building at boot and dynamically at runtime less costly. |
|
I rewrote the description. It was cluttered, hard to follow and the update made it longer. |
|
This is amazing. TBH I don't hear a night-and-day comparison in the sounds - those wavetable voices are already mostly pretty gritty, so the aliasing doesn't scream out to me. But I'm sure there are more exposed cases, it's definitely a real problem. This does seem like a lot of functionality (an entire FFT!) for a rather rare use-case. That's OK, I think it's contained in its impact, and Claude assures me that the object size impact is only a couple of kB. I don't want to turn this on by default, because of the compute time and particularly the RAM impact. As I understand it, code that links the AMY library can now call the new functions to make use, but these new functions aren't part of any published API. I would feel better if we actually exposed this somehow, I'm having Claude look at it. |
|
Thanks for this, and for splitting it into commits that can be judged separately. On the size question: I built the changed files at On "rungs by default, or on request": I'd prefer on request, through the wire protocol. At the moment only C embedders can call
Plus a matching entry in the Things I'd like it to handle:
I don't need slicing or per-rung rebuilds yet. The |
|
Thanks, and an entire FFT felt like a lot to me too, at the start. The default and how to expose it were where I was stuck, which is why it is not yet plugged in anywhere. |
|
This is the real Dan again. It strikes me that the successively band-limited wavetables don't need to be sampled so densely; I'm pretty sure we could halve the length each time we lowpass, so the entire ladder would only occupy 2x the original wavetable (instead of 4x for the current ladder). This is the approach of the |
|
Fair point. On the sizes, a first round of numbers from a host sim (fixed point, 48 kHz, the five shipped tables, steady notes on the middle frame): energy between the harmonics relative to the harmonics, mean over the tables, lower is better.
I'll investigate the mechanism behind these numbers before reading more into them. Pushing the previous round of changes with an update comment before digging more into the halving and lutset stuff. |
f67f337 to
af4c318
Compare
|
Pushed: five commits now. The description still covers the ladder, frame spread and FFT builder as they were; this comment covers what is new, and with
On your list:
On amy.h's "not while that preset is being loaded or unloaded": what remains is the exposure the z load already has, another sender unloading the preset while the build reads it unlocked. Closing that would take a copy under the lock with a generation check, or deferred frees, at 32-128 KB or a new lifetime mechanism; I judged that an AMY-wide question and out of scope for right now. |
|
The numbers, as promised. The first round I posted overstated the cost of halving: on one of the shipped tables the halved rungs overflowed the 32-bit multiply in
So I'd keep 256 per rung. At 256, each rung down has twice the samples per cycle of its top harmonic (4, 8, 16, 32), and the linear interpolation's images fall with it; halving holds that at 2 (128/64/32/16) or 4 (256/128/64/32), and a table with energy right at a rung's limit then images at close to the partial's own level. On sharing: the rungs already go through Separately: |
|
Thanks for the response.
Your measurements are very interesting, I'm not sure exactly what they
measure. The results must depend on the original wavetable, right? And I
suppose they compare alias energy to the "ideal" band-limited rendering,
how do you generate that? sinc-interpolation in floating point or
something?
When it comes to aliases, absolute energy is an upper bound, but the actual
acceptability depends significantly on where the alias harmonics fall
relative to the signal. So I'm interested if you (Rasmus) think the "4x"
tables sound appreciably better than the "1.9x". (I wasn't trying to
advocate for the "0.94x" solution, that would assume that the original 256
waveforms were already 2x oversampled).
I know nothing about existing wavetable systems, is it commonplace to have
this kind of laddered waveshape, or is aliasing accepted as part of the
deal? I supposed I could look at the Mutable Instruments source to find
out what they did.
My impression is that RAM usage is of concern in this scenario, so I can
imagine that halving RAM may be worth 10-20 dB in SNR. I suspect it's only
when we get into the "SNR below 10dB" range that things become really
problematic, but that's just a guess. But maybe the RAM isn't really a
problem, in which case the fixed-size tables are a win (because we can use
the hard-coded 256-point lut render routine).
My point about reusing the code was referencing `choose_from_lutset` etc.
I see you are already using that; I am now happy, not sad.
DAn.
…On Sat, Nov 7, 2026 at 4:57 PM Rasmus T ***@***.***> wrote:
*rt-rtos* left a comment (shorepine/amy#1251)
<#1251 (comment)>
The numbers, as promised. The first round I posted overstated the cost of
halving: on one of the shipped tables the halved rungs overflowed the
32-bit multiply in render_lut's linear step (more on that below). With
that multiply done in 64 bits, the same sim (fixed point, 48 kHz, the five
shipped tables, middle frame; energy between the harmonics relative to the
harmonics, mean over the tables, worst table in brackets):
notes no ladder 256 each (4x) 128/64/32/16 (0.94x) 256/128/64/32 (1.9x)
F#3-D#4 -37 (-33) dB -42 (-35) dB -33 (-26) dB -42 (-35) dB
F#4-D#5 -31 (-25) dB -43 (-36) dB -29 (-22) dB -30 (-23) dB
F#5-D#6 -8 (-1) dB -60 (-54) dB -31 (-25) dB -40 (-34) dB
F#6-F#7 -4 (3) dB -49 (-42) dB -23 (-18) dB -31 (-25) dB
So I'd keep 256 per rung. At 256, each rung down has twice the samples per
cycle of its top harmonic (4, 8, 16, 32), and the linear interpolation's
images fall with it; halving holds that at 2 (128/64/32/16) or 4
(256/128/64/32), and a table with energy right at a rung's limit then
images at close to the partial's own level. create_lutset keeps about 8
(2^ceil(log2(8 x hmax)), so 512/256/128/64 for these limits, 960 samples
per frame against the ladder's 1024), so the ladder already sits near the
lutset density.
On sharing: the rungs already go through LUT, choose_from_lutset and
render_lut. What isn't shared is that render_wavetable ignores the picked
entry's size and does its own pick before unison_prepare; I can make it
take the stride and log2 from the entry and drop the extra pick, a few
lines. Generation can't go through create_lutset, which synthesises
tables offline from a harmonic list, while the ladder cuts tables that only
exist at runtime.
Separately: INTERP_LINEAR multiplies (c - b) * frac in 32 bits (MUL0_SS),
which wraps once neighbouring samples differ by full scale or more. Four of
the five shipped wavetables have frames like that in the base table (steps
up to 2.0), so the plain WAVETABLE render already wraps on those frames,
ladder or not. I'll open an issue for it.
—
Reply to this email directly, view it on GitHub
<#1251?email_source=notifications&email_token=AAEGZUMYFG75TEX2K72T7AD5X6LD5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMNZRGM2TGOBSGU2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6713538254>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEGZUKSDRB7EGPBSPL67EL5X6LD5AVCNFSNUABFKJSXA33TNF2G64TZHM2TCNZXG44DAMJXHNEXG43VMU5TMMBWGY3TQNZSHAZKC5QC>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Oh, also I think it's probably worth separating out the "UNISON" feature
from the anti-aliased wavetables, since they are separate and the wavetable
stuff is already complicated enough. Would you like to split the UNISON
feature into a separate PR?
DAn
…On Mon, Nov 9, 2026 at 8:03 AM Dan Ellis ***@***.***> wrote:
Thanks for the response.
Your measurements are very interesting, I'm not sure exactly what they
measure. The results must depend on the original wavetable, right? And I
suppose they compare alias energy to the "ideal" band-limited rendering,
how do you generate that? sinc-interpolation in floating point or
something?
When it comes to aliases, absolute energy is an upper bound, but the
actual acceptability depends significantly on where the alias harmonics
fall relative to the signal. So I'm interested if you (Rasmus) think the
"4x" tables sound appreciably better than the "1.9x". (I wasn't trying to
advocate for the "0.94x" solution, that would assume that the original 256
waveforms were already 2x oversampled).
I know nothing about existing wavetable systems, is it commonplace to have
this kind of laddered waveshape, or is aliasing accepted as part of the
deal? I supposed I could look at the Mutable Instruments source to find
out what they did.
My impression is that RAM usage is of concern in this scenario, so I can
imagine that halving RAM may be worth 10-20 dB in SNR. I suspect it's only
when we get into the "SNR below 10dB" range that things become really
problematic, but that's just a guess. But maybe the RAM isn't really a
problem, in which case the fixed-size tables are a win (because we can use
the hard-coded 256-point lut render routine).
My point about reusing the code was referencing `choose_from_lutset` etc.
I see you are already using that; I am now happy, not sad.
DAn.
On Sat, Nov 7, 2026 at 4:57 PM Rasmus T ***@***.***> wrote:
> *rt-rtos* left a comment (shorepine/amy#1251)
> <#1251 (comment)>
>
> The numbers, as promised. The first round I posted overstated the cost of
> halving: on one of the shipped tables the halved rungs overflowed the
> 32-bit multiply in render_lut's linear step (more on that below). With
> that multiply done in 64 bits, the same sim (fixed point, 48 kHz, the five
> shipped tables, middle frame; energy between the harmonics relative to the
> harmonics, mean over the tables, worst table in brackets):
> notes no ladder 256 each (4x) 128/64/32/16 (0.94x) 256/128/64/32 (1.9x)
> F#3-D#4 -37 (-33) dB -42 (-35) dB -33 (-26) dB -42 (-35) dB
> F#4-D#5 -31 (-25) dB -43 (-36) dB -29 (-22) dB -30 (-23) dB
> F#5-D#6 -8 (-1) dB -60 (-54) dB -31 (-25) dB -40 (-34) dB
> F#6-F#7 -4 (3) dB -49 (-42) dB -23 (-18) dB -31 (-25) dB
>
> So I'd keep 256 per rung. At 256, each rung down has twice the samples
> per cycle of its top harmonic (4, 8, 16, 32), and the linear
> interpolation's images fall with it; halving holds that at 2 (128/64/32/16)
> or 4 (256/128/64/32), and a table with energy right at a rung's limit then
> images at close to the partial's own level. create_lutset keeps about 8
> (2^ceil(log2(8 x hmax)), so 512/256/128/64 for these limits, 960 samples
> per frame against the ladder's 1024), so the ladder already sits near the
> lutset density.
>
> On sharing: the rungs already go through LUT, choose_from_lutset and
> render_lut. What isn't shared is that render_wavetable ignores the
> picked entry's size and does its own pick before unison_prepare; I can
> make it take the stride and log2 from the entry and drop the extra pick, a
> few lines. Generation can't go through create_lutset, which synthesises
> tables offline from a harmonic list, while the ladder cuts tables that only
> exist at runtime.
>
> Separately: INTERP_LINEAR multiplies (c - b) * frac in 32 bits (MUL0_SS),
> which wraps once neighbouring samples differ by full scale or more. Four of
> the five shipped wavetables have frames like that in the base table (steps
> up to 2.0), so the plain WAVETABLE render already wraps on those frames,
> ladder or not. I'll open an issue for it.
>
> —
> Reply to this email directly, view it on GitHub
> <#1251?email_source=notifications&email_token=AAEGZUMYFG75TEX2K72T7AD5X6LD5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMNZRGM2TGOBSGU2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6713538254>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAEGZUKSDRB7EGPBSPL67EL5X6LD5AVCNFSNUABFKJSXA33TNF2G64TZHM2TCNZXG44DAMJXHNEXG43VMU5TMMBWGY3TQNZSHAZKC5QC>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
|
Splitting them makes sense. I have the frame spread as a standalone commit already; it only means a rebase for whichever goes in second.
From my understanding Mutable does not do this: Braids oversamples 2x, and Plaits stores the integrated wave and differentiates after the read (likely due to being on ~20-32kb of ram). The usual choices seem to be band-limited copies (mip-maps) or oversampling, at the cost of memory or CPU; Surge XT and Odin 2 use copies. Building the copies on request softens the memory cost: only the tables in use carry them, and nothing extra sits in flash. It also means a wavetable generated at runtime gets them. I judged the band-limited approach to be more in line with how AMY does things. I'll come back on to you on the ear check and measurements. |
The saw, pulse and triangle renders pick a table from their lutset only when synth->lut is NULL, and only note-on clears it. A WAVE change on a sounding osc left the old wave's table in place, so a saw switched to TRIANGLE mid-note kept reading the saw's band-limited table, and a triangle switched to SAW_DOWN or PULSE kept reading the triangle's, until the next note-on. play_delta now clears synth->lut when the wave changes, and the new wave picks its own table on the next block. The same wave sent again keeps the table picked at note-on, as before. tests/test_wave_switch: SAW_DOWN -> TRIANGLE, TRIANGLE -> SAW_DOWN and TRIANGLE -> PULSE mid-note, each reading the new wave's lutset on the block after the switch (all three read the old set before); SAW_DOWN sent again under a bend keeping its note-on table.
A wavetable preset plays one 256-sample cycle at every pitch. A cycle drawn with overtones to the 127th folds above about F3, and a scan or a detuned cluster moves the folded partials around, which is the metallic smear a wavetable note gets higher up the keyboard. The saw, pulse and triangle pick a table by pitch from a band-limited set; the wavetable path now does the same from a ladder an embedder builds per preset: pcm_wavetable_ladder_build(preset) computes copies of the table cut at 63, 31, 15 and 7 harmonics (per frame, the Fourier series cut at the limit with the mean kept, 2 * limit * 256 multiply-adds) into one allocation, the preset's rungs are published as a lutset beside the base table, and render_wavetable picks from it with choose_from_lutset, per block for the osc's sharpest copy and per group through unison_prepare. The rungs live on the memory preset and go with it; the ROM wavetables keep theirs in a static table, freed by pcm_deinit. With no ladder built nothing changes, which keeps the default and every reference render as they are. Build and free are the embedder's to call off the render thread: a few million multiply-adds for a 64-frame table. Build publishes the set and free (or unloading the preset) takes it back under amy_render_lock, so a block reads the whole set or none, and the block after a free plays the base table. A second build rewrites the rungs in place from the current table. The osc keeps no pointer into a preset's set past its block: render_wavetable clears synth->lut once the copies hold their tables. WAVETABLE_SAMPLES_PER_CYCLE moves to amy.h, as pcm.c needs it too. tests/test_wavetable_ladder: the rung limits and each rung within 1 LSB of the series on a synthetic table; a note below the base's limit byte-identical to no ladder; notes at 262 and 523 Hz byte-identical to a plain osc on the rung alone; two octave groups against four plain oscs on their two rungs (-57 dB); a rebuild following a rewritten table; free, unload, amy_stop dropping a ROM ladder, and the refusals (stereo, short, missing preset); no pointer into the set kept between blocks, and a mid-note switch to SAW_DOWN reading its own table. The pitch expectations are checked against AMY_SAMPLE_RATE in the test.
The series builder cost about 300 ms per 64-frame table on a 240 MHz ESP32-S3: every rung redid the harmonic analysis and both loops ran on one dependent float accumulator, and on a core without an FPU every one of its 121k multiply-adds per frame was a soft-float call. The rungs are now computed by a real FFT per frame (the even and odd samples packed as one complex 128-point transform, then split to the 64 bins the rungs can hold) and an inverse per rung with the bins above the limit zeroed, in fixed point: samples at 2^-7 in int32, twiddles at Q26 from two 256-entry int16 cosine tables, each product pair summed in 64 bits and rounded once, the forward transform unscaled behind seven guard bits and the inverse halving every stage. No float in the builder. About 90 ms for a 64-frame table on that board, and on a Cortex-M0+ about 11k 64-bit multiplies per frame with no soft-float call. The rungs are within 0.54 LSB of the series computed in double on the five shipped tables and a synthetic one (the series builder's own were within 0.52) and differ from the series builder's on about 1 % of samples, by 1 LSB; test_wavetable_ladder and test_unison pass unchanged. Measured and left out because they miss 1 LSB: 16-bit data halved per forward stage (4 to 5 LSB mean error over the seven halvings) and Q15 twiddles without the residual table (1.3 to 2.6 LSB). A float FFT is faster where there is an FPU (56 ms here) but leaves the FPU-less targets at tens of thousands of soft-float calls per frame; fixed point is the one shape that serves every target. The set shape, the contract and the pick are untouched; the header and synth.md carry the measured cost.
pcm_wavetable_ladder_build() was reachable only from C, so Python,
Tulip, web and sysex users could not build a ladder. zW<preset> builds
the preset's rungs, built-in wavetable or memory preset, and
zW<preset>,0 frees them; nothing is built unless asked. The Python
keyword is wavetable_ladder, a list ('zWL') so the free form goes
through: wavetable_ladder=3 sends zW3, wavetable_ladder=(3, 0) sends
zW3,0. The generated JS and Godot map follow, and docs/api.md and
synth.md give the wire form first.
The builder refuses, with a log line each:
- a preset that is not a memory or built-in wavetable preset, which
covers file presets streamed by zF;
- one that is not a mono table of 16,384 samples, the wavetable format
in the docs (the render reads any number of whole cycles; the builder
keeps to the format), which covers zS recordings, as they are stereo;
- one a z load is still writing. Over sysex a zW sent during a load
arrives as payload, but one sent through amy_add_message() would read
a half-filled table;
- and fails the same way when the rungs cannot be allocated.
pcm_load() and pcm_load_file() already unloaded the old memory preset
and its rungs; a load on a built-in wavetable's number now drops that
table's rungs too. They used to stay allocated under the new preset
and came back after it was unloaded, built from data loaded before.
Like the z load, zW plays the deltas that are due before it builds:
a reset sent just before it (RESET_ALL_OSCS, RESET_SYNTHS) unloads
the memory presets on the render thread, and played during the build
it would free the table being read. The build reads the table
unlocked, so before publishing it looks the preset up again under the
render lock and returns 0, logged, if an unload or reload replaced it;
a first build then frees its rungs instead of writing into a freed
preset. The reads, and a rebuild's writes in place, still rely on the
contract that the preset is not unloaded meanwhile.
zW builds on the thread that parses it, like the other sample
commands. On Pico, Teensy and ESP with multithread=0 that is the loop
that renders, and on every platform a zW fired by the sequencer or a
CV trigger parses on the render thread; the audio waits for the build
there.
tests/test_wavetable_ladder: zW builds and zW,0 frees; a reset sent just
before zW lands first, so nothing is built (fails without the settle);
zW refused after a z header while the data has not arrived; a load over
a ROM wavetable's number leaving no rungs once it is unloaded; a
32-frame table refused.
af4c318 to
5942e00
Compare
|
The ear check and the measurements, as promised.
There is no reference render. For each steady note I take the spectrum and split it by position: what sits on a multiple of the note's frequency counts as harmonic, everything else as between the harmonics, and the figure is the second over the first. A note of the scale never divides 48000 evenly, so anything that folds lands between the harmonics. It does depend on the table: BRAIDS01 sets every worst-table figure. What the rung-size columns pick up is the straight-line read between table samples. The fewer samples per cycle a rung keeps for its top harmonics, the louder their images, roughly 12 to 15 dB for each halving, and the images fold. The closed form for that matches the halved-rung figures within 0.5 dB; I can post it if it is useful.
I could go either way on 1.9x. What it leaves stays in the background, as a texture behind the note, where no ladder makes the folding a significant component of the sound. PPG_WA00 all-under-10MB.mp4BRAIDS01 all-under-10MB.mp4Imported Drawbar WT all-under-10MB.mp4Each video runs a glide from F#3 to F#7 in 12 s, four passes with the spectrogram (linear, 0 to 24 kHz): no ladder, 256 per rung, 256/128/64/32, and last the difference between those two raised 20 dB. PPG_WA00 and BRAIDS01 are at their middle frame. The third is a drawbar-organ table of mine at its last frame: nine sine partials at the same level, the 16th the highest, which makes it a hard case for the halved rungs. Everything is a single osc with no filter. In the later part of the PPG_WA00 glide, 1.9x has audible folding where 256 per rung is clean (-32 dB between the harmonics there, against -65 dB). BRAIDS01 with no ladder turns into a spider's web of folding, and the drawbar table shows the no-ladder case most plainly: from A6 up its top partials bounce back down like a laser beam. What I'd keep 256 per rung for is predictability. A rung at 256 holds some of the base table's harmonics at the base table's density, so building a ladder can't make a note worse than it was without one. Halved rungs lose that: BRAIDS01 at F#4 and A4 is at -23 dB with 256/128/64/32 against -31 and -29 dB with no ladder, and the drawbar table, which folds nothing below A6 and sits at -52 dB there with no ladder, is at -40 dB from F4 and -32 dB from F5. Over the five shipped tables halving costs 7 to 34 dB depending on table and band. The worst cell is -23 dB, so it stays clear of your 10 dB line. The sizes: the rungs are 128 KB per table at 256 each and 60 KB halved. A loaded or generated table also holds its own 32 KB, so 160 KB against 92 KB in all. It is spent only on presets someone sent I concede that losing the predictability, and the lesser audible aliasing that remains, could be worth halving the memory cost.
What no ladder costs depends on the table and the register. BRAIDS01 from A5 up has more energy between the harmonics than in them; VIRAL is at -60 dB up to A4 with nothing to fix. That fits building on request. There is some merit to it as part of the sound: a high note played from only 7 harmonics comes out somewhat sterilized. I still think that is a cleaner representation of the wavetable than whatever the aliasing leaves. And where the aliasing is wanted, nothing is lost: without |
Summary
Four commits for WAVETABLE. The unison frame spread that was commit 2 here is now #1259.
render_wavetablepicks one by pitch from the set, as the saw does, so a wavetable stops folding higher up the keyboard. Nothing in the audio changes unless rungs are built.zWbuilds and frees a preset's rungs over the wire.zW<preset>builds,zW<preset>,0frees;wavetable_ladderin Python.The commit messages carry the test-by-test detail;
docs/synth.mdon the branch carries the user-facing semantics.Open
Settled in the thread: rungs are built on request through
zW, not by default, and the frame spread is its own PR (#1259).1. amy: a WAVE change clears the osc's table
The saw, pulse and triangle pick a table only when
synth->lutis NULL, and only note-on cleared it, so a mid-note switch kept reading the previous wave's table until the next note-on. The table is now cleared when the wave changes; the same wave sent again keeps the table picked at note-on. It changes behaviour for everyone, which is why it is its own commit.tests/test_wave_switch: SAW_DOWN -> TRIANGLE, TRIANGLE -> SAW_DOWN and TRIANGLE -> PULSE mid-note (all three read the old wave's lutset before) and a repeated wave.2. wavetable: band-limited rungs per preset, picked by pitch like the saw
A cycle drawn with overtones to the 127th folds above about F3 at 44.1 kHz,
and a scan or a detuned cluster moves the folded partials around, which is
the metallic smear a wavetable note gets higher up the keyboard. On the
shipped tables the folded energy in the worst frame is -12 dB (111) to -5 dB
(SINE2SAW) relative to the frame at C4, -3 dB at C5.
01-wavetable-ladder.mp4
The wire form and the Python keyword come with commit 4. amy.h gains
pcm_wavetable_ladder_build,pcm_wavetable_ladder_free,pcm_wavetable_lutsetandAMY_WAVETABLE_LADDER_RUNGS.Context
static table in
pcm.c, freed bypcm_deinit; asking the embedder topcm_loada copy instead would cost a 32 KB copy of each shipped tablebefore its ladder. A memory preset's rungs go with the preset.
free and unload take
amy_render_lock, so a block reads the whole set ornone; the compute runs outside it. A second build rewrites the rungs in
place, so a block rendered meanwhile may read a half-written rung once,
and build must not run while that preset is loading or unloading. amy.h
says so.
moves within a note: a rung picked at note-on folds once a bend or a sweep
carries the note above its limit. It is per group, not per osc, because
the groups sit at octave intervals: each group reads the rung for its own
sharpest copy, so an octave-up group does not fold on the base group's
table.
render_wavetableclearssynth->lutonce the copies hold theirtables, so no osc keeps a pointer into a preset's set between blocks and a
free or unload under the lock leaves nothing dangling. One lookup and one
short list walk per osc per block; nothing in the per-sample path.
Verification
tests/test_wavetable_ladder(new, fixed point): each rung within 1 LSB ofthe series, notes byte-identical to a plain osc on the rung their pitch
names and to no ladder below the base's limit, a two-octave cluster against
plain oscs on its rungs at -57 dB, and the lifecycle.
test_unisonandtest_pcm_memory_presetpass unchanged.rungs (the video). From C4 up the ladder takes 9 to 24 dB out of the notes
(the difference against the shipped render; 111 the least, BRAIDS01 the
most). Peaks unchanged within 0.01 dB.
Not measured for audibility. A windowed cut would lower it and change the
rungs' content.
3. wavetable: ladder rungs by a fixed-point FFT
Commit 2's builder redid the harmonic analysis for every rung, in float: a
soft-float call per multiply-add on a core without an FPU. This commit does
one real FFT per frame and an inverse per rung, in fixed point, no float in
the builder. About 2 KB of stack on the calling thread (the old builder
0.5 KB); amy.h says so.
A float FFT measured 56 ms on the same board and is what my own firmware
runs; fixed point is the shape that serves every target AMY ships on.
Against the series computed in double, both builders are within 0.54 LSB
peak and 0.26 LSB mean on the five shipped tables and a synthetic one.
Verification
test_wavetable_ladderandtest_unisonpass unchanged; the ladder testholds every rung within 1 LSB of the series.
each builder's rungs: -94 dB difference, no sample more than 1 LSB apart.
The video above was rendered with commit 2's rungs.
4. wavetable: zW builds and frees a preset's ladder over the wire
zW<preset>builds,zW<preset>,0frees, for a built-in wavetable or a memory preset. The Python keyword iswavetable_ladder:wavetable_ladder=3sendszW3,wavetable_ladder=(3, 0)sendszW3,0. Generated JS and Godot map, and a row indocs/api.md.zload is still writing, azFpreset, and anything that is not a mono table of 16,384 samples. That includeszSrecordings, which are stereo.multithread=0, and on every platform when the sequencer or a CV trigger fires thezW; there the block waits for the build. amy.h anddocs/api.mdsay so.tests/test_wavetable_ladderadds build and free over the wire, a refusal after azheader whose data has not arrived, a load over a ROM wavetable's number, and a 32-frame table refused.Notes for reviewers
WAVETABLE_SAMPLES_PER_CYCLEand its log2 move from oscillators.c toamy.h, as pcm.c needs them; the
_Static_asserttying the two stays inoscillators.c because amy.h is also compiled as C++.
AMY_HAS_MUL64branchof
amy_fixedpoint.hwrites them, inline with the builder's own Q26 shift;the builder is off the render path, so it takes no 32-bit alternative.