4 - Sampling in Digital Audio
Title Tag
How Digital Audio Works: From Microphone to Sampling (Simple Guide)
Meta Description
Learn how digital audio works in simple terms — from microphones and sound waves to sampling, A/D conversion, and playback. Includes real-life examples and beginner Python code.
How Digital Audio Works (Without the Confusion)
If you've ever wondered how your voice turns into a Spotify track or a voice note — it’s actually a pretty simple idea.
Let’s walk through it like a normal conversation, not a textbook.
🎤 How a Microphone Converts Sound into a Signal
So here’s the basic idea.
When you speak, you create sound waves — tiny pressure changes in the air.
A microphone turns those pressure waves into electricity.
How it works (simple version):
- There’s a magnet and a coil of wire
- The coil is attached to a flexible surface (like a thin diaphragm)
- When sound hits it, the coil moves
- Moving the coil inside a magnetic field creates voltage
And that voltage is continuous — it smoothly goes up and down.
📡 Analog vs Digital Audio (Why We Need Conversion)
But computers don’t understand continuous signals.
They only understand numbers.
So we use something called an:
- Analog-to-Digital Converter (ADC) → turns sound into numbers
- Digital-to-Analog Converter (DAC) → turns numbers back into sound
💿 What Happens During Recording?
Here’s the process step-by-step:
- You speak → sound waves
- Microphone → continuous electrical signal
- ADC → converts signal into samples (numbers)
- These samples are stored (MP3, WAV, etc.)
And yeah, back in the day, those samples were stored on CDs.
🔊 What Happens During Playback?
When you play audio:
- File is read (samples)
- DAC converts samples → continuous signal
- Signal goes to speaker
- Speaker vibrates → sound waves again
And interestingly…
👉 A speaker works almost like a microphone in reverse
📊 What is Sampling? (The Core Idea)
Sampling is just:
Taking snapshots of a continuous signal at regular intervals
Example (Real Life)
Think of a flipbook animation.
- Each page = one sample
- Flip fast enough = smooth motion
Same with audio:
- Each sample = one measurement of sound
- Enough samples per second = smooth sound
🎵 Understanding Sampling with a Sine Wave
Let’s say your sound is a simple sine wave.
Instead of storing the whole smooth wave, we:
- Take points (samples)
- Store only those points
Then during playback:
- We reconstruct the wave
- Sometimes just by “connecting the dots”
📉 Visualizing Sampling
Here’s the core idea mathematically:
This is a smooth signal.
Sampling means we only keep selected points from this curve.
🧠 When Does “Connecting the Dots” Work?
And here’s the important part:
👉 It works only if you have enough samples
If you don’t:
- The signal looks jagged
- You lose information
- Audio sounds distorted
This is where sampling rate matters (like 44.1 kHz in music).
🧩 Simple Real-Life Example
Imagine tracking your friend’s location:
- If you check once per hour → rough path
- If you check every second → smooth path
Same with audio.
More samples = better accuracy.
Continuing with thinking about the digital audio, we can think about sort of music or, or any other way of dealing with audio right? When we record a sound, we have a microphone and a microphone generates out a continuous voltage. By the way, you guys know how a microphone works? More or less a microphone works the following way. We have a permanent magnet and we've got a electric coil alright with some wires in it, and out, out of that coil comes another wire. And usually, the the coil is on a little springy mechanism. The permanent magnets are fixed.

You speak and that causes a pressure wave, a press, a pressure wave causes the coil to move back and forth. When you move a coil of wire through a magnetic field, that induces a voltage. So that voltage comes out on that wire, and it's a continuous signal. But, in order to encode this into a computer, we put it through what's known as an A to D converter, analog to digital converter, and we get out a bunch of samples. And then, by the way in the old days we used to put those samples on something called a CD. Compact disk. You guys probably don't even buy those anymore. If, if you do, you only buy them to rip them. But, basically, it's a set of samples, it's in a file, whatever it is, okay? When you go to play this thing, okay, what you do is you put your CD into your ancient CD player. It pulls out the samples, and then it goes through what's called a D to A converter, digital to analog converter. And then we take that continuous voltage and we put that out through a speaker. Which by the way, is almost exactly the same as a microphone. Right. It's a coil of wire, you pump electricity through it. It generates a magnetic, varying magnetic field. There's a set of permanent magnets that causes the speaker to move, with respect to those magnets. And voila, out comes a continuous pressure wave.



So, let's talk about this sampling operation and then the reconstruction. So, here we'll take as an example just a sign wave. Okay. So, I collect a bunch of samples. If I collect a bunch of samples, then what am I going to do to reconstruct it? Well, it might be enough to basically just connect the dots and get back the next sine wave. Alright, and so, as long as I had enough dots, that's easy enough to do. So I have enough dots, I connect the dots.