tablexkt — Reads function tables with linear, cubic, or sinc interpolation.


Reads function tables with linear, cubic, or sinc interpolation.


ares tablexkt xndx, kfn, kwarp, iwsize [, ixmode] [, ixoff] [, iwrap]


iwsize -- This parameter controls the type of interpolation to be used:

  • 2: Use linear interpolation. This is the lowest quality, but also the fastest mode.

  • 4: Cubic interpolation. Slightly better quality than iwsize = 2, at the expense of being somewhat slower.

  • 8 and above (up to 1024): sinc interpolation with window size set to iwsize (should be an integer multiply of 4). Better quality than linear or cubic interpolation, but very slow. When transposing up, a kwarp value above 1 can be used for anti-aliasing (this is even slower).

ixmode1 (optional) -- index data mode. The default value is 0.

  • 0: raw index

  • any non-zero value: normalized (0 to 1)

[Note] Notes

if tablexkt is used to play back samples with looping (e.g. table index is generated by lphasor), there must be at least iwsize / 2 extra samples after the loop end point for interpolation, otherwise audible clicking may occur (also, at least iwsize / 2 samples should be before the loop start point).

ixoff (optional) -- amount by which index is to be offset. For a table with origin at center, use tablesize / 2 (raw) or 0.5 (normalized). The default value is 0.

iwrap (optional) -- wraparound index flag. The default value is 0.

  • 0: Nowrap (index < 0 treated as index = 0; index >= tablesize (or 1.0 in normalized mode) sticks at the guard point).

  • any non-zero value: Index is wrapped to the allowed range (not including the guard point in this case).

[Note] Note

iwrap also applies to extra samples for interpolation.


ares -- audio output

xndx -- table index

kfn -- function table number

kwarp -- if greater than 1, use sin (x / kwarp) / x function for sinc interpolation, instead of the default sin (x) / x. This is useful to avoid aliasing when transposing up (kwarp should be set to the transpose factor in this case, e.g. 2.0 for one octave), however it makes rendering up to twice as slow. Also, iwsize should be at least kwarp * 8. This feature is experimental, and may be optimized both in terms of speed and quality in new versions.

[Note] Note

kwarp has no effect if it is less than, or equal to 1, or linear or cubic interpolation is used.


Here is an example of the tablexkt opcode. It uses the file tablexkt.csd.

Example 1101. Example of the tablexkt opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac           -iadc     ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o tablexkt.wav -W ;;; for file output any platform

;Example by Jonathan Murphy

  sr	    =  44100
  ksmps	    =  10
  nchnls    =  1

    instr 1

  ifn	    =  1    ; query f1 as to number of samples
  ilen	    =  nsamp(ifn)

  itrns	    =  4   ; transpose up 4 octaves
  ilps	    =  16  ; allow iwsize/2 samples at start
  ilpe	    =  ilen - 16   ; and at end
  imode	    =  3  ; loop forwards and backwards
  istrt	    =  16  ; start 16 samples into loop

  alphs	    lphasor   itrns, ilps, ilpe, imode, istrt
	; use lphasor as index
  andx	    =  alphs

  kfn	    =  1   ; read f1
  kwarp	    =  4 ; anti-aliasing, should be same value as itrns above
  iwsize    =  32  ; iwsize must be at least 8 * kwarp

  atab	    tablexkt  andx, kfn, kwarp, iwsize

  atab	    =  atab * 10000

	    out	      atab



f 1 0 262144 1 "drumsMlp.wav" 0 4 1
i1 0 60


See also

Table Reading with Dynamic Selection


Author: Istvan Varga
January 2002
Example by: Jonathan Murphy 2006

New in version 4.18