← All posts
8 min read

How Sound Becomes Data: Sampling a Wave into Numbers

#technology#computer-science#audio#data
📑 On this page

Sound begins as movement. A guitar string vibrates, a speaker cone moves, or vocal cords push and pull the surrounding air. Those changing air-pressure patterns reach our ears, and the brain interprets them as speech, music, or noise.

A computer cannot store moving air directly. It stores a numerical description.

Digital audio is a sequence of measurements that describes how an audio signal changes over time.

Playing the audio reverses the journey: the measurements guide a speaker, which recreates a changing pressure wave in the air.

Sound is a wave through a medium

When an object vibrates, it compresses and releases nearby particles. That disturbance travels through a medium such as air, water, or a solid material.

Two useful properties are:

  • Amplitude, related to the strength of the pressure change and perceived loudness
  • Frequency, the number of repeating cycles per second, related to perceived pitch

Frequency is measured in hertz. A 440 Hz tone repeats approximately 440 cycles each second.

Real sounds are rarely one perfect wave. A musical instrument produces a complex combination of frequencies that changes over time. Those combinations help distinguish a piano from a violin even when both play the same note.

A microphone converts pressure into an electrical signal

A microphone contains a component that responds to changing air pressure. Depending on its design, movement changes an electrical property and creates a varying signal.

At this stage the signal is analog: its electrical level changes continuously in a way related to the incoming sound.

The signal may be amplified and filtered before reaching an analog-to-digital converter, often shortened to ADC. The converter measures the signal repeatedly and produces numbers.

The quality of the microphone and recording environment matters before digitization begins. A high sample rate cannot remove a loud fan, room echo, clipping, or a poorly placed microphone.

Sample rate: measurements per second

The sample rate states how many times per second the analog signal is measured.

Common rates include:

  • 8,000 samples per second for some narrow-band speech systems
  • 44,100 samples per second for audio CDs
  • 48,000 samples per second in much video and professional audio work
  • Higher rates in specialized recording and processing

Why take so many measurements?

To describe a changing wave, the sample rate must be high enough to capture its fastest relevant variations. A foundational result called the Nyquist-Shannon sampling theorem says that reconstructing a band-limited signal requires a sample rate greater than twice its highest frequency.

Human hearing is often approximated as extending to around 20,000 Hz for young listeners under ideal conditions. A 44,100 Hz rate is slightly more than twice 20,000 Hz and leaves room for practical filtering.

Sampling below the required rate creates aliasing, where high-frequency changes appear as false lower-frequency patterns.

Bit depth: precision of each measurement

Sample rate controls how often measurements occur. Bit depth controls how many numerical levels are available for each sample.

For one sample:

Bit depthPossible levels
8-bit256
16-bit65,536
24-bit16,777,216

More levels allow the system to represent amplitude more precisely and provide a wider usable dynamic range.

Rounding a continuous signal to one available level creates quantization error. With sufficient bit depth and proper signal handling, this error can be made very small. Audio systems may also add carefully controlled noise called dither to make quantization behavior less correlated and less objectionable.

Bit depth does not simply mean "louder." Playback volume is a separate choice. Greater recording depth provides more precision and headroom during capture and processing.

Channels: one stream or several

A channel is an independent sequence of audio samples.

  • Mono uses one channel.
  • Stereo uses two, commonly associated with left and right.
  • Surround formats use additional channels or object-based spatial descriptions.

Stereo can preserve differences in timing and level between two microphones or a created mix. During playback, separate speakers use those channels to produce spatial cues.

Doubling the number of uncompressed channels doubles the sample data. A one-minute stereo recording contains twice as many sample values as a one-minute mono recording at the same sample rate and bit depth.

A concrete example: calculating audio size

For uncompressed pulse-code modulation, estimate the data rate with:

sample rate × bit depth × channels

For CD-quality stereo:

44,100 samples/second × 16 bits × 2 channels
= 1,411,200 bits/second

Divide by eight:

1,411,200 ÷ 8 = 176,400 bytes/second

For one minute:

176,400 × 60 = 10,584,000 bytes

That is approximately 10.6 MB before container overhead. A three-minute song would require roughly 31.8 MB uncompressed.

Compressed formats can reduce this substantially.

PCM, containers, and codecs

Pulse-code modulation, or PCM, is a common way to represent sampled audio values directly.

A file or stream also needs structural rules. Several terms are useful:

  • A codec defines how audio is encoded and decoded.
  • A container organizes encoded data and metadata.
  • A file extension often hints at the container, but does not tell the complete story.

WAV files often contain uncompressed PCM, but the WAV container can hold other formats. MP3 and AAC are lossy audio codecs. FLAC is lossless and can reconstruct the original PCM sample values exactly.

Metadata may include artist, album, track title, cover art, recording date, and technical properties.

Lossless and lossy audio

Lossless compression finds a more efficient representation without changing the decoded sample values. It is useful for archival, editing, and listeners who want exact reconstruction.

Lossy compression removes or simplifies information according to models of human hearing. It may discard details masked by louder sounds or represent less perceptually important information with reduced precision.

The bitrate of a compressed stream describes how many bits are used per second. A higher bitrate often permits better fidelity, but codec efficiency, content, and encoding settings also matter.

A spoken podcast can remain intelligible at a bitrate that would make complex music sound unpleasant. The content and purpose should guide the choice.

Playback reverses the process

To hear digital audio:

  1. Software reads the file or stream.
  2. A codec decodes compressed information into sample values.
  3. A digital-to-analog converter creates a changing electrical signal.
  4. An amplifier provides power.
  5. A speaker or headphone driver moves.
  6. That movement produces pressure waves in the air.
  7. Your ears and brain interpret the result.

The speaker does not output individual audible dots. Reconstruction and the physical system produce a continuous waveform from the sample sequence.

Clipping and recording level

Digital formats have maximum and minimum sample values. If an incoming signal exceeds the available range, the recording cannot preserve the true peak. Values are forced to the limit, producing clipping.

Clipping changes the waveform and often creates harsh distortion. Once recorded, the missing peak shape cannot be perfectly recovered.

Recording too quietly is not ideal either, because the desired signal sits closer to microphone and electronic noise. Good level setting preserves headroom for peaks while keeping the useful signal strong.

Modern high-bit-depth recording gives engineers more flexibility, but it does not eliminate the need for sensible microphone placement and gain.

Common misunderstandings

"Digital audio is a staircase-shaped sound"

Samples are discrete values, but a digital-to-analog system reconstructs a continuous signal. The final speaker movement is not a sequence of frozen stair steps.

"A higher sample rate always sounds better"

The rate must be sufficient for the relevant frequency range and processing. Beyond that, microphone quality, mastering, speakers, room acoustics, and listener ability may matter more.

"Bit depth controls the maximum playback volume"

It controls the number of sample levels and available dynamic range in the representation. The listening volume is controlled later by the playback system.

"Compressed means damaged"

Lossless compression changes size without changing decoded samples. Lossy compression removes information, but a good encoder at an appropriate bitrate can produce a result that is difficult to distinguish from its source.

Knowledge check

1. What does sample rate measure?

It measures how many times per second the audio signal is sampled.

2. What does bit depth affect?

It determines how many amplitude levels are available for each sample, influencing precision and dynamic range.

3. Why does stereo uncompressed audio use more data than mono?

Stereo stores two independent sample streams instead of one, so it has twice as many sample values at the same rate and depth.

4. What is clipping?

Clipping occurs when a signal exceeds the numerical range available for recording, forcing peaks to the limit and distorting the waveform.

The one idea to remember

Digital audio is a rapid sequence of amplitude measurements organized through time.

Sample rate controls when measurements are taken, bit depth controls their precision, channels provide independent streams, and codecs determine how efficiently the data is stored or transmitted.

Next, we will look closely at compression and the strategies used to make many kinds of files smaller.