F-Tables

F-tables, or "function tables" are terms borrowed from the Csound language. Simply put, ftables are arrays of floating point values. They are often used by audio-rate signal generators in Sporth like samplers and table-lookup oscillators.

F-tables in Sporth are coupled with gen routines (another term from the Csound/Music N world). Gen routines are in charge of filling stuff into the F-tables. In Soundpipe, ftable creation and gen routines are two separate operations. However, in Sporth, ftable creation and gen routine calls are a single operation.

A simple example

Our most basic gen routine is a sine wave generator, which computes a single cyle of a sine wave. The code below shows how can build a 300 Hz sine wave using a table lookup oscillator:

 "sine" 4096 gen_sine
 330 0.5 0 "sine" osc

A few things to take note of:

Gen routines with arguments

Most gen routines are adopted from Csound, where arguments exist inside a string, separated by spaces. In Sporth/Soundpipe this convention is carried over. The following patch uses sawtooth wavetable oscillator, whose wavetable was generated using the gen_line gen routine. For variety, a random number sample and hold generator is feeding into the frequency of the saw, and is also being fed into a butterworth lowpass filter.

 "saw" 4096 "0 1 4096 -1" gen_line
 (300 800 10 randh) 0.3 0 "saw" osc 
 (1000 butlp)

Gen routines conventionally follow a similar argument structure:

NAME SIZE ARGSTRING gen_routine

Where:

Because of the argument strings, gen routines are tricky things to use and learn about. The Soundpipe reference guide, is the most comprehensive starting point. For instance, here is the entry on gen_line, the gen routine used in above example.

The underscore (_) shortcut

To save keystrokes and make ftables look prettier, the underscore key can be used in place of strings without spaces. For instance:

 "line" 4096 "0 1 4096 -1" gen_line

Is identical to:

 _line 4096 "0 1 4096 -1" gen_line

This is the preferred convention for ftables and variables, which will be discussed in the next chapter.

Unit generators that use f-tables

Here are some common unit generators that make use of f-tables:


Back