AudioMasher
[continue autosave] Learn Sporth
log in learn new browse

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 like samplers and table-lookup oscillators. Gen routines are in charge of filling stuff into the F-tables.

A simple example

Our most basic gen routine is gen_sine, 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:

Currently, the most comprehensive description of existing gen routines is the Soundpipe reference guide, which describes the Sounpipe function underlying each Sporth gen routine. 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:


Previous: Gates and Triggers | Back | Next: Variables


Compile & play Stop audio