Subsections

random sine wave with controls

Figure 4 summary

Slider Controls

A slider can be placed anywhere you want to vary something by connecting directly to it. In this case we have slider outlet going to metronome period inlet. You should set slider properties such as colour, range and size by right clicking and using the [properties] dialog. Range is most often important. Here the slider goes between 10 and a few hundred, so that we never tell the metronome to have a period of zero (which makes a very strange noise sometimes). Another useful property to set is [init], which makes the slider remember the last value set when you save and reload a patch.

Scaling amplitude

Now we vary the amplitude of the oscillator so some notes to play more more quietly and some more loudly. Thinking about appropriate ranges, to scale a signal we want to multiply it by a number between 0 and 1. At zero we will have complete silence, because anything multiplied by 0 is 0, and at 1 the signal will be at its normal strength. But [random] only gives us integers. To get a normalised signal, 0 to 1, we divide the output of [random] by the same value as its range minus one. Using the value of 100 we get one hundred possible steps now mapped between 0 and 1, $ {0.01, 0.02, 0.03...0.99}$ which can be used to scale the audio. Notice that it doesn't matter which side of the (symmetrical) [*~] object we connect control signal or audio signal to.

Signal ordering with triggers

Sometimes it matters which way you connect objects because of the order you want things to happen. A trigger is like a splitter that can be used to keep program diagrams neat and logical. It's evaluation order goes right to left so in this case the random number affecting frequency is computed before the random number for amplitude. You will hear no difference if you swap the ordering on this simple patch, but in more complex Pd programs the ordering becomes important.
Figure 4: random-sine-controls
\includegraphics[angle=0, scale=1]{/home/zero/PRODUCTION/TEACHING/PD/Composition-000/images/D-random-sine-controls-play}
D-random-sine-controls-play.pd D-random-sine-controls-play.ogg
Andy Farnell
http://obiwannabe.co.uk/