GEN14
Prev | Score Statements and GEN Routines | Next

## GEN14

GEN14 — Stores a polynomial whose coefficients derive from Chebyshevs of the second kind.

## Description

Uses Chebyshev coefficients to generate stored polynomial functions which, under waveshaping, can be used to split a sinusoid into harmonic partials having a pre-definable spectrum.

## Syntax

    f # time size 14 xint xamp h0 h1 h2 ...

## Initialization

size -- number of points in the table. Must be a power of 2 or a power-of-2 plus 1 (see f statement). The normal value is power-of-2 plus 1.

xint -- provides the left and right values [-xint, +xint] of the x interval over which the polynomial is to be drawn. These subroutines both call GEN03 to draw their functions; the p5 value here is therefore expanded to a negative-positive p5, p6 pair before GEN03 is actually called. The normal value is 1.

xamp -- amplitude scaling factor of the sinusoid input that is expected to produce the following spectrum.

h0, h1, h2, etc. -- relative strength of partials 0 (DC), 1 (fundamental), 2 ... that will result when a sinusoid of amplitude

xamp * int(size/2)/xint

is waveshaped using this function table. These values thus describe a frequency spectrum associated with a particular factor xamp of the input signal.

| Note
GEN13 is the function generator normally employed in standard waveshaping. It stores a polynomial whose coefficients derive from the Chebyshev polynomials of the first kind, so that a driving sinusoid of strength xamp will exhibit the specified spectrum at output. Note that the evolution of this spectrum is generally not linear with varying xamp. However, it is bandlimited (the only partials to appear will be those specified at generation time); and the partials will tend to occur and to develop in ascending order (the lower partials dominating at low xamp, and the spectral richness increasing for higher values of xamp). A negative hn value implies a 180 degree phase shift of that partial; the requested full-amplitude spectrum will not be affected by this shift, although the evolution of several of its component partials may be. The pattern +,+,-,-,+,+,... for h0,h1,h2... will minimize the normalization problem for low xamp values (see above), but does not necessarily provide the smoothest pattern of evolution. GEN14 stores a polynomial whose coefficients derive from Chebyshevs of the second kind.

## Examples

Here is an example of the GEN14 generator. It uses the file gen14.csd.

Example 1208. Example of the GEN14 generator.

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
    -odac  ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o gen14.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1
    ;after the example from The Csound Book, page 83

    instr 1	;compare results from GEN13 & GEN14

    iwshpfn	= p6
    inrmfn	= p7
    aswp	linseg	0.01, p3*.5, .49, p3*.5, 0.01		;index sweep function
    aindex	poscil	aswp, p5, 2				;sound to waveshape
    atable	tablei	aindex, iwshpfn, 1, .5			;waveshape index
    anrm	tablei	aswp*2, inrmfn, 1			;normalization
    aenv	linen	p4, .01, p3, .02			;amplitude envelope
    asig	= (atable*anrm)*aenv				;normalize and impose envelope
    asig    dcblock2 asig					;get rid of DC
    	outs    asig, asig

    endin
    </CsInstruments>
    <CsScore>

    f 2 0 8192 10 1			;sine wave

    f 28  0   4097 13  1 1 1 0 .8 0 .5 0 .2		;waveshaping function: GEN13 - odd harmonics
    f 280 0   2049 4   28 1				;normalization function for f28
    f 29  0   4097 14  1 1 1 0 .8 0 .5 0 .2		;waveshaping function: GEN14 - same harmonics
    f 290 0   2049 4   29 1				;normalization function for f29

    f 30  0   4097 13  1 1 0 1 0 .6 0 .4 0 .1	;waveshaping function: GEN13 - even harmonics
    f 301 0   2049 4   30 1				;normalization function for f30
    f 31  0   4097 14  1 1 0 1 0 .6 0 .4 0 .1	;waveshaping function: GEN13 - even harmonics
    f 310 0   2049 4   31 1				;normalization function for 31
    s
    i1 0   3   .7   440 28  280
    i1 4   .   .7    .  29  290
    i1 8   .   .7    .  30  301
    i1 12  3   .7    .  31  310

    e
    </CsScore>
    </CsoundSynthesizer>

These are the diagrams of the waveforms of the GEN14 routines, as used in the example:

f28 0 4097 13 1 1 1 0 .8 0 .5 0 .2 - waveshaping function: GEN13, odd harmonics

f29 0 4097 14 1 1 1 0 .8 0 .5 0 .2 - waveshaping function: GEN14, the same odd harmonics

f30 0 4097 13 1 1 0 1 0 .6 0 .4 0 .1 - waveshaping function: GEN13, even harmonics

f31 0 4097 14 1 1 0 1 0 .6 0 .4 0 .1 - waveshaping function: GEN14, the same even harmonics

## See Also

GEN03, GEN13, and GEN15.

Information about the Chebyshev polynomials on Wikipedia: http://en.wikipedia.org/wiki/Chebyshev_polynomials

Prev | Up | Next
GEN13 | Home | GEN15