Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@maruaudio/dsp/tables/sample-reader plays a mono table of up to 65536 f32 samples (SAMPLE_TABLE_MAX_SAMPLES) with linear interpolation. One state machine serves cyclic wavetable playback and one-shot regions: a region is chosen as normalized start and end points, the read position advances by playbackRate source samples per output frame, and at the region end it either wraps by the region span or stops and latches finished. Voices, polyphony and grain scheduling stay outside it.

Parameters

configureSampleTableReader(state, playbackRate, startNormalized, endNormalized, gain, loop) sets them together.

ArgumentRange as codedDefault from initUnit
playbackRate0 to 161source samples per frame
startNormalized0 to 1, floored to an index, at most length − 10fraction of the table
endNormalized0 to 1, floored; at least start + 1, at most lengthtable endfraction of the table
gain0 to 41linear
loop0 one-shot, anything else loops0flag

Lifecycle

initSampleTableReader() allocates the full-capacity table. loadSampleTable(state, available, readSample) runs on the control thread: it stores up to the capacity through the caller's decoder callback, resets the region to the whole table and returns the accepted length. Then configureSampleTableReader → sampleTableReaderTick per sample → resetSampleTableReader, which returns to the region start and clears finished. sampleTableLinearAt(state, position) is the shared interpolation read for table-driven voices.

When to use it

A single-cycle wavetable or a short sample played at a fixed rate, looped or once, inside a larger voice. For loop crossfades and reverse play see @maru/tables-looped-region.

Limits

  • Mono sample tick; linear interpolation only. No smoothing on rate or gain.
  • Configuring re-seeks to the region start. An empty table ticks 0 and is finished.
  • At the end of a looped region the interpolation partner is the region start; in a one-shot it is the last sample.
  • The loop wrap is a while subtraction of the span; the rate cap of 16 keeps it short. Clamps are conditional, so NaN settings pass through.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Ports

  • Out outoutput · audio · mono

One sample per sampleTableReaderTick call.

Dependencies

None: this node imports no other node.

Dependents

No other node imports this one.

Used by

No plugin with a published composition uses this node yet.