Wavetable instrument: two-oscillator band-limited wavetable synth (0.32.0)

Written for Sizzle (the hub's candidates are GPL-3.0-only, so nothing was
copied): tables kept as spectra and rendered per octave by inverse FFT with
a taper, level picked per control block so high notes don't alias; twelve
generated tables plus Serum / WaveEdit WAV import (clm chunk, frame-size
guessing, rebuilt from the kept WAV after a restart); two oscillators with
position, phase bend and up to 4-voice unison, sub, noise, drive, SVF,
amp and mod envelopes, tempo-synced LFO. 12 factory presets. Played inside
SynthVoice like the Morph Pad.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-13 09:30:09 +01:00
co-authored by Claude Opus 5.5
parent aa023d1f01
commit c8d760ed17
18 changed files with 1172 additions and 33 deletions
+44 -1
View File
@@ -212,7 +212,7 @@ cc.tiredsysadmin.android.sizzle
│
├── audio/ The real-time sound engine (own thread)
│ ├── Transport.kt TransportState snapshot published to the UI
│ ├── SynthVoice.kt One synth note (3-osc subtractive), or a Morph Pad note via FrasilVoice
│ ├── SynthVoice.kt One synth note (3-osc subtractive), or a Morph Pad / Wavetable note (FrasilVoice / WaveVoice)
│ ├── GrainSources.kt The Grain Cloud's ten built-in sources, synthesised in the background
│ ├── SampleVoice.kt Pitched + sliced playback of a decoded sample
│ ├── SampleStore.kt Process-wide decoded-PCM cache + WAV encode/decode
@@ -229,6 +229,11 @@ cc.tiredsysadmin.android.sizzle
│ ├── FrasilPatch.kt Parsed slot snapshot (+ morph target); FrasilClock (the shared TIDE time)
│ └── FrasilVoice.kt One pad note: choir + partials + breath, drift, tide, warmth
│
├── wavetable/ The Wavetable synth (Sizzle's own, GPL; see §5.9)
│ ├── WaveTables.kt Band-limited tables: FFT, one mip level per octave, 12 generated tables, WAV import
│ ├── WaveDefs.kt Its settings, editor pages, 12 factory presets
│ └── WaveVoice.kt WavePatch + one note: 2 table oscillators, bend, unison, sub, SVF, 2 envelopes, LFO
│
├── echofield/ MIT: the Grain Cloud, ported from ECHOFIELD (see §5.8)
│ ├── EchofieldDefs.kt Its settings, editor pages, 14 factory presets, the source list
│ └── GrainCloud.kt GrainPatch + one channel's cloud: modes, scheduler, grains, gate, auto-level
@@ -522,6 +527,44 @@ custom source survives a restart without saving a preset.
about a synth note's level (`GrainCloudTest.aCloudIsAboutAsLoudAsASynthNote`).
Four dense clouds (32 grains each) took about 1.3 % of real time on a desktop JVM.
### 5.9 The Wavetable synth (Sizzle's own)
The **Wavetable** instrument (`ToolboxType.WAVETABLE`) was the third pick from the
FM-1 firmware hub, but the candidates there (Clipper's WAVE engine, TastyWaves) are
**GPL-3.0-only**: copying them would have made the whole app GPL-3.0-only. So it was
written from scratch with the standard techniques they also use; no code was taken.
**Tables** (`WaveTables`). A table is up to 256 single-cycle frames (16 in the
factory set). Each frame is kept as a spectrum (cosine/sine of harmonics 1..512) and
rendered by an inverse FFT into one **mip level per octave**: level k holds
`512 >> k` harmonics in `max(64, 4·harmonics)` samples, the top quarter of its
harmonics faded with a raised cosine so switching levels is inaudible. The voice
picks, every 16 samples, the level whose top harmonic (times BEND's steepening) stays
under 0.45·fs — `WavetableTest.aHighSawDoesNotAlias` measures the off-harmonic
energy of a C7 saw at about 3e-5. Reads are linear inside a cycle (four samples per
top harmonic make that clean) and linear between neighbouring frames.
**Factory tables** are formulas (no audio ships): Classic (sine → tri → saw → square
→ pulse), PWM, Vowels (moving formants), Harmonic Sweep, Sync, FM, Organ (drawbar
registrations), Fold, Digital (bit reduction), Glass (sparse harmonics), Odd Even,
Comb (moving notches). They are built on a background thread at startup
(`prewarm`); a table not ready yet is silent rather than blocking.
**Import.** LOAD TABLE takes a WAV: Serum's `clm ` chunk gives the frame length;
otherwise 16384 samples is read as WaveEdit (64 × 256), then 2048-, 256-, 1024- or
512-sample frames by divisibility (Frame Size overrides it). The table is built on
the UI thread at import; the WAV is kept like the Grain Cloud's custom source
(`sfSample`/`sfFile`, a copy in the preset folder), so after a restart only the WAV
comes back and `WaveTables.forSample` rebuilds the table once on its worker.
**Voice** (`WaveVoice`, played inside `SynthVoice` like the Morph Pad): two
oscillators (table, POSITION, octave/semi/fine, level, BEND), up to 4 unison copies
spread ±30 cents, a sub sine, noise, tanh drive, a TPT state-variable filter
(low/band/high), a linear amp envelope, a mod envelope (to position and cutoff) and a
tempo-synced LFO (to position, pitch, cutoff). BEND is a two-segment phase warp, as in
phase-distortion synthesis. 32 voices with 2 oscillators × 4 unison took about 6 %
of real time on a desktop JVM.
---
## 6. How to extend