NAME

gen9 - make a function with a waveform, composed of any partials


SYNOPSIS

makegen(table_number, 9, table_size, partial1_ratio, partial1_amp, partial1_phase [, ... partialN_ratio, partialN_amp, partialN_phase ])


DESCRIPTION

Call makegen from a script with a function_type of 9 to make a function table with a waveform. You define the waveform in terms of any number of partials, harmonic or inharmonic, with specific amplitudes and starting phase for each.

NOTE: Much of the functionality of gen 9 has been duplicated and extended by the "wave3" table-type in maketable and the new (in RTcmix 4.0) table-handle scheme.


ARGUMENTS

table_number
The numeric ID for the function table.

Normally the table will be rescaled to fit between -1 and 1. Put a negative sign before the number to prevent this.

table_size
The size of the function table: how many values it stores. The larger the size, the less quantization noise you'll get when using this with a wavetable oscillator (as in WAVETABLE).

partialN_ratio
The ratio of partial N to the fundamental. A ratio of 1 is the fundamental, a ratio of 2 is the second harmonic partial, a ratio of 5.1 is a little higher than the fifth harmonic partial, a ratio of 0 is DC, and so on.

Note that inharmonic partials in are not truly inharmonic, since their periodicity is governed by the table size. In contrast, all harmonic partials complete an integer number of cycles spanning the table.

partialN_amp
The amplitude of partial N, relative to the other partials.

partialN_phase
The starting phase of partial N, in degrees. Phase can be negative.


EXAMPLES

   makegen(2, 9, 1000, 1, 1, 0)

makes one cycle of a sine wave, at full amplitude, with starting phase of 0 degrees. This is exactly equivalent to makegen(2, 10, 1000, 1).


   makegen(-2, 9, 1000, 1, 0.5, 90)

makes one cycle of a cosine wave, at half amplitude (from -.5 to +.5). Making table_number negative prevents rescaling the function to span -1 to +1.


   makegen(2, 9, 1000,  1, 1, 0,  2, 0.4, 90,  10.1, 0.1, 130)

makes a waveform with the first harmonic at amplitude 1 and phase 0, the second harmonic at amplitude 0.4 and phase 90, and an inharmonic partial with 10.1 times the frequency of the fundamental at amplitude 0.1 and phase 130.


   makegen(1, 9, 1000,  0.5, 1, 0)

makes a waveform with one half-cycle of a sine wave, suitable for use as a grain envelope.


   makegen(-1, 9, 1000,  0, 0.5, 90,  1, 0.5, -90)

makes a ``raised cosine'' shape, or hanning window. (Gen 25 does this more simply.) The DC component specified by the first triplet of arguments adds 0.5 to every point on the phase-shifted sine wave cycle specified by the second triplet of arguments, thus making all the table values positive. Not sure why DC phase has to be non-zero, but it does.



NOTES

Gen 10 lets you specify a waveform more simply, but with only harmonic partials and no phase adjustment.


SEE ALSO

makegen, gen10, gen25