100 Days Of ML Code — Day 093
Recap From Day 091 and 092
In the last two days, we talked about sampling rate, and how to determine an appropriate sampling rate to represent audio digitally and that had to do with the x-axis, the time axis of our waveform representation.
You can catch up using the links below 100 Days Of ML Code — Day 092 //100 Days Of ML Code — Day 092medium.com 100 Days Of ML Code — Day 091 Recap From Day 090medium.com
Starting from today, we’re going to turn to the y-axis, the amplitude axis, and talk about how many binary digits. What our bit width needs to be to represent each amplitude sample that we record. We’ll talk more formally about what bit width is, and we’ll review what binary numbers are, in case you’re not familiar with them already. And then we’ll also talk about some implications of bit width, in terms of how we record sound, and also how artists have used it in some interesting ways.
Formally the bit width is the number of binary digits that we use to represent the amplitude of each sample.
So for each of the dots in the image shown above, how many binary numbers are we using on the computer? How many zeros or one digits are we using to represent, what that amplitude value is? So it's important that we think about this in terms of binary numbers.
So if we had a bit width of one, for example, that would mean that we would use one binary digit and a binary digit can either be zero or it can be one. It’s either on or it’s off. So we have two possibilities here, it’s either zero, or it’s one. So that means that our resolution is effectively two we have two options for how we’re going to represent the amplitude and that would obviously be an incredibly restrictive environment to work in.
So if we want two bits each one of them each of the two binary digits as seen in the table above could be either zero or one. So, two possibilities for the first digit two possibilities for the second digit. 2 times 2 is 4. still pretty limited. And when up to 8 bits which is something that’s actually used in some fairly low-resolution recordings. I have 8 binary digits, 2 to the 8th power possibilities, 256 possible amplitude values. In other words, as we’re taking the negative one to positive one amplitude space, that y-axis over waveform, we’ve kind of limited it to 256 different possibilities evenly spread across that space.
16 bits which is what we use in CD’s we have 2 to the 16th possibilities about 65,000 and then 24 bits which is what I like to use whenever possible we have two to the 24th possibilities on to 16 million. Also, those extra eight bits from 16 bits to 24 bits gets you a lot of extra resolution on your y-axis from 65,000 up to about 16,000,000. Some people recorded 32 bit as well with some high-end audio software and hardware.
So, obviously, we want to record with as much resolution as we can, within the limits of whatever media we’re working with. Obviously eventually you know using a CD we’re going to be limited to 16 bits when we finally code that file for a CD. But we can’t use infinite amounts of disk space an issue we’ll get to later in the future but, I also just want to talk about the implications of this for recording because it’s not enough to just record something at a good bit width using 16 bits or 24 bits or 32 bits or whatever.
It’s very important that when you are recording you are trying to use the full dynamic range that is available to you because if you are recording at a high bit width but you are only using a tiny bit of the negative one, positive one amplitude range because you might be turning really low or whatever else, might be going on in your process you’re wasting all these bits, they’re just never getting used for anything and so you’re effectively recording at a much lower resolution.
But on the other hand, if you record too loud, I wouldn’t use every single of those bits no matter what. That’s also a problem, because if you go over the negative ones, the positive one range well, then you’ve run out of binary digits to represent those amplitudes values and so they all just kind of clips are cut off at positive one or negative one, so you end up with something called digital distortion which is also not a good thing. It’s basically the peaks and the troughs of all your waveforms just get kind of lopped off and that tends not to sound very good either.
That’s all for day 093. I hope you found this informative. Thank you for taking time out of your schedule and allowing me to be your guide on this journey. And until next time, be legendary.