This subroutine will generate a piecewise cubic spline curve, the smoothest possible through all specified points.
size -- number of points in the table. Must be a power of 2 or power-of-2 plus 1 (see f statement).
a, b, c, etc. -- ordinate values of the function.
n1, n2, n3 ... -- length of each segment measured in stored values. May not be zero, but may be fractional. A particular segment may or may not actually store any values; stored values will be generated at integral points from the beginning of the function. The sum n1 + n2 + ... will normally equal size for fully specified functions.
![]() | Note |
---|---|
|
Here is a simple example of the GEN08 routine. It uses the files gen08.orc and gen08.sco. It will create a curve with a smooth hump in the middle, going briefly negative outside the hump then flat at its ends. Here is its diagram:
Diagram of the waveform generated by GEN08.
Example 1. A simple example of the GEN08 routine.
/* gen08.orc */
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
; Instrument #1.
instr 1
; Create an index over the length of our entire note.
kcps init 1/p3
kndx phasor kcps
; Read Table #1 with our index.
ifn = 1
ixmode = 1
kval table kndx, ifn, ixmode
; Generate a sine waveform, use our Table #1 value to
; vary its frequency by 100 Hz from its base frequency.
ibasefreq = 440
kfreq = kval * 100
a1 oscil 20000, ibasefreq + kfreq, 2
out a1
endin
/* gen08.orc */
/* gen08.sco */
; Table #1: a curve with a smooth hump (using GEN08).
f 1 0 65 8 0 16 0 16 1 16 0 16 0
; Table #2, a sine wave.
f 2 0 16384 10 1
; Play Instrument #1 for two seconds.
i 1 0 2
e
/* gen08.sco */