WAVESHAPE -- waveshape distortion synthesis
in RTcmix/insts/std
quick syntax:
WAVESHAPE(outsk, dur, freq (Hz/oct.pc), indexmin, indexmax, amp[, pan, wavetable, transferfunction, indexenv, ampnormalize {default: 1}])
underlined parameters are
pfield-enabled
for table or dynamic control (see the
maketable
or
makeconnection
scorefile commands). Parameters after the [bracket] are optional and
default to 0 unless otherwise noted.
4.0 Newer Documentation (taken from the source code):
older docs and more explanation below
WAVESHAPE -- waveshaping synthesis instrument
p0 = start time
p1 = duration
p2 = frequency (Hz or oct.pc)
p3 = minimum distortion index
p4 = maximum distortion index
p5 = amp *
p6 = pan (in percent-to-left form: 0-1) [optional; default is 0]
p7 = reference to oscillator waveform table [optional; if missing,
must use gen 2] **
p8 = reference to waveshaping tranfer function table [optional; if missing,
must use gen 3] ***
p9 = index guide [optional; if missing, must use gen 4] ****
p10 = amp normalization [optional; default is on (1)]
p2 (freq), p3 (min index), p4 (max index), p5 (amp), p6 (pan) and
p9 (index) can receive dynamic updates from a table or real-time
control source.
NOTE: The amp normalization in this instrument can cause clicks at
the beginning and ending of notes. Passing zero for p10 turns it off.
----
Notes about backward compatibility with pre-v4 scores:
* If an old-style gen table 1 is present, its values will be multiplied
by p5 (amplitude), even if the latter is dynamic.
** If p7 is missing, you must use an old-style gen table 2 for the
oscillator waveform.
*** If p8 is missing, you must use an old-style gen table 3 for the
waveshaping transfer function.
**** If p9 is missing, you must use an old-style gen table 4 for the
distortion index curve.
rev for v4, JGG, 7/22/04
Older Documentation:
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)