WAVESHAPE


Waveshaping: a type of distortion synthesis wherein an input waveform is modified by a transfer function to produce an output signal. Thus, an input signal, x, puts out an output signal, y, by passing through a function defined as y = f(x). So:
   f(x) = x2 will exponentially expand the amplitude of the incoming waveform (Dodge and Jerse, 1985).

Other useful transfer functions to use are waveforms and Chebyshev polynomial equations, which can output pre-defined harmonic spectra.

WAVESHAPE(), the command in WAVESHAPE, uses makegen to define its transfer function. The makegen essentially draws a graph with input samples coming in on the x axis and output samples going out the y axis.

Syntax:


makegen(1, 24, 1000, t0, a0, t1, a1...) /* the amplitude of the output in time/amplitude pairs */
makegen(2, 10, 1000, p0, p1...) /* the incoming waveform defined by the relative amplitude of its partials */
makegen(3, 7, 1000, a0, g0, a1, g1...aN) /* transfer function for the waveshaper, where aN and aN+1 are amplitudes and gN is the number of points in the curve to interpolate between them (the sum of the g values cannot exceed the number allocated in p2, in this case 1000) */
makegen(4, 24, 1000, t0, a0, t1, a1...) /* the index envelope of the waveshaper, allowing the waveshaping to increase and decrease over time */

WAVESHAPE(outskip, duration, pitch, indexlow, indexhigh, amplitude, spread)

in comment form:

/* waveshaping instrument
*  p0 = start
*  p1 = duration
*  p2 = pitch (hz or oct.pc)
*  p3 = index low point
*  p4 = index high point
*  p5 = amp
*  p6 = stereo spread (0-1) 
*  function slot 1 is amp envelope
*     slot 2 is waveform to be shaped (generally sine)
*     slot 3 is the transfer function
*     slot 4 is the index envelope
*/

An example score:

rtsetparams(44100, 2)
load("WAVESHAPE")
makegen(1, 24, 1000, 0,0, 3.5,1, 7,0)
makegen(2, 10, 1000, 1)
makegen(3, 7, 1000, -0.7, 200, -0.5, 300, 0, 300, 0.5, 200, 0.7)
makegen(4, 24, 1000, 0,0, 3.5,1, 7,0)
WAVESHAPE(0, 7, 7.02, 0, 1, 10000)
WAVESHAPE(0, 7, 7.021, 0, 1, 10000)

Another score. Note that makegen 3 uses gen number 17, which creates a Chebyshev polynomial for defining harmonics:

rtsetparams(44100, 2)
load("WAVESHAPE")
makegen(1, 24, 1000, 0,0, 3.5,1, 7,0)
makegen(2, 10, 1000, 1)
makegen(3, 17, 1000, 0.9, 0.3, -0.2, 0.6, -0.7)
makegen(4, 24, 1000, 0,0, 3.5,1, 7,0)
WAVESHAPE(0, 7, 7.02, 0, 1, 9000, 0.99)
makegen(2, 24, 1000, 0,0, 1.5,1, 7,0)
makegen(4, 24, 1000, 0,1, 7,0)
WAVESHAPE(4, 7, 6.091, 0, 1, 10000, 0.01)