Skip to 0 minutes and 3 secondsSo that you can understand how computers can represent sound digitally, we're first going to learn about what sound actually is. Sound is all about vibration. To make a sound, something has to start a vibration, whether that's the string on a guitar, the larynx - the voice box of a person - or the speakers in your computer. Sound wave consists of vibrating particles. These knock into other particles causing them to vibrate, and so the sound can travel away from the source. You can hear sound because the vibrations in the air cause your ear drums to vibrate. This vibration is converted into signals which travel down a nerve to your brain.

Skip to 0 minutes and 43 secondsAnd similarly, microphones can detect these vibrations and convert them into electrical signals. When you think about a sound wave, you may think of something that looks a little bit like a water wave like this, but this a really inaccurate representation of the sound wave. The particles moving a part of a sound wave vibrate back and forth in the direction that the sound wave is travelling, creating areas where the particles are more bunched up, high pressure, and areas where the particles are more spread out, low pressure. Now, this type of wave is called a longitudinal wave. However, as you can see, it's not very easy to represent this.

Skip to 1 minute and 22 secondsSo we use the waveform you've seen before, with the top of the wave representing high pressure compression and the bottom of the wave representing a low pressure area. In this case, the x-axis of the graph is space. But more often, you'll see it representing time. So the graph represents a sound wave passing a particular point. From a graph showing how the wave changes over time, we can extract two important features

Skip to 1 minute and 48 secondswhich will affect how we hear each sound: the amplitude and the frequency. The amplitude of the wave is the height of the wave on the graph from the middle to its highest point. Now, louder signs will produce waves with a higher amplitude. The sound wave created by an actor projecting their lines across a theatre will have a higher amplitude than somebody in the audience whispering to their friend. The time between two peaks on one of these graphs is the time period of the sound. And to get the frequency of the sound, you must calculate one divided by this time period. The frequency of sound tells us about the pitch of the sound that you hear.

Skip to 2 minutes and 32 secondsA sound wave with a higher frequency will have a higher pitch. The shrill sound of a whistle will look a lot more bunched up on one of these graphs than the deep sound of a double bass. Of course, most sound waves are not pure sounds like this one. Most sounds are made up of combination of lots of these waves. Let's look at the sound waves corresponding to whistling, speech, and music. [WHISTLING]

Skip to 3 minutes and 3 secondsAs you can see, whistling gives a nice, pure sound, whereas the sound wave from speech is a combination of multiple waves of different frequencies and amplitudes into a more complicated wave. Music is similar, with most instruments not producing one pure note.

Skip to 3 minutes and 30 secondsWith free software like Audacity and a microphone connected to your computer, maybe as part of a webcam, you can record different sounds and look at the shape of the sound wave. Give it a try with things that you have at home. Can you tell anything about the sounds by looking at the waves you see on the screen? Share your observations in the comments. In the next steps, we'll look at how the computer measures and stores these sound waves as ones and zeros, allowing you to play them back later.

The Physics of Sound

So you can understand how computers digitally represent sound, you first need to know a little about what sound is!

Vibrations and waves

Sound is all about vibration. To make a sound, something has to vibrate — whether that’s the string of a guitar, the larynx (voice box) of a person, or the loudspeakers of your radio. Sound waves consist of vibrating particles, which knock into other particles, causing those particles to vibrate and knock into more particles, and so on and so forth; this is how sound waves travel away from their source. We hear sounds because the vibrations in the air cause our ear drums to vibrate, and these vibrations are converted into nerve signals that are sent to our brains. Similarly, microphones detect vibrations in the air and convert them into electrical signals.

When you imagine a sound wave, you might think of something that looks a bit like a water wave:

A cosine wave

However, this isn’t really an accurate representation of a sound wave. The particles that vibrate as part of a sound wave move back and forth along the axis along which the sound wave is travelling. This movement creates areas where particles are more bunched up (areas of high pressure, or compressions) and areas where particles are more spread out (areas of low pressure, or rarefactions). This type of wave is called a longitudinal wave.

It’s not easy to visually represent a longitudinal wave; there are two types of graphs to do it:

  1. A graph like the one below, where the x-axis indicates space, with the top of the wave representing areas of compression, and the bottom of the wave representing areas of rarefaction
  2. A graph where the x-axis indicates time, so the graph represents a sound wave passing a particular point in space; this is the more commonly used type of graph

At the top, a set of dots representing particles. The concentration of these changes periodically from left to right. Below this is a graph with the x-axis labelled Distance and a y-axis labelled Pressure. The graph shows a sinusoidal wave with peaks aligned below the regions with the highest concentration of dots, and troughs aligned below the regions with the lowest concentration of dots.

Amplitude and frequency

From a graph showing how a sound wave changes over time, you can extract two important features that affect what a sound sounds like to us: the amplitude and the frequency. The amplitude is the height of the wave on the graph from the middle to its highest point. The amplitude determines a sound’s volume — sound waves of higher amplitude are louder. For example, the sound wave created by an theatre actor projecting their lines to the audience has a higher amplitude than the sound wave produced by someone in the audience whispering to their friend.

A graph with the x-axis labelled as Time. There is a sinusoidal wave on the graph, with a horizontal dashed line showing its midpoint. A double-headed arrow from this dashed line vertically up to the peak of the wave is labelled "Amplitude". Another double-headed arrow from this peak horizontally to another peak is labelled "Time Period".

The time that passes between two wave peaks is the time period of the sound wave. To calculate the frequency, you divide 1 by this time period. The frequency of the sound wave tells you about the sound’s pitch: a sound with a higher frequency has a higher pitch. For example, the graph of the shrill sound of a whistle will look a lot more bunched up than the graph of the deep sound of a double bass. The sound represented by the green line in the graph below would have a higher pitch than the sound represented by the purple line.

A graph with the x-axis labelled as Time. There are two sinusoidal waves on the graph - a purple one and a green one. The green one has more repeats on the graph than the purple one (it is more squashed horizontally).

Of course, most sound waves are not pure like the ones shown above, because most sounds are made up of combinations of lots of waves. Let’s look at the sound waves corresponding to whistling, speech, and music.

sound wave of whistling Whistling

As you can see, whistling produces a smooth, simple sound wave.

sound wave of speech Speech

By contrast, speech is a combination of multiple sound waves of different frequencies and amplitudes that results in a more complicated wave.

sound wave of music Music

Music is similar to speech, and most instruments don’t produce just one pure note.

Activity: record and investigate sound waves

With free software like Audacity and a microphone connected to your computer (maybe as part of a webcam), you can record different sounds and look at the shape of the sound wave.

  • Give it a try — record sounds and noises produced by items in your home.
  • Can you tell anything about the sounds by looking at the waves on screen?

Share your observations in the comments!

In the next steps, we’ll look at how computers measure and store sound waves as ones and zeroes, so that they can play them back later.

Share this video:

This video is from the free online course:

Representing Data with Images and Sound: Bringing Data to Life

Raspberry Pi Foundation