ComputingRevision.net

1.2.4d Sound

Audio is stored and processed as binary data. However, sound is an analogue waveform, so needs to be converted into binary. This process is called sampling.

Analogue and Digital Audio Graphs

Sound Sampling

To convert the analogue sound into binary data, the amplitude (height) of the wave is measured at regular intervals. The measurements are stored as binary numbers.

In the animation…

  • A reading is taken once per second.
  • The closest binary number is stored
  • Each binary number is 3-bits long, so we say it has a bit depth of 3.

Sampling frequency is measured in hertz (Hz).

  • 1 Hz is one sample per second
  • 1 kilohertz (kHz) is 1000 samples per second
  • 1 megahertz (mHz) is 1 million samples per second

Inaccuracies

We can see this is a very poor quality sample! The samples, shown by the purple dots, are not an accurate representation of the analogue sound wave.

Accuracy, and therefore the quality of the sample, can be improved by increasing the frequency of the sampling, or increasing the bit depth.

Animation

Increasing the Frequency of Sampling

One way to improve the quality of the sample is to take more samples per second.

In this animation, you can see the readings (again shown by the purple dots) are much closer to the analogue sound wave.

However, taking more samples per second means more data is stored and the file size will increase.

Despite increasing the frequency of the samples, it is still not an exact match to the analogue audio.

Animation

Increasing the Bit Depth

To further improve the quality of the sample, we are going to increase the bit depth.

The readings taken of the wave amplitude are closer together, which is more accurate. However, using more bits will mean even more data is used and the file size will be even larger.

Animation

Calculating Sound File Size

The formula for calculating the size of a sound file is:

Audio file size formula

This formula will give you the size in bits. You should convert your answer to appropriate units (bytes, kilobytes, megabytes, etc)

You may be given a duration in minutes or hours. Remember to convert it to seconds before calculating the file size.


Quality vs File Size

The examples above are very simple, using small values. In reality, CD-quality sound is sampled at 44.1 kHz (44,100 samples per second) with a bit depth of 24 (each binary value is 24 bits long).

This is a lot of data to store, so CD-quality sound files can be very large!

Sound Metadata

Metadata can be thought of as data about data.

When your computer reads data, it just has a stream of 1s and 0s — it does not know how the sample rate, duration of the sample, or the bit depth.

Metadata provides this information, so it can be correctly played.

Other metadata may include:

  • The date the image was created
  • Who created it
  • What software was used

If the audio file is music, additional metadata might also include: recording artist, track name, and album name.

If you are asked about audio metadata in an exam, ensure any examples you give are relevant to audio files.