Skip to content

Tables and Guard Points

Generating Function Tables

Tables are generated by subroutines called GEN Routines. Traditionally GEN Routines are called in the score by a f-statement. Most users nowadays create function tables in the orchestra part of the code via the ftgen opcode.

This statement creates a table with 1024 points via GEN10, resulting in a sine, in the score section:

  f 0 0 1024 10 1

This statements creates the same table in the orchestra section:

  ftgen(0, 0, 1024, 10, 1)

Normalization

When a GEN Routine is called with a positive number, the content of the function table is normalized to a maximum value of 1 or -1. This can be avoided by calling the GEN Routine with a negative number.

This call will normalize the sample "dish.wav" while transferring the audio data to a table:

  ftgen(0, 0, 0, 1, "dish.wav", 0, 0, 0)

This call will not normalize the sample "dish.wav":

  ftgen(0, 0, 0, -1, "dish.wav", 0, 0, 0)

Guard Points

A guard point is the last position on a function table. If the table size is 1024, the table will have 1024+1 (1025) points: the extra point is the guard point. For the 1024-point table, the first point is index 0 and the last 1023; index 1024 (Guard Point) is not really used.

The reason for a guard-point is that some opcodes interpolate to obtain a table value, in which case, when the table index is say, 1023.5, we need the value of the 1024 pos in order to interpolate.

There are two ways of filling this point (writing the value that goes in it):

  • Default way: by copying the value of the 1st point in the table
  • Extended Guard-Point: extending the contour of the table (continuing to calculate the table for one extra point)

In general the first mode is used for wrap-around applications, such as an oscillator (which loops continuously reading the table). The second use is for one-shot readouts, such as envelopes, where the last point needs to be interpolated correctly following the table contour (we are not looping back to the beginning of the table).