Additive synthesis with a GEN function vs. multilayer sine tones.
In the example A the oscillator uses the default audio waveform (a sine tone). There are 3 harmonically related frequencies: 440 Hz, 1320 Hz (3rd harmonic) and 2200 (5th harmonic). All the instances have the same entry delay.
This method allows for the maximum freedom, since all kinds of frequencies can be specified. Moreover, the timing characteristics (entry delay and duration), as well as the amplitude envelope of each frequency can be individually specified (see also below, Limits of the GEN functions as waveform).
However, this requires more data and is computationally less efficient than the method used in the example B.
The Example B uses as f1 (the audio waveform) the GEN10 function, which generates composite waveforms made up of weighted sums of simple harmonically related sinusoids. The relative amplitudes of the partials numbers 1, 2, 3, etc. are specified starting from p5 (5th field of the list, the field after the number 10) as numbers between 0 and 1 (see the Csound documentation for further information).
Here, the following values are used:
1st harmonic with amplitude 1
2nd harmonic with amplitude 0
3rd harmonic with amplitude 1
4th harmonic with amplitude 0
5th harmonic with amplitude 1
This method is very efficient, but it is really useful only the same steady waveform is requested.
Render and play the result of examples A and B. The audio files are the same.
When using a GEN function as an audio table (as in the example B above), only one amplitude envelope for all the components can be specified, since all the harmonic components are already inside the waveform.
If different amplitude envelopes for each components are needed follow the example below. The same strategy can be applied to give different entry delays or durations to the individual components.