Audio Programming for Beginners Tutorial 00- Analog to Digital Conversion, Sample Rate & Bit Depth

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up everybody I'd like to welcome you to lesson one of audio programming for beginners this is a course that I'm starting out just to get started with building your own audio effects and digital instruments just a few things to go through before we get started first thing is that I'm going to try to keep these videos limited to about 10 or 15 minutes of video just try to keep things nice and short and to the point so we don't get drawn too far in second thing is I have a pen mouse now where I can write down and draw some of the concepts for you just to warn you my writing and my drawing is pretty horrible but hopefully it's good enough to get the idea across so we're just going to jump into things and I thought a great place to start would be just getting some foundations for some foundational knowledge of digital signal processing and I know some of you might be thinking well why do I need to know this theory stuff you know I just want to build I just want to get the building audio effects and building programs and the answer is unless you know what some of these key concepts are and what they mean then when you get around to trying to program this stuff you won't know basically anything you won't have any idea what these different concepts and these different numbers mean like sample rate bit depth Nyquist theory so on and so forth so this is just going to give you like a real rough foundation and I'm going to kind of breeze through a lot of this stuff but I mean you could get really deep into this you know some of these concepts I kind of I'm going to explain to you today I mean you can get really really far into it but I'm just giving you just enough to get you started and hopefully if you're curious about them you can go in and you read more about it okay so this first thing that we're going to talk about is the concept of analog to digital conversion okay and what does that mean okay well and all of the digital conversion is basically taking an analogue source like my voice okay and how does it get converted from my voice going as vibrations through the air into the microphone how does that get converted into numbers into the competitive computer can read and then consequently back out through vibrations through a speaker and then into your eardrums we're going to talk a little bit about that and some of the key concepts around that such as sample rate and bit depth okay so first thing that we need to know is what is a sound okay and as I said before a sound is basically their their vibrational waves okay if you look at this sampler that I have here in Ableton this is a kick this is a sample of a kick drum okay and a lot of people don't really think about this but this um this wave that you see here that's kind of pretty much like a sine wave this is actually like an instruction manual of for how your speaker needs to move to actually recreate this sound okay so so this is this is exactly how the cone in your speaker needs to move back and forth to create this sound okay so taking a step a little bit further back from that well how do we how do we figure that out okay how do we when my voice goes into the computer how is the computer able to come out with a wave that's kind of similar to the one that you see here okay let's through two numbers really one of them is called sampling rate and the other number is called bit deaf so if we go into the Ableton preferences now go into my audio section and you see a section here says sampling rate and then you see a number here that says 44100 and what does that mean I'm going to explain that shortly then if we go into the section where you record you see a number here this is bit depth and says 16 what does that 16 mean okay so um so I'm going to try to explain these concepts the best that I can and do it in a real quick kind of way okay so if we go to my drawing board here pick up my 10 so the first thing that we're going to talk about is sampling rate okay okay the number that we had there was 44 140 4,100 okay well what does that mean well it means exactly what it says the sampling rate is the rate at which a signal is being sampled okay so now I have a signal which in this case let's just say it's my voice and it's like this okay on this x-axis we have time okay so let's just say this is one second okay so this is zero to one second okay 44100 means that every second my voice get sampled at different points forty four thousand one hundred times okay that's what the sampling rate means means that this signal gets sampled 44,000 100 times every second okay so what happens is it looks at a point okay let's just say this point here okay let me let me actually draw this on a different graph okay so you got time zero all right let's just Nate it my voice is doing this okay and it sampled that and then let's just say that my voice is doing this at 1 144 100th of a second later that it's just doing these various things let's just say we get to 1 second now I'm going to draw a sine wave but my voice obviously isn't a sine wave so what happens is that the voice is sampled okay sampled like so okay and then it's held okay sample sampled sample and hold okay so what this basically means is that whisk is sampled and then it holds that value until it gets to the next point where your voice needs to be sampled and then it opens and it takes what the next value is and then it holds that value until it gets to the next point where where it needs to be sampled okay then it just continues to do this okay for as long as you're recording okay just like that okay so that sampled and that's sample-and-hold okay so at these points the values taken okay so now you have my the the the wave is going between values of minus one and one okay so when you take this point and you sample it okay you could just say that that is zero over 40 for 100 so so if we were just like putting numbers to these different times that that these values are being sampled right and then the next time would be like 144 100 and the next point where it gets sample which would be like right here be 2 over 40 for 100 okay so just going to erase this up clipboard so what are those values all right so let's go back ok so I've got these values good sampling them right once again we're just going to say sample rate sample rate is the rate at which we are sampling 44100 times a second okay now we've talked about how many times that's happening per second right 44100 times but we haven't really talked about what are these values okay I've already told you that they're between 1 and minus 1 all right what are these values this is where we get into the next item of the discussion that we're going to call bit depth okay now what happens we're going to talk about two concepts actually bit depth and quantization okay so let's just take a look at this very point where my voice has been sampled okay what's the value of that particular place is something between 1 and minus 1 what happens is that it goes through this process called quantization okay what that means is that we have a certain space of values that we call bit depth ok and if we go back to Ableton we can look at what our bit depth actually is in my mouse doesn't act funny ok so go into preferences bit depth is 16 okay so 16 okay does that mean that I have 16 places that I can go between 1 and -1 well now that's not what it means it means that you have 2 to the 16th power of places that you could go between 1 and minus 1 okay and if we calculate that out I believe that makes it 65,536 places that you can go between 1 and -1 so what happens is you look at my voice where is it at this point okay let's say this is let's say that this point is this point okay tell them how the same thing what it does is it looks up and it looks down and it says what value is closest to one of these 6536 values that were allowed to choose and it places it places this value up or down into that place that's what Colin that's what quantization is okay now when we have so now we've sampled the voice we've put it into its proper place quantization using the bit depth okay now when we need to read it back out into the speakers what happens is that this gets kind of filtered and I'm going to not going to go into a lot of detail about this just yet what happens is that this this gets filtered what it does is it kind of smooths the changes between these different between these different values okay smooth them over and then and then the voice in turn goes back out to the speakers okay okay and that's that's how it gets converted back into an analog signal okay so just to review okay so I'm just going to erase this so we have sample rate this 44100 hurts okay ken can be higher can be lower but standard is 44100 hurts okay now we're just going to talk about one more thing before we just kind of round up why 44100 hurts right why isn't it higher why isn't it lower sorry close my door there okay well the human range of hearing is between 20 Hertz and 20,000 Hertz okay now there's this theory is called the Nyquist theory okay what the Nyquist theory says is that the maximum representable frequency is one-half of your sampling rate okay so the maximum representable frequency is one half of your sampling rate okay so if we took forty four thousand one hundred and divided it by two we will get 22050 Hertz okay and if we look at the range of human hearing 20 20 20 Hertz to 20,000 Hertz okay so you can see how this number makes sense because it can basically fit our whole range of hearing into uh into this sampling rate okay a forty four thousand one Hertz but one forty four thousand one hundred Hertz okay so I'm just going to do a quick review okay so like I said before sampling rate is how many times a second are we going to take a value okay so go back down here here's my wave okay this is one second this is zero okay this is time okay forty-four thousand one hundred times I'm reading values okay the process of that is called sample and holds okay so I've sampled so I've sampled these points okay now I go and I look at my bit depth right which is in this case is 16 okay which means 2 to the 16th power which is 65,536 values okay that these points can be placed into okay and that process is called quantization so I'm writing all over the place here it's that process called quantization when the value when the signal is getting ready to be read out of the computer and processed back into an analog signal again it gets smoothed out through a filtering process okay and then it's read out through the speakers okay so that is the process of converting an analog signal to a digital signal and then converting it back into an analog signal again okay so that's it for this lesson if you have any questions please comment below and I'll do my best to answer them if you like this lesson be sure to thumbs up and subscribe if you haven't already subscribed and for the next tutorial we're going to go over aliasing okay so we're going to talk about aliasing let me just erase this give you something to think about so aliasing right my maximum representable frequency is 22050 Hertz what happens if I have a signal that's 30 100 Hertz right would is above the range of human hearing okay human range a range of human hearing is 20 Hertz 20,000 Hertz if I have a sound that's 30 1000 Hertz that's above my Nyquist frequency what will happen okay will you hear it it's just something to think about for next time and then we're going to go a little bit more over the principles of things like sine waves and just some more basic digital signal processing principles okay so I hope you enjoyed the video and I will see you next week
Info
Channel: The Audio Programmer
Views: 37,124
Rating: undefined out of 5
Keywords: audio programming, creative coding, audio coding, creative programming, digital signal processing, dip, plugins, vst, software development, ableton, max map, c++, sample rate, bit depth, nyquist theorem, juce framework, tutorial, beginner, easy, games development, games programming, sample and hold, sampling, quantization, nyquist, basics
Id: Ov3GXhorrJE
Channel Id: undefined
Length: 21min 55sec (1315 seconds)
Published: Mon May 22 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.