Designing Sound in SuperCollider/Sirens

From Wikibooks, open books for an open world
Jump to navigation Jump to search

28: US-style police siren[edit | edit source]

We'll use the internal server to make sure we can use the oscilloscope etc.:

Server.default = s = Server.internal;

Fig 28.6: imitation of capacitor charge/discharge[edit | edit source]

In SuperCollider we can provide an almost-direct physical model: the LFPulse represents a "raw" on/off signal before smoothing by capacitors, and the "lagud" provides exponential smoothing, with the handy feature of allowing different time-periods for the "on" and "off" convergence. This one-line example will plot the curve for you:

{, 0.99, 0.4).lagud(0.3, 0.7)}.plot(2)

The siren[edit | edit source]

Now let's use this technique both for the pitch curve, and for waveform synthesis.

SynthDef(\dsaf_horn1, { |rate=0.1|
	var freq =, 0.99, 0.4).lagud(0.4 / rate, 0.6 / rate) * 800 + 300;
	var son  =, 0.99, 0.2).lagud(0.4 / freq, 0.6 / freq) * 2 - 1;
	// This filtering is a simple approximation of the plastic horn acoustics:
	son =, 1500, 1/4) * 4;
	// delay and reverb, to simulate the environment in which we hear the siren
	son = son +, 0.1, 0.1, 0.3);
	son = son +;, * 0.4));

x = Synth(\dsaf_horn1);


// Choose a rate
x.set(\rate, 3);
x.set(\rate, 0.1);

Exercise: instead of using the lagged-pulse implementation of the waveform, do as the book says and try using a simple triangle oscillator (LFTri) - this loses the physical-modelling "realism" of the authentic circuit but will be more efficient, and reasonably similar. How much of an effect on the tone quality do you get?