## Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Representing Data with Images and Sound: Bringing Data to Life. Join the course to learn more.
3.3

## Raspberry Pi Foundation

Skip to 0 minutes and 3 seconds So 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 seconds And 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 seconds So 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 seconds which 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 seconds A 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 seconds As 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 seconds 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 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:

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

## 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.

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.

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.

Whistling

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

Speech

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

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?