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
Mix.ar() UGen. They are now all sent to the first
For more partials and dynamic sizes, it makes sense to use the
method of the array class:
Adjust the partial weight formula to generate basic waveforms (square, sawtooth, triangle). Monitor the signal in the scope to verify. Try different numbers of partials and compare the results.
Combine the example with a mouse control, allowing to change two parameters of the timbre or partial frequencies.