Three phones

In this set of exercises we are going to build 3 telephones. Each is very different and uses quite distinct principles. To do this we will look at 3 synthesis methods and 3 control structures. By creating the 'same sound' in 3 different ways we get to understand how the description of a sound leads to possible implementations. Each is synthesised efficiently, in such a way that a game designer could very easily incorporate the code as an object method for generating an actors sounds. Doing this we get to see how the interface design relates to the behaviour and control structures.

The first telephone is a 1980s style American phone, the kind heard in so many TV programmes. It has no realworld counterpart, in other words it is a completely artificial sound. Our only association that tells us it's a phone is empirical, the experience of having heard the sound as a telephone ring. That means we cannot work from first principles or physical deconstruction, instead we must take a knowledge based approach by learning how the circuit for such a telephone works. For this we will use AM synthesis to place sidebands at specific intervals, coupled with a control structure which is itself amplitude modulation.

The second example departs radically from the first. Here we will use brute force additive synthesis to approximate an old fashioned bell sound. Here we use imperative/generative knowledge, by understanding a method which can get us close to the sound we want. This is the kind of telephone heard in the 1930s and 1940s, a sound featured in many old films of the wartime and postwar era. At this point we expand on the concept of separating control from synthesis structures and explore how event messages in PureData differ from audio blocks. This allows us to decouple previously codependent parameters and obtain more versatile control through modularity.

The final example is a more advanced attempt to recreate a real telephone bell. In doing so we will look at the shortcomings and fudges we made in the first two attempts and look at how to refine a model, tweak its efficiency and generally improve its behaviour. For this we will use closed form cosine synthesis and stochastic control methods.

1980 called and they want their phone back.

Lets begin with a quick listen to the first example. audio .mp3

How did we construct this sound?- Oscillator basics

To begin with we establish a base or foundation. In many forms of constructive synthesis we start with a simple outline or approximation of a sound and then proceed to add in details. Sometimes we want to get the loudness or amplitude curves right first, other times we can start with getting the approximate frequency or tone correct. What better signal then to begin with than a simple sinewave as our foundation? This is so often the starting point for constructive synthesis the diagram below will become very familiar, eventually we will start to skip this stage in later exercises and take it for granted. However, at this stage consider the parameters in the diagram. We have only the frequency and phase to adjust. Let's begin by placing the centre of our foundation roughly in the middle of human hearing range at 1KHz. Let's also forget about phase. We leave the phase input unconnected or set it to 0 because in simple additive and AM synthesis as well as other occasions our ears don't actually hear or care about the phase of the signals in the sound. Knowing the phase is actually very important in determining how signals interact in synthesis, but for now we will ignore this part.

1 oscil in pd

At the center is an atom named [osc~]. This is a sinewave oscillator unit. It has two inputs, one to set the frequency and one to set the phase. These inputs are fed by a pair of messages. If you make this patch in PureData you will not hear anything to begin with, that's because it's default frequency is not specified and so it will run at zero Hz. A sound at 0Hz is no sound at all. So first you must send the message telling it what frequency to run at by clicking the first message. Because the output of the oscillator is connected directly to the digital to analog converter (the soundcard in your computer) it will be very loud, so beware. Normally we place an attenuator/volume block in the way to reduce the amplitude a bit. Something like [*~ 0.25] is commonly used to reduce the level to 1/4 or 25% of its maximum. If you don't hear anything make sure the audio engine is switched on in PureData, use the menu Media->AudioON or press CTRL+/ on your keyboard.

Basic additive methods

That sounds pretty boring doesn't it? But it is our starting point for building the next stage of the telephone. Look at the diagram below. We have added another oscillator. The atom which combines the two oscillator outputs is a [+~] unit, which simply adds the two audio signals together. Notice that this time instead of sending messages to the oscillators they have been entered with default parameters. This is common for many PureData atoms which may take either realtime control values through their inlets, or may adopt defaults specified when they are created. It means that this patch will produce a sound immediately. It does not mean that we are stuck with those frequency values though, any parameter changes that happen at the inlets will override the initial defaults. I chose a couple of random frequencies, 1234 and 789 just because they are quick to type in, but take a listen... It sounds a little familiar doesn't it? That's because telephones of the 1980s era used DTMF signals which were simply pairs of unique frequencies added to one another. By choosing the frequencies correctly the telephone exchange switch was able to distinguish clearly between dialled tones over a bad noisy line. The exchange demodulated the pairs using a circuit called a phase locked loop. Now, since these oscillators were being built into early electronic phones it's no suprise that the same chips were reused to create the ringing tone too, which is the cultural/commercial reason why 80s phones sound the way they did. We will come to that in a moment, but first let's explore the possibilities of just adding pairs of sine waves together.

2 oscils added in pd

As it goes we can create dialling tones very easily. Let's do just that and add a little spice to our telephone by giving it a keypad we can dial numbers on.

Here's a list of all the frequency pairs used in DTMF/CCITT dialling tones arranged in a table.

         1209   1336   1477   1633
       -------------------------------------------
697 | 1         2         3         A
770 | 4         5         5         B
852 | 7         8         9         C
941 | *         0         #         D

To get the tone for 9 we add an oscillator at 1477Hz to a tone at 852Hz. Our final sound therefore has two components one at each of the given frequencies. It's quite important that sine waves are used, remember a sine or cosine wave contains only its own frequency, it is pure. Adding pure sine waves together gives us very easy to understand spectrums, the result is merely each of the components we put in. This is straightforward additive synthesis. As long as we don't distort the signal in any way the two components will not interact with each other, to make a chemistry analogy they are rather like oil and water or unreactive solutes in a solution and we may later recover each of them unaltered from the mix using filtering or other techniques. This goes for any number of pure sinewave signals.

Using the table above we can now create the DTMF dialler. In fact this will actually work as a telephone dialler if you connected the soundcard to a voice-modem device or telephone. The keys on the keypad send bang messages to unique destinations, each destination fires a list message of two frequencies into the dialler patch. The [unpack f f] atom separates the list into two floats and each goes to one of the oscillators. Actually it doesn't matter which value goes to which oscillator because the addition function is symmetrical, 1234Hz + 789Hz = 789Hz + 1234Hz. Remember not all functions are like this, but multiplication and addition are two that definitely are. Download the patch here puredata file .pd or listen to the example here audio .mp3

ccitt dialer in pd

Modulation (AM)

Well, now we have a way to make the call, but no ringing sound to know when someone is calling. Let's move on to a new technique called "modulation". We have already seen the audio multiply atom [*~], but until now we have been multiplying only by fixed values, like 1 and 0 to control the loudness of a signal. What happens when instead of adding two sine waves together we multiply them? This is modulation. Modulation adds in new harmonics, which are different from the two frequencies we start with. The two original frequencies are still in the resulting signal but now we also get some extra ones. They aren't random new frequencies however, they are mathematically related to the source signals. How? Well, employing modulation usually adds in harmonics symmetrically about the base frequency, and in the case of simple multiplication or AM (amplitude modulation) they are the sum and difference of the sources. In other words if we perform a modulation which combines one component at 1200Hz and one at 200Hz then we will also get another signal at 1000Hz (1200 - 200) and another at 1400Hz (1200 + 200). Pure AM is the perfect case. In fact we will get exactly two new harmonics when modulating signal F by signal M, one at F + M and one at F - M. Compare the output of the diagram below by listening here audio .mp3 or downloading and running this PureData patch puredata file .pd

simple amp modulation

Our sound is beginning to take on a richer more bell-like tone, but it is still far from being a ringtone. The ringtone in the example is far richer, it has a complex spectrum containing quite a few frequencies. Before using modulation to just make a random bunch of new frequencies let's consider why we might choose a certain kind of spectrum. One way an electronic ringtone tries to emulate a real bell is by trying to reproduce the effect of a bell hammer. Early mechanical bells had a solenoid, a magnetic buzzer with an arm attached to a weight which struck the bell. The frequency of vibration was usually between about 8Hz and 20Hz. Modulating the tones at this frequency gives us a kind of warbling effect, not entirely unlike the sound of a real electromechanical bell. Also the DTMF tones are quite pleasant to listen to but they are designed to perform a technical function, on the other hand the ringtone is not a signal designed to be carried across a wire and unambiguously demodulated, rather it is a sound designed to arrest the attention of a human being. How does this happen and why are certain sounds better at grabbing our attention than others?

What noise annoys an oyster?

Certain pairs of harmonics are unpleasant to hear, they are not harmonious and so they irritate our senses in the same way that colours can clash and create a displeasing effect on the eye. One of the most arresting sounds the human brain is tuned to is the sound of a baby crying. In fact that particular sound has every pair of unpleasant and stressful harmonic pairings possible. These dissonant clashes of sound are called inharmonics. A pairing is more inharmonic when it has no integer relationship to its partner, no factor or common multiple. Prime numbers help us out here. If two frequencies are coprime then they are very inharmonic. Using only a few inharmonic frequencies we get a sound that grabs our attention. Of course the circuit designers of early phones probably didn't realise this, they merely experimented with getting the most attention grabbing sound using the smallest number of modulators to save on cost.

So how do we get a whole bunch of relatively inharmonic tones quite easily? Consider an interesting question, what happens if we multiply a sinewave by a complex spectrum? In other words what happens when we take the output of our AM tone source above containing 4 harmonics and multiply it by another sinewave? What we get is an even more complex spectrum. Each harmonic in the complex tone forms a sum and difference pair with the new signal. Lets say we started with 1000Hz and 300Hz to give us 1000Hz, 300Hz, 1300Hz, and 700Hz harmonics. Now lets multiply this by a new sine wave at 900Hz. For our troubles we get 1900Hz, 100Hz, 1200Hz, 600Hz, 2200Hz, 400Hz, 1600Hz and 200Hz in addition to our original 1000Hz, 300Hz, 1300Hz, 700Hz and 900Hz components. Wow! We've only used three oscillators and a couple of multiply blocks to get a pretty complex signal!

Now consider that a ringtone sound is broken into segments. By starting and stopping at regular intervals the sound is more likely to be heard because we tend to hear changes more prominently than constant sounds. While this is common sense you can find a reference to research that demonstrates this in Bigand and McAdams. In fact neural systems in general don't perceive steady unchanging values well at all, whether it be eyes, ears or touch and smell a change in some quality or quantity is actually what we perceive. Don't forget that although we talk of a "steady tone" any audio signal is in fact a changing quantity by definition. So, our next step then is to break the steady spectrum we have created into chunks, and again we use modulation. We modulate the tone with a square wave which causes it to switch on and off at a fairly slow rate.

To get a square wave we use a little trick called clipping. A [clip~] atom allows signals to pass through it unaltered so long as they lie within its two boundaries or threshold values. Once the signal exceeds a threshold, in either a negative or positive direction, it is clipped or locked at that maximum or minimum value. If we amplify a sine wave and then clip it asymmetrically we obtain a good approximation of a square wave useful for level control.

am based telephone tone

Phoney Mc Ring Ring

It's time to put all these parts together and build our example. You can have a go yourself or download and study the example here puredata file .pd

The start button sends a list representing the telephone number to a simple sequencer which then sends each digit to the dialler. Fortunately the line isn't engaged, and the ring tone commences right away. Of course it takes a while for the person at the other side to get up and move their fat ass over to the the phone and pick up.

                           _____________________________________
                          / Phoney say...                                     \
                         | "Even a monkey can understand      |
                         | amplitude modulation... are you       |
                         | stupider than a  monkey?"                |
  _________         \______________________________________/
 /  ______    \     /
(__)][__][(__)                 
   / ,      \  \  
  / (O)|(O) \  
  | ^\__/^   |
  |_________|

Links

Amplitude modulation http://en.wikipedia.org/wiki/Amplitude_modulation

In practice http://www.soundonsound.com/sos/mar00/articles/synthsecrets.htm

Modulation http://ccrma.stanford.edu/courses/220b/topics/modulation-synthesis/

Next next tutorial

Top tutorials list

Designing Sound Textbook