# Designing Sound in SuperCollider/Additive synthesis

From Wikibooks, open books for an open world

## Fig 17.4: Additive synthesis[edit]

Additive synthesis using eqn 17.2, taken from Moorer.

First start the server, if you haven't already - this time making sure it's the server which lets use the oscilloscopes:

```
Server.default = s = GUI.stethoscope.defaultServer;
s.boot;
```

In the following we use ".sin" and ".cos" as mathematical operations, so we can stick closely to the original design - these are **much** less efficient than using SC's SinOsc oscillator, which is what most people would use for additive synthesis in SuperCollider.

In the original diagram, freq starts as 122, index as 0.42. Here we connect these parameters to the mouse - left/right for freq, up/down for harmonic decay.

The amplitude will vary with the decay coefficient, so practically, you'd want some kind of normalisation.

```
(
x = {
var freq = MouseX.kr(100, 1000, 1) / SampleRate.ir;
var distance = 3.00;
var index = MouseY.kr(0.42, 0.99);
var theta, beta, num, denom, son;
// Two phasors which will ramp from zero to 2pi
theta = Phasor.ar(0, freq, 0, 2pi);
beta = Phasor.ar(0, freq * distance, 0, 2pi);
num = sin(theta) - (index * sin(theta - beta));
denom = 1 + index.squared - (2 * index * cos(beta));
son = num / denom;
Out.ar(0, Pan2.ar(son * 0.3));
}.freqscope; // Use ".freqscope" or ".scope", both are illustrative.
)
```