By adding together sinusoids we can begin to create interesting synthethic timbres. Well, more interesting than plain sine waves. I’ve included examples of how to do this in PD and SuperCollider. I attempted to do this in both languages to get a better feel of the differences and similarities between them.

PD feels sluggish by comparison, manually connecting lots of [osc~] objects can get tedious quickly. That said, @poperbu, is going to send me some patches that show how to connect things dynamically in PD. I’m looking forward to giving that a try.

SuperCollider, on the other hand, is starting to get really exciting. There are some Ruby-like control structures in there that I’m really interested in exploring further.

Pure Data:

PD Additive Synthesis

Download

SuperCollider:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// =====================================================================
// additive synthesis:
// building richer sounds from sinusoids
// =====================================================================

// Declare variables
var fund, synth, freq, amp;

// Fundamental frequency
n = 440;

// Create an array of overtone frequencies
freq = Array.new(10);
f = (1..10).do {arg i; var val = (i*n); freq.add(val) };

// Create an array of 10 random floats
a = { arg num = 10;
  var rand_nums = Array.rand(num, 0.0, 1.0);
  rand_nums;
};

// Set amp to an array of amplitude values
amp = a.value;

// Make some sound
{Mix(SinOsc.ar(freq,1,amp))*0.1}.play

EDIT: Another, more elgant way:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(
{
  var n = 10;

  var wave = Mix.fill(10,{|i|

      var mult= 1.0.rand;

      SinOsc.ar(440*(i+1))*mult

    });

  Pan2.ar(wave/n,0.0);

}.play;
)

EDIT: Another, even slicker, way!

1
2
3
4
5
6
7
8
9
(
var n = 10;
var fund = 440;

var arr = Array.rand(n, 0.0, 1.0);
var freq = fund*(1..n);

{Mix(SinOsc.ar(freq,0,arr))*0.1}.play;
)