Thursday, February 9, 2012

Randomness and Probability in Electronic Music

The heart of any random circuit is a noise generator.  In audio, a white noise generator consists of all audible frequencies at once, where a pink, brown, blue, red, etc noise (white and pink are the most common), is a noise limited to certain frequencies.  Most of these correspond to the electromagnetic spectrum and get their names from colors of light waves.  White light, for instance, includes all color frequencies at once. These signals are extremely random and chaotic in nature and are never predictable.

One circuit that is often used to capture randomness, is a sample-and-hold circuit or simply S/H.  For this essay, I am limiting my topic to synthesis and modular synthesis and will not venture into digital audio, which also uses a similar theory of sampling.  In synthesis, at least ninety percent of all S/H circuits are used with noise as its main input for sampling.  This circuit needs a clock or trigger and will sample whatever the input is and hold it there until the next clock pulse.  If a noise generator is used as the input, then the output is a random signal pattern that can control other synthesizer modules.  A classic example of this would be the sound in R2D2 from the Star Wars series, though there is definitely more to R2 than a simple S/H circuit, but you get the picture.

So S/H circuits can be used with other sources as well.  In the figure that follows, I show the clock or pulse waveform on the bottom in black with a saw input on the top in black.  To illustrate each pulse, I use a blue line.  The output of this S/H circuit would be the red signal.  Notice that the input here is not noise, but the output pattern can still seem somewhat random.  We call these types of signals quasi-random signals because they can seem random, but are repeating patterns as long as the input and the clock remain at stable frequencies - this would be because of common multiple integers of the input and clock frequencies... (On a quick side-note, quasi random can also refer to signals based on number patterns where the repetition is so far apart that they seem random).
This same S/H circuit can be used as a probability generator.  If the input is also a pulse wave (like the clock, but a different frequency), then the output of the S/H can either be high or low and nothing inbetween.  The following figure shows an example of the input also being a pulse wave.
When using an S/H circuit in this way, it is preferable to have the input frequency greater than the clock frequency because this allows more variation in the output from clock pulse to clock pulse.  What is interesting about using an S/H like this is that the duty cycle of the input becomes the probability of getting a high signal on the output.  In other words, if the top black signal is roughly a 50% duty cycle, or square wave, then the red output has a 50% probability of being high as opposed to low.  The next figure shows an input pulse with a 25% duty cycle - the output would have a probability of being 25% high or 75% low with every clock cycle.
To make this pattern a little more unpredicable, one could change the frequency of the input with an LFO or equivalent while keeping the pulse width at the same duty cycle - the output would still have the same probability and you would avoid quasi-randomness, or be less likely to have any repeating patterns due to interference from common multiple integers of the input and clock frequencies.

I know this is probably obvious, but you can also change the pulse width of the input signal and therefore change the probability. Since most synthesizer oscillators have pulse outputs with a pulse width control (or PWM - pulse width modulation), this is very easy to do.  You can control PWM with an envelope generator and have a different probability at the beginning of the sound than at the end of the sound.

There can be an infinite number of useful applications for this.  I especially like to use a keyboard trigger as the clock source so every time I hit a note, there is a probability for multiple things to happen.  Some examples could be:

 - the probability of a vibrato rate speeding up as you play a note
 - the probability of a drum pattern or sequence changing during a phrase or bar
 - the probability of switching between two separate sounds or voices
 - the probability of a sound also being sent through a delay or reverb


No comments:

Post a Comment