polynomial — Efficiently evaluates a polynomial of arbitrary order.
The polynomial opcode calculates a polynomial with a single a-rate input variable. The polynomial is a sum of any number of terms in the form kn*x^n where kn is the nth coefficient of the expression. These coefficients are k-rate values.
ain -- the input signal used as the independent variable of the polynomial ("x").
aout -- the output signal ("y").
k0, k1, k2, ... -- the coefficients for each term of the polynomial.
If we consider the input parameter ain to be "x" and the output aout to be "y", then the polynomial opcode calculates the following equation:
y = k0 + k1*x + k2*x^2 + k3*x^3 + ...
Here is an example of the polynomial opcode. It uses the file polynomial.csd.
Example 331. Example of the polynomial opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> ; no sound output -n </CsOptions> <CsInstruments> sr = 10 ; audio rate is not important kr = 10 ; execute the statements in instr 1 ten times per second instr 1 ; ax will vary from 1 to 10 ax init 1 ; ay = ax^3 + 2ax^2 + 3ax + 4 ay polynomial ax, 4, 3, 2, 1 ; convert our a-rate signals to k-rate values so that we can print ky downsamp ay kx downsamp ax printf "%d: %d\n", kx, kx, ky ax = ax + 1 endin </CsInstruments> <CsScore> i1 0 1 e </CsScore> </CsoundSynthesizer>