The following example implements simple additive synthesis in SuperCollider, suited as a starting point for more elaborate designs. Arrays can be helpful for using single UGens multiple times, which is the very idea of additive synthesis. The multichannel expansion allows the use of arrays as arguments for UGens, resulting in an array of objects with the initialization parameters given in the arrays. The following example will create five oscillators, sending their outputs to the buses 0...4:
The single partials can be easily summed by wrapping them inside a Mix.ar() UGen. They are now all sent to the first output bus:
For more partials and dynamic sizes, it makes sense to use the fill() method of the array class:
Combine the example with a mouse control, allowing to change the timbre and the pitch.
Adjust the partial weight formula to generate basic waveforms (square, sawtooth, triangle).