4.0 send/receive, send~/receive~, throw~/catch~
4.1 Adding Signals: Constructive and Destructive interference
Soon we realize that we might want to have several sound files going to the same [dac~] (note that from now on, we’ll use the [] to mean object; this is a common expression between pd programmers; then [+] means a “+” object.). Everything that we send to the [dac~] is in fact added together before being sent to your audio output, so let’s evaluate what is really happening when we add two audio signals. As in previous cases, we’ll use sine waves, because they are simple enough to show problems clearly.
When we add signals with a [+~], we are adding the value of each signal for every sample in the sample rate. Adding signals is what we commonly call “mixing” audio. As we know well now, the output range of an osc~ is -1 to 1, so the output range of the addition of two sine waves of the same frequency will depend on only one factor: their relative phases.
As seen in the graphs on the right, adding two signals with exactly the same frequency (220Hz in this case) can cause very unexpected results.
In the case of b), the two sine waves have exactly opposite phases. This means that when signal1 has a value of 1, signal2 has a value of -1, and viceversa. As these signals mirror each other, adding them cancels their values and the result is silence. This is called “destructive interference”.
In the case of a), the two sine waves have exactly the same phase, so when one of them has a value of one, the other does too. As a consequence, the addition of these two signals will lead to a value of two and the range of the added signal will be -2 to 2. This is called constructive interference.
In real life situations, two signals having exactly the same frequency and the same or opposite phases is unusual. You can think about some concert situations, where speakers create nodes where sounds reinforce or cancel each other, or you can think about noise cancellation headphones as an application of phase cancellation.
In any case, we’ll generally not worry about controlling phase and our “mixing” process will basically consist of adding two signals regardless of their content. If you decide to add any two signals with a range of -1 to 1, you will generally obtain a signal with a range of -2 to 2. A combination of operating system and audio hardware will determine how your computer will react to sound that is beyond the -1 to 1 audio range. The expected result is for you to hear distortion as your computer clips everything above 1 and below -1.
To avoid distortion, you need to control the amplitude and bring it back to the digital audio range: -1 to 1. So here is another golden rule: If you add n signals, always divide the addition by n.
3.2 Beating
When two sounds with frequencies close to each other are mixed together, you hear a phenomenon commonly known as beating. Because the frequencies of these sounds are so close to each other, they oscillate between moments of constructive and destructive interference such that they are audible and inaudible at a frequency of precisely the frequency difference between them. Thus, if we hear two sine waves, such as those shown in the patch at the right, one with a frequency of 330Hz and another one with 331Hz, the resulting sound will be a 330Hz sound beating at a frequency of 1 Hz.
3.3 Fourier or Harmonic Series
Let’s now move to a special kind of series of frequencies: the harmonic series.
The harmonic series refers to the integer multiples of a frequency. For example, if this frequency is 110Hz, this is considered the fundamental frequency or first harmonic. Each integer multiplication of the first harmonic is successively the second, third and nth harmonic. The term partial is also often used. Try to listen to this series by multiplying the output of a counter times a fundamental frequency.
As you can listen, the resulting sounds seem quite familiar.
Frequency in Hz | 110 | 220 | 330 | 440 | 550 | 660 | 770 | 880 |
Approximate pitch | A2 | A3 | E4 | A4 | C#5 | E5 | G5 | A5 |
Ratio | 2:1 | 3:2 | 4:3 | 5:4 | 6:5 | 7:6 |
In the resulting series of harmonics, we can recognize some intervals that are familiar such as octaves and fifths and also some that are familiar although perhaps might feel a bit detuned such as a major third and minor seventh. Compare them by playing them on a keyboard if you have one available. This is because these are not the tempered intervals we are used to listening to, but instead are determined by just intonation.
3.4 Adding harmonics together
As you might guess, adding harmonics is a special kind of signal addition in computer music. The reason this is a special operation is because it is possible to describe any periodic sound in terms of an addition of sine waves called the fourier series. In fact, the sounds of many instruments based on strings and tubes can be modeled by adding together a series of harmonics to create a rudimentary timbre. This process is called additive synthesis.
If you create a series of sine waves with frequencies that are multiples of a specific fundamental frequency and control their relative amplitudes, you can experiment with this theory. The patch below is provided in the examples for this session. With a fundamental of 110Hz (and then with others), try various combinations of relative amplitudes to hear how timbres change.