Designing Sound - Procedural Audio for Games and Film.

Code examples for “Designing Sound” textbook

Practical 20: Clocks

Pure Data

Clocks - complete ticking clock model

#N canvas 119 450 296 301 10;
#X obj 69 76 select 0 1 2 3 4 5 6 7;
#X obj 69 11 metro 125;
#X obj 111 274 dac~;
#X obj 69 -9 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 69 33 f;
#X obj 100 33 + 1;
#X obj 69 54 mod 8;
#X obj 111 247 *~ 1;
#X obj 214 178 loadbang;
#X obj 220 124 escapement;
#X obj 163 14 noise~;
#X obj 163 38 hip~ 200;
#X obj 69 125 clocktick;
#X obj 139 124 clocktick2;
#X msg 214 197 0.09;
#X obj -3 125 clockhand;
#X obj 111 192 *~ 0.3;
#X obj 69 148 *~ 0.1;
#X obj 139 147 *~ 0.1;
#X obj 220 147 *~ 0.06;
#X obj -3 148 *~ 0.3;
#X obj 121 219 bodyresonance~;
#X connect 0 0 9 0;
#X connect 0 0 12 0;
#X connect 0 0 15 0;
#X connect 0 1 9 0;
#X connect 0 2 9 0;
#X connect 0 2 13 0;
#X connect 0 3 9 0;
#X connect 0 4 9 0;
#X connect 0 4 12 0;
#X connect 0 5 9 0;
#X connect 0 6 9 0;
#X connect 0 6 13 0;
#X connect 0 7 9 0;
#X connect 1 0 4 0;
#X connect 3 0 1 0;
#X connect 4 0 5 0;
#X connect 4 0 6 0;
#X connect 5 0 4 1;
#X connect 6 0 0 0;
#X connect 7 0 2 0;
#X connect 7 0 2 1;
#X connect 8 0 14 0;
#X connect 9 0 19 0;
#X connect 10 0 11 0;
#X connect 11 0 12 1;
#X connect 11 0 13 1;
#X connect 11 0 15 1;
#X connect 12 0 17 0;
#X connect 13 0 18 0;
#X connect 14 0 21 1;
#X connect 15 0 20 0;
#X connect 16 0 7 0;
#X connect 16 0 21 0;
#X connect 17 0 16 0;
#X connect 18 0 16 0;
#X connect 19 0 16 0;
#X connect 20 0 16 0;
#X connect 21 0 7 0;

Download clock_all.pd.

Clocks - body resonance, clock housing

#N canvas 0 0 399 236 10;
#X obj 1 172 delwrite~ \$0-clockbodyl 100;
#X obj 1 67 delread~ \$0-clockbodyl 50;
#X obj 1 88 bp~ 1200 3;
#X obj 205 162 bp~ 1200 3;
#X obj 205 86 delread~ \$0-clockbodyw 50;
#X obj 205 217 delwrite~ \$0-clockbodyw 100;
#X obj 205 32 + 0.02;
#X obj 139 0 inlet;
#X obj 91 102 inlet~;
#X obj 52 218 outlet~;
#X obj 1 113 *~ 0.3;
#X obj 205 187 *~ 0.3;
#X obj 1 34 bodyscale;
#X obj 205 55 bodyscale;
#X connect 1 0 2 0;
#X connect 2 0 9 0;
#X connect 2 0 10 0;
#X connect 3 0 9 0;
#X connect 3 0 11 0;
#X connect 4 0 3 0;
#X connect 6 0 13 0;
#X connect 7 0 6 0;
#X connect 7 0 12 0;
#X connect 8 0 0 0;
#X connect 8 0 5 0;
#X connect 10 0 0 0;
#X connect 10 0 3 0;
#X connect 11 0 5 0;
#X connect 12 0 1 0;
#X connect 12 1 2 1;
#X connect 13 0 4 0;
#X connect 13 1 3 1;

Download bodyresonance~.pd.

Clocks - hand of the clock

#N canvas 0 0 450 300 10;
#X obj 213 53 inlet~ noise;
#X obj 0 104 outlet~;
#X obj 0 1 inlet trigger;
#X obj 0 82 mclick~ 300 120 3245 20 5356 10;
#X connect 0 0 3 1;
#X connect 2 0 3 0;
#X connect 3 0 1 0;

Download clockhand.pd.

Clocks - a tick sound

#N canvas 0 0 300 121 10;
#X obj 204 57 inlet~ noise;
#X obj -1 102 outlet~;
#X obj -1 22 bangburst 3;
#X obj -1 44 sel 1 2 3 4 5 6 7 8;
#X obj -1 1 inlet trigger;
#X obj -1 80 mclick 7543 30 3988 20 2765 10;
#X connect 0 0 5 1;
#X connect 2 0 3 0;
#X connect 3 0 5 0;
#X connect 3 1 5 0;
#X connect 3 3 5 0;
#X connect 3 5 5 0;
#X connect 3 7 5 0;
#X connect 4 0 2 0;
#X connect 5 0 1 0;

Download clocktick2.pd.

Clocks - another tick sound

#N canvas 0 0 300 121 10;
#X obj 205 51 inlet~ noise;
#X obj 0 102 outlet~;
#X obj 0 22 bangburst 3;
#X obj 0 44 sel 1 2 3 4 5 6 7 8;
#X obj 0 1 inlet trigger;
#X obj 0 80 mclick 6543 30 3245 20 1356 10;
#X connect 0 0 5 1;
#X connect 2 0 3 0;
#X connect 3 0 5 0;
#X connect 3 3 5 0;
#X connect 3 4 5 0;
#X connect 3 7 5 0;
#X connect 4 0 2 0;
#X connect 5 0 1 0;

Download clocktick.pd.

Clocks - escapement sound

#N canvas 0 0 186 186 10;
#X obj 4 123 *~;
#X obj 20 101 osc~ 10000;
#X obj 104 125 *~;
#X obj 46 161 outlet~;
#X obj 120 103 osc~ 8000;
#X obj 4 38 sel 1 2 3 4 5 6 7 8;
#X obj 4 -5 inlet trigger;
#X obj 4 16 bangburst 3;
#X obj 4 79 sqdec 10;
#X obj 104 80 sqdec 10;
#X connect 0 0 3 0;
#X connect 1 0 0 1;
#X connect 2 0 3 0;
#X connect 4 0 2 1;
#X connect 5 0 8 0;
#X connect 5 1 9 0;
#X connect 5 2 8 0;
#X connect 5 3 9 0;
#X connect 5 4 9 0;
#X connect 5 5 8 0;
#X connect 5 6 9 0;
#X connect 5 7 8 0;
#X connect 6 0 7 0;
#X connect 7 0 5 0;
#X connect 8 0 0 0;
#X connect 9 0 2 0;

Download escapement.pd.

Clocks - exponential decay envelope (needed abstraction)

#N canvas 0 0 122 152 10;
#X obj 0 64 vline~;
#X obj -1 131 outlet~ signal;
#X obj 0 -1 inlet trigger;
#X obj 0 20 f \$1;
#X msg 0 41 1 1 0 \, 0 \$1 1;
#X obj -1 108 *~;
#X connect 0 0 5 0;
#X connect 0 0 5 1;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 0 0;
#X connect 5 0 1 0;

Download expdec.pd.

Clocks - square decay envelope (needed abstraction)

#N canvas 0 0 110 140 10;
#X obj 0 64 vline~;
#X obj -1 117 outlet~ signal;
#X obj 0 -1 inlet trigger;
#X obj 0 20 f \$1;
#X msg 0 41 1 1 0 \, 0 \$1 1;
#X obj -1 94 *~;
#X connect 0 0 5 0;
#X connect 0 0 5 1;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 0 0;
#X connect 5 0 1 0;

Download sqdec.pd.

Clocks - metalic click gen (needed abstraction)

#N canvas 21 4 246 219 10;
#X obj 80 146 *~;
#X obj 161 143 *~;
#X obj -2 145 *~;
#X obj 96 73 inlet~ noise;
#X obj 58 -1 inlet trigger;
#X obj 58 22 t b b b;
#X obj 80 200 outlet~;
#X obj 80 178 *~ 3;
#X obj 13 110 bp~ \$1 30;
#X obj 95 108 bp~ \$3 30;
#X obj 177 107 bp~ \$5 30;
#X obj -2 48 sqdec \$2;
#X obj 80 48 sqdec \$4;
#X obj 161 48 sqdec \$6;
#X connect 0 0 7 0;
#X connect 1 0 7 0;
#X connect 2 0 7 0;
#X connect 3 0 8 0;
#X connect 3 0 9 0;
#X connect 3 0 10 0;
#X connect 4 0 5 0;
#X connect 5 0 11 0;
#X connect 5 1 12 0;
#X connect 5 2 13 0;
#X connect 7 0 6 0;
#X connect 8 0 2 1;
#X connect 9 0 0 1;
#X connect 10 0 1 1;
#X connect 11 0 2 0;
#X connect 12 0 0 0;
#X connect 13 0 1 0;

Download mclick.pd.

Clocks - bang sequence (needed abstraction)

#N canvas 152 306 149 135 10;
#X obj -3 -2 inlet;
#X obj 57 45 + 1;
#X msg -3 45 bang;
#X obj 57 21 moses 10;
#X msg 108 46 0;
#X obj 101 94 outlet;
#X obj 57 -2 float;
#X obj 57 72 t f b f;
#X obj 79 115 del \$1;
#X connect 0 0 2 0;
#X connect 1 0 7 0;
#X connect 2 0 6 0;
#X connect 3 0 1 0;
#X connect 3 1 4 0;
#X connect 4 0 6 1;
#X connect 6 0 3 0;
#X connect 7 0 6 1;
#X connect 7 1 8 0;
#X connect 7 2 5 0;
#X connect 8 0 2 0;

Download bangburst.pd.

Audio

Ticking clock sounds

In this sound example the ticking clock is heard breaking down to its components, until just the escapement is audible, then building back up again re-introducing each component.

Download clock.wav.