Generate composite waveforms made up of weighted sums of simple sinusoids.
The specification of each contributing partial requires 3 p-fields using GEN09.
Syntax
f#timesize9pnastraphsapnbstrbphsb...
Initialization
size -- number of points in the table. Must be a power of 2 or power-of-2 plus 1 (see f statement).
pna, pnb, etc. -- partial no. (relative to a fundamental that would occupy size locations per cycle) of sinusoid a, sinusoid b, etc. Must be positive, but need not be a whole number, i.e., non-harmonic partials are permitted. Partials may be in any order.
stra, strb, etc. -- strength of partials pna, pnb, etc. These are relative strengths, since the composite waveform may be rescaled later. Negative values are permitted and imply a 180 degree phase shift.
phsa, phsb, etc. -- initial phase of partials pna, pnb, etc., expressed in degrees (0-360).
Note
These subroutines generate stored functions as sums of sinusoids of different frequencies. The two major restrictions on GEN10 that the partials be harmonic and in phase do not apply to GEN09 or GEN19.
In each case the composite wave, once drawn, is then rescaled to unity if p4 was positive. A negative p4 will cause rescaling to be skipped.
Examples
Here is an example of the GEN09 routine. It uses the files gen09.csd.
<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 gen09.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1gi1ftgen1,0,2^10,9,1,3,0,3,1,0,9,0.333,180;an approximation of a square wavegi2ftgen2,0,2^10,9,1,3,180,3,1,0,9,0.333,0;same values as gi1, except some phase valuesgi3ftgen3,0,2^10,9,1,.4,0,2.2,.5,0,3.8,1,0;inharmonic, but does not sound well --> wave does not end at same point as where it begins --> artefactsgi4ftgen4,0,2^10,9,10,.4,0,22,.5,0,38,1,0;the same proportions, but value of partial number is multiplied 10 times -->the sound is much clearer,;because the sudden "jump" like the one in gi3 will pop up only once in 10 repetitionsinstr1kamp=.6kcps=220ifn=p4asigposcilkamp,kcps*p5,ifnoutsasig,asigendin</CsInstruments><CsScore>i10211;subtle difference between table 1 and 2i13221i17231;big difference between table 3 and 4i11024.1;p5 has to compensate for the 10 repetitions of gi4 as opposed to gi3 to get the same pitche</CsScore></CsoundSynthesizer>
These are the diagrams of the waveforms of the GEN09 routines, as used in the example:
gi1 ftgen 1,0,2^10,9, 1,3,0, 3,1,0, 9,0.333,180 - approximation of a square wavegi2 ftgen 2,0,2^10,9, 1,3,180, 3,1,0, 9,0.333,0 - same values as gi1, except phase valuegi3 ftgen 3,0,2^10,9, 1,2,0, 3,2,0, 9,0.333,180 - inharmonic partials, but with distortion due to the sudden jump in ending and beginning of the wavegi4 ftgen 4,0,2^10,9, 1,2,180, 3,2,0, 9,0.333,0 - same ratio as gi3, except with less artefacts