feat: add a bounded WAV sampler with looping, relinking and saved presets

This commit is contained in:
Johannes Findeisen 2026-11-05 23:50:14 +01:00
commit 35bf6a00a1
24 changed files with 213 additions and 32 deletions

View file

@ -90,3 +90,34 @@ Format 14 adds instrument controls and automation. Readers still accept v1–v13
old fixed internal assignments use their original defaults. Older builds reject
v14. Tests cover legacy-default sound equality, v13 migration, parameter/preset
round trips, pitch-bend offsets, automated block partitions, undo and GUI edits.
## Phase 42 sample instrument
**File → Load sampler WAV** assigns a Sample Player to the selected track or
relinks its existing sample while retaining its controls. Use the instrument
controls editor for root MIDI key (0..127), whole-sample loop (0/1), attack,
release and gain (0..4). One root mapping covers every MIDI key using linear
rate conversion, including source/output sample-rate differences. Loop and root
are integer controls and require hold automation. Live bend spans ±2 semitones.
This initial sampler has no multisample zones, loop-point editor or time stretch.
Extreme transposition can alias; use appropriate source material.
The existing WAV reader supports PCM16/24/32 and float32, mono/stereo downmixed
to mono. Each sample is at most 16M mono frames; the combined instrument plan
budget is 64M frames (256 MiB). Files are at most 256 MiB, with 4096 chunks.
There are 32 preallocated voices per track. Loading and freeing happen only on
the control thread; playback interpolates cached samples without I/O.
Missing/invalid samples retain their references and play silence, reported in
backend asset-issue counts, GUI preparation warnings and `xtc-check --inspect`.
Relink with Load sampler WAV; it is one undoable prepared edit. Allocation and
capacity failures reject preparation. Format 15 adds a SAMPLE reference after
each instrument's controls/automation; in-project samples save relatively and
resolve relative to the project file. Other samples retain absolute paths.
Preset files include the reference but do not embed/copy audio.
`examples/projects/original-pluck.wav` is an original synthesized example with
license/provenance in SAMPLE_LICENSE.md. Both are installed with the examples.
Tests cover source-rate conversion, one-shot endpoint, looping, release,
partitioning, preset references, missing assets, GUI relinking/undo/reload and
preparation-allocation/callback guards.