1.2.7 Sound

In this lesson, you will learn how analogue sound is sampled and stored as binary data. You will explore how sample rate, bit depth and duration affect sound quality and file size, and calculate the storage required for digital sound files.

Representing Sound

Sound travels through the air as continuously changing vibrations. These vibrations can be represented as an analogue sound wave. An analogue signal changes continuously, meaning its value can take any value within a range.

A computer stores data digitally using binary, so an analogue sound wave cannot be stored directly. It must first be converted into a series of numerical measurements using a process called sampling.

During sampling, the amplitude of the sound wave is measured at regular time intervals. Amplitude describes the strength of the vibration at a particular point and is related to how loud the sound is. Each measurement is called a sample.

Figure 1. An analogue sound wave sampled at regular time intervals, with each sample recording the amplitude of the wave at that point.

Unlike the original analogue wave, which changes continuously, the digital representation is made up of separate sample values taken at specific points in time.

The value of each sample is then represented as a binary number so that it can be stored and processed by the computer. When the sound is played back, the stored samples are used to recreate an approximation of the original analogue sound wave.

Sample Rate

Sample rate is the number of samples taken from the analogue sound wave each second. Sample rate is measured in hertz (Hz), where 1 Hz means one sample per second. Sample rates may also be given in kilohertz (kHz), where 1 kHz = 1,000 Hz. For example, a sample rate of 44,100 Hz (or 44.1 kHz) means that 44,100 samples are taken every second.

Increasing the sample rate means the sound wave is measured more frequently. This usually produces a more accurate digital representation of the original sound and can improve playback quality.

Figure 2. The same analogue sound wave sampled at a low and high sample rate. A higher sample rate takes more measurements and produces a closer representation of the original wave.

With more sample points, less of the original wave is missed between measurements, so the stored data can represent changes in the sound more closely. However, more samples must be stored each second, so a higher sample rate also increases file size.

The total number of samples in a recording also depends on how long the recording lasts. This is described by its duration.

Duration

Duration is the length of the recording, measured in seconds. At a fixed sample rate, a longer recording contains more samples overall and therefore requires more storage. Doubling the duration doubles the amount of sound data that must be stored, assuming the sample rate and bit depth stay the same.

Duration does not directly improve playback quality; it simply determines how much audio is stored. For example, at the same sample rate and bit depth, a 20-second recording stores twice as many samples as a 10-second recording and therefore requires twice as much storage.

Sample rate and duration therefore determine how many samples are stored in total. The next factor, bit depth, determines how many bits are used to store each of those samples.

Bit Depth

Bit depth is the number of bits available to store the value of each sample. More bits allow a greater number of possible binary values, so the measured amplitude can be stored more precisely.

Equation 1. The number of possible sample values is calculated by raising 2 to the power of the bit depth.
Table 1. Number of possible sample values at different bit depths.
Bit DepthPossible Sample Values
8 bits
16 bits

The amplitude measured at each sample point must be stored using one of the available binary values. These possible values can be thought of as amplitude levels. The more amplitude levels available, the smaller the gap between them, so the measured amplitude can be represented more accurately.

With 8 bits, there are 256 possible amplitude levels, so each sample must be stored using the level closest to its measured amplitude. With 16 bits, there are 65,536 possible amplitude levels. The gaps between the available levels are therefore much smaller, allowing the stored value to be much closer to the actual amplitude of the analogue wave.

Figure 3. The same analogue sound wave represented using different bit depths. A higher bit depth provides more possible amplitude values, allowing each sample to be stored more precisely and the digital representation to follow the original wave more closely.

A higher bit depth can therefore improve playback quality because each sample can be represented more accurately. However, more bits must be stored for every sample, so increasing bit depth also increases file size.

The Effect of Sample Rate, Bit Depth and Duration

Sample rate, duration and bit depth all affect the amount of data stored in a sound file, but they do not all affect playback quality in the same way. Sample rate determines how often the analogue wave is measured, duration determines how long sampling continues, and bit depth determines how precisely each measurement can be stored.

Table 2. Effects of sample rate, bit depth and duration on playback quality and file size.
FactorEffect on Playback QualityEffect on File Size
Increase sample rateMore frequent measurements give a more accurate representation of the sound waveIncreases because more samples are stored each second
Decrease sample rateFewer measurements can reduce accuracy and sound qualityDecreases because fewer samples are stored
Increase durationNo direct improvement in qualityIncreases because more seconds of audio are stored
Decrease durationNo direct reduction in quality per sampleDecreases because fewer seconds of audio are stored
Increase bit depthEach sample can be stored more preciselyIncreases because more bits are stored for each sample
Decrease bit depthEach sample is represented less preciselyDecreases because fewer bits are stored per sample

There is therefore a trade-off between sound quality and storage. Increasing sample rate or bit depth can produce a more accurate digital representation of the original sound, but also increases file size. Increasing duration increases file size because more samples are stored overall, but it does not improve the quality of each sample.

Calculating Sound File Size

For an uncompressed sound recording, file size depends on how many samples are stored and how many bits are required for each sample. The number of samples is determined by the sample rate and duration. Each sample then requires the number of bits specified by the bit depth.

Multiplying sample rate by duration () gives the total number of samples in the recording. Multiplying that result by the bit depth gives the total number of bits required to store those samples.

Equation 2. Sound file size is calculated by multiplying the sample rate (samples per second), duration (seconds), and bit depth (bits per sample), giving a result in bits.

Suppose a recording has a sample rate of 22,000 Hz, a duration of 30 seconds, and a bit depth of 8 bits. Using the formula in Equation 2 above, this can be calculated as:

Therefore, the recording requires 5,280,000 bits of uncompressed sound data. To convert this into bytes:

Using the 1000-based units from Lesson 1.2.3 Units:

Therefore, the uncompressed sound data requires 660 KB.

The formula shows why the three factors affect file size: increasing sample rate stores more samples each second, increasing duration stores samples for longer, and increasing bit depth stores more bits for every sample.

The calculation gives the storage required for the uncompressed sound data. An actual audio file may have a different size because it can contain metadata and may use compression.

Ready to finish?

Log in to save this lesson and earn rewards.