October 18, 2019

How to change the default synth in SuperCollider

The default synth sound in SuperCollider is a cheesy old piano sound. If you have ever tried the event pattern examples in the documentation of SuperCollider or been in the process of testing some pattern specifics of your own, you will have heard this extremely unconvincing synthesizer:

A nice alternative: A triangle wave synth with a low pass filter

Imagine a utopian world where the default cheese-piano-synth has been replaced by a nicer, kind of gameboy like synth. Well that world is here and now.

Overwriting the default is actually easy. All you have to do is write a new SynthDef called \default. Evaluate this piece of code:

// A simple triangle wave synth in stereo 
(
SynthDef.new(\default, {
arg dur, attack=0.01, release=1.0,
t_gate=1, out, freq=442, cutoff=5500,
rq=1, pan=0.0, amp=0.5;

var env = EnvGen.kr(
	Env.perc(attack, release), 
	t_gate, 
	timeScale: dur, 
	doneAction: 2
);
var sig = DPW3Tri.ar(freq: freq, mul: env);
sig = RLPF.ar(sig, cutoff.clip(20.0, 20000.0), rq.clip(0.0,1.0));
sig = Pan2.ar(sig, pan);
Out.ar(out, sig * amp);
}).add;
)

Try this new default synth out by playing the default event again:

().play;

Isn’t that much better?

Now, let us try it with patterns:

Make this the default synth permanently

To make this change permanent we need to edit the startup file for SuperCollider. This is a regular SuperCollider file that is evaluated on startup. It is a good place to keep settings and defaults. Here is how to access it:

  1. Open the SuperCollider IDE

  2. In the top menu, click “File”

  3. In the drop down click “Open startup file”

Now, if we just paste the code from above here, it will still get overwritten by the default synth when booting the server. To get around this, we need to add our synth after the server has booted. We do this by wrapping our SynthDef in a server function called doWhenBooted (s.doWhenBooted{/* paste code here*/}):

Here is what the default synth should now sound like (with a bit of reverb of course)

https://www.madskjeldgaard.dk/wp-content/uploads/2019/10/new-default-synth.mp4

#supercollider #tutorial