GEN03 — Generates a stored function table by evaluating a polynomial.
This subroutine generates a stored function table by evaluating a polynomial in x over a fixed interval and with specified coefficients.
size -- number of points in the table. Must be a power of 2 or a power-of-2 plus 1.
xval1, xval2 -- left and right values of the x interval over which the polynomial is defined (xval1 < xval2). These will produce the 1st stored value and the (power-of-2 plus l)th stored value respectively in the generated function table.
c0, c1, c2, ..., cn -- coefficients of the nth-order polynomial
C0 + C1x + C2x2 + . . . + Cnxn
Coefficients may be positive or negative real numbers; a zero denotes a missing term in the polynomial. The coefficient list begins in p7, providing a current upper limit of 144 terms.
Note | |
---|---|
|
Here is a simple example of the GEN03 routine. It uses the files gen03.csd. It fills a table with a 4th order polynomial function over the x-interval -1 to 1. The origin will be at the offset position 512. The function is post-normalized. Here is its diagram:
Example 553. A simple example of the GEN03 routine.
<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 gen03.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 kamp table kndx, ifn, ixmode ; Create a sine wave, use the Table #1 values to control ; the amplitude. a1 oscil kamp*30000, 440, 2 out a1 endin </CsInstruments> <CsScore> ; Table #1: a polynomial function (using GEN03). f 1 0 1025 3 -1 1 5 4 3 2 2 1 ; Table #2, a sine wave. f 2 0 16384 10 1 ; Play Instrument #1 for 2 seconds. i 1 0 2 e </CsScore> </CsoundSynthesizer>