Audio Programming: Sample Rate and Bit Depth

Gerald Clark
3 min readJan 12, 2024

Audio is where my whole game development/programming journey began! I love audio and I aspire to work in the game audio field, so I’m starting a series of audio programming articles to help showcase this stuff. lets get right into it!

SAMPLE RATE:

What is sample rate? Sample rate is the rate at which an audio signal is sampled. So lets just assume I’m looking at a waveform being sampled at 44,100hz. Lets also assume that this waveform’s duration is 1 second. Time will be represented on the X axis of this image.

The 44,100hz means that this is being sampled 44,100 times per second. So what happens is at 1/44,100 of a second the signal is being sampled and then HELD.

By held I mean that the value of that sampled audio is being carried over until the time reaches 2/44,100 of a second. Then whatever the value of that sampled audio is held until 3 and so on and so on. But what values am I talking about?

BIT DEPTH and QUANTIZATION:

I’m talking about bit depth! Bit depth is basically a value between -1 and 1. This is represented on the Y axis of the image.

So when an audio signal is sampled, it goes through a process called quantization. To understand that, we need to understand bit depth a little more clearly. You’ve probably noticed in your DAW of choice your project is, by default, usually set to either 16 or 24 bit. Does this mean you have 16 to 24 places you can sample the audio between -1 and 1? NO.

It means that you have 2¹⁶ places you can have the audio sampled between -1 and 1 if you’re at 16 bit for example… which equals out to 65,536 places. So when the audio is sampled, it takes the point at which it is sampled, looks up and down between all 65,536 places and basically “snaps” that sample to whichever place it is closest to.

Why 44,100hz though? We aren’t stuck here. Lots of recordings are done at 48kHz or even higher at 96kHz. It really just depends on what you want to do. But this brings me to something called the Nyquist Theory.

NYQUIST THEORY:

The range of human hearing is from 20hz to 20kHz. The Nyquist theory basically says that the maximum representable frequency is half of the sample rate. SO 44,100/2 = 22,050hz. This number makes sense because it allows all the frequencies within the range of human hearing to fit within it.

I hope this helps clear up some of the mystery surrounding the concept of sample rate and bit depth! Be on the lookout for more audio programming articles! Thanks for reading.

--

--

Gerald Clark

Father Game Developer Music Composer Sound Designer