December 5, 2026
5 min read

Part 1: Digital Audio Fundamentals — Sample Rate, Bit Depth and PCM

Android HAL
Audio HAL
HAL
PCM
MMukund Pandey
Mukund Pandey

AOSP Engineer

This section explains how digital audio represents the amplitude of a sound signal using bit depth. Using a sine wave as an example, we explore how sample rate determines the frequency of capturing points along the time axis (X-axis), while bit depth determines the accuracy with which each captured point is represented along the amplitude axis (Y-axis).

Imagine you're sitting in your car, playing your favourite song on a music application.

You tap the Play button.

Within milliseconds, you start hearing music through your car speakers. It feels like a simple operation, but a lot is happening behind the scenes.

Every mobile phone and car offers a unique audio experience. Different devices have different audio hardware, amplifiers, DSPs, speakers and audio processing capabilities.

Interestingly, the application you choose to play your favourite song doesn't need to know any of this. It doesn't need to understand which amplifier is connected, which DSP is processing the audio, or how the speakers are configured.

That's the beauty of Android's architecture!

Applications interact with a common, platform-independent audio framework, while the underlying layers take care of communicating with the device-specific hardware.

But how does this actually work?

How can the same music application work seamlessly across different devices, each having completely different audio hardware? How do AudioFlinger, Audio HAL, ALSA and the DSP communicate with each other to deliver the final audio experience?

Let's take a closer look at the layers that make this possible.

And while exploring these layers, we'll focus on one particularly interesting aspect: Audio Buffers.

Why does every layer maintain its own buffer? How are these buffer sizes calculated? What factors should we consider while allocating them?

Let's start with the fundamentals.

1. How do we represent audio in a digital format?

Before understanding audio buffers, let's understand how audio is represented digitally.

When we listen to music, what we actually hear is a continuous variation in air pressure, which our ears perceive as sound.

A microphone converts these sound waves into an analogue electrical signal. However, computers and digital audio systems cannot directly process a continuously varying analogue signal in its original form.

We need to convert this continuous signal into digital data.

This process is called Analog-to-Digital Conversion (ADC).

To understand how this works, let's consider a simple sine wave.

1.1 Understanding a Sine Wave

A sine wave is one of the simplest representations of a periodic audio signal.

It continuously oscillates between positive and negative amplitudes.

For example, consider a 1 kHz sine wave.

  • Its frequency is 1,000 Hz.
  • It completes 1,000 cycles every second.
  • One complete cycle takes 1 millisecond.

A simplified representation:

The horizontal axis represents time, while the vertical axis represents the amplitude of the signal.

Now, how do we convert this continuous waveform into digital data?

Two important parameters come into the picture:

  1. Sample Rate
  2. Bit Depth

1.2 Sample Rate – How frequently do we capture the signal?

Imagine taking photographs of a moving object.

If you take only a few photographs per second, you might miss some of its movement. If you take more photographs per second, you can capture its movement more accurately.

Digital audio works on a similar principle.

Instead of storing the entire continuous waveform, we capture its amplitude at regular intervals. Each captured value is called a Sample.

The number of samples captured per second is called the Sample Rate, measured in Hertz (Hz).

For example:

  • 8,000 Hz means 8,000 samples per second.
  • 44,100 Hz means 44,100 samples per second.
  • 48,000 Hz means 48,000 samples per second.

Let's consider our 1 kHz sine wave and sample it at 48 kHz.

This means we capture 48,000 samples every second.

The time interval between two consecutive samples is:

Time between samples = 1 / Sample Rate

= 1 / 48,000

= 20.83 microseconds

The more frequently we sample, the more information we capture about how the signal changes over time.

An important observation: Sample Rate determines how frequently we capture the waveform, not how accurately we represent its amplitude.

That brings us to our next parameter.

1.3 Bit Depth – How accurately do we represent the signal's amplitude?

We know that sample rate determines how frequently we capture the signal. But once we capture a sample, how do we represent its amplitude digitally?

This is where Bit Depth comes into the picture.

Imagine our sine wave has an amplitude ranging from -0.5 to +0.5.

When the ADC captures a sample, it measures the signal's amplitude at that instant. However, a digital system cannot represent every possible amplitude value. It must map the measured amplitude to one of a finite number of available levels. This process is called quantization.

The bit depth determines how many levels are available for this representation.

For example, in 16-bit PCM audio, each individual sample is represented using 16 bits (16 binary digits).

This gives us: [ 2^ = 65,536 ]

These levels are distributed across the representable amplitude range. For signed 16-bit PCM, the digital values range from -32768 to +32767.

1.4 PCM (Pulse Code Modulation) – Bringing It All Together

We have now understood two important parameters of digital audio:

Sample Rate: Determines how frequently we capture the analogue signal.

Bit Depth: Determines how accurately we represent the amplitude of each captured sample.

But how do we bring these two concepts together to represent audio digitally?

This is where Pulse Code Modulation (PCM) comes into the picture.

PCM is a digital representation of an analogue audio signal in which the signal is sampled at regular intervals, and each sample is quantized and encoded into a binary value.

In simple terms, PCM converts a continuous audio waveform into a sequence of digital sample values that can be stored, transmitted and processed by digital systems.

Let's revisit our example:

Frequency: 1 kHz

Sample Rate: 48 kHz

Bit Depth: 16-bit

Channels: 2 (Stereo)

Each sample occupies 16 bits (2 bytes).

For stereo audio, we have two samples per sampling instant: one for the left channel and another for the right channel.

Therefore, the amount of audio data generated every second is: PCM Data Rate Calculation

For our example:

Comments (0)

Sign in to join the conversation

Loading comments...