GEN08 — Generate a piecewise cubic spline curve.
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 file gen08.csd. 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:
Example 557. A simple example of the GEN08 routine.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform ; Audio out Audio in -odac -iadc ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o gen08.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; 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 </CsInstruments> <CsScore> ; 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 </CsScore> </CsoundSynthesizer>