WAVETABLE -- wavetable synthesis instrument
in RTcmix/insts/base


quick syntax:
WAVETABLE(outsk, dur, amp, freq (Hz/oct.pc)[, pan, wavetable])





4.0 Newer Documentation (taken from the source code):
older docs and more explanation below
   WAVETABLE -- simple wavetable oscillator instrument
 
   p0 = start time
   p1 = duration
   p2 = amp *
   p3 = frequency (Hz or oct.pc **)
   p4 = pan (in percent-to-left form: 0-1) [optional; default is 0]
   p5 = reference to wavetable [optional; if missing, must use gen 2 ***]

   p2 (amplitude), p3 (freq) and p4 (pan) can receive dynamic updates
   from a table or real-time control source.

   * If an old-style gen table 1 is present, its values will be multiplied
   by the p2 amplitude multiplier, even if the latter is dynamic.

   ** oct.pc format generally will not work as you expect for p3 (osc freq)
   if the pfield changes dynamically.  Use Hz instead in that case.

   *** If p5 is missing, you must use an old-style gen table 2 for the
   oscillator waveform.

                                                rev for v4, JGG, 7/12/04



Older Documentation:


NAME

WAVETABLE - wavetable synthesis instrument


SYNOPSIS

WAVETABLE(outskip, dur, amp, freq [, stereoloc ])

Function table 1 gives amplitude curve.

Function table 2 gives waveform.


DESCRIPTION

WAVETABLE consults a wavetable -- a table that stores one cycle of an arbitrary waveform -- to construct a signal at a specified frequency. It scans the wavetable at a rate determined by the frequency and table size. (See Dodge and Jerse, or any other computer music text, for detailed explanation of this process.)

WAVETABLE uses the curve provided in function table 1 to scale the amplitude of the output. Use setline, setexp, or makegen to create function table 1. If this table has not been created, no amplitude scaling will occur.

WAVETABLE uses the waveform in function table 2. Use gen 9 or gen 10 to make this.

The output of WAVETABLE can be either stereo or mono.


PFIELDS

p0 (outskip) output start time
p1 (dur) duration
p2 (amp) peak amplitude
p3 (freq) frequency (or pitch in octave.pc if < 15)
p4 (stereoloc) percent (from 0 to 1) of signal to place in left output channel [optional, default is 0 if output is stereo]


EXAMPLES

The following plays a sine wave for 4 seconds, at a frequency of 440 Hz and peak amplitude of 10000.

   makegen(2, 10, 1000, 1)    /* sine wave */
   WAVETABLE(outskip = 0, dur = 4, amp = 10000, freq = 440)

The following plays a sawtooth wave for 2 seconds, starting at 3 seconds after the beginning of the score. The pitch is the G above middle C, the peak amplitude is 4500, and the stereo location is nearly hard right.

   makegen(2, 10, 1000, 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9)
   WAVETABLE(outskip = 3, dur = 2, amp = 4500, pitch = 8.07, loc = 0.1)

Make the sound a little more interesting by using two WAVETABLE calls, each with slightly different pitch, to get a chorusing effect.

   dur = 10
   amp = 8000
   pitch = 8.00
   makegen(2, 10, 1000, 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9)
   WAVETABLE(0, dur, amp, pitch, loc = 0.4)
   WAVETABLE(0, dur, amp, pitch + 0.0002, loc = 0.6)


Some additional scorefiles:
rtsetparams(44100, 2)
load("WAVETABLE")
makegen(1, 7, 1000, 0, 50, 1, 900, 1, 50, 0)
makegen(2, 10, 1000, 1, 0.3, 0.2)

start = 0.0
freq = 149.0

for (i = 0; i < 40; i = i+1) {
        WAVETABLE(start, 40-start, 500, freq)
        start = start + 1.0
        freq = freq + 25
        }

Another score:

rtsetparams(44100,2)
load("WAVETABLE")
/* uncomment the following line to get rid of all the screen output */
/* print_off() */
makegen(1, 24, 1000, 0,0, 0.01,1, 0.1,0.2, 0.4, 0)
makegen(2, 10, 1000, 1, 0.3, 0.2)

reset(20000)
start = 0.0
freq = 149.0

for (i = 0; i < 100; i = i+1) {
        WAVETABLE(start, 0.4, 5000, freq, 0)
        WAVETABLE(start+random()*0.07, 0.4, 5000, freq+random()*2, 1)
        start = start + 0.1
        makegen(1, 10, 1000, 1, random(), random(), random(), random(), random()
, random())
        }

A third score:

rtsetparams(44100, 2)
load("WAVETABLE")
print_off()
makegen(1, 24, 1000, 0, 1,  950, 0)
makegen(2, 10, 1000, 1, 0.3, 0.2)

srand(0.35)

for (start = 0; start < 7; start = start + 0.14) {
freq = random() * 200 + 35
        for (i = 0; i < 3; i = i+1) {
                WAVETABLE(start, 0.4, 1500, freq, 0)
                WAVETABLE(start+random()*0.1, 0.4, 1500, freq+(random()*7), 1)
                if (start > 3.5) {
                        makegen(1, 10, 1000, 1, random(), random(),random(),rand
om(),random(),random(),random(),random(),random(),random(),random())
                        }
                freq = freq + 125
                }
}


SEE ALSO

setline, setexp, makegen, gen9, gen10, WIGGLE