0:00

So in the last video, we talked about the, the fundamentals of visual sound.

Â and of each of the samples and the considerations we have in terms of

Â sampling rate and bit width, number of channels we use to represent sound

Â visually. in this video, we're going to delve into

Â the question of sampling rate in much more detail.

Â and ask a simple question of how do we determine what the appropriate sampling

Â rate is. so we'll, we'll explain it a little bit

Â more formally what a sampling rate is. And we'll look at the Nyquist Theorem,

Â which gives us some guidance on picking a sampling rate.

Â so finally we'll also talk about foldover which is something that can happen

Â usually that we usually don't want to happen, if you pick a bad sample

Â [INAUDIBLE] that is too low for a particular project.

Â so the sampling rate is, is very simply put, it's the number of samples per

Â second of digital audio. so if you recall we have this kind of

Â very zoomed-in sine wave here. Each of these dots is a sample.

Â It's simply asking, well, how many of these dots are we capturing every second.

Â and because this is, is in terms of samples per second kind of metric, we

Â actually use hertz to represent it. The same thing we had used to represent

Â frequency. so, for instance if 8,000 hertz is our

Â 1:18

sampling rate, it simply means that we're we're capturing 8,000 of these samples

Â every second. so that's how we talk about sampling

Â rate. And now, how do we decide what our

Â sampling rate should be? it's actually fairly simple.

Â we use something called the Nyquist Theorem, which is also sometimes known as

Â the sampling theorem. And what the Nyquist Theorem says is that

Â the sampling rate must be at least twice the highest frequency that you wish to

Â represent. this makes a lot of intuitive sense when

Â you think about it. And the reason for that is let's think

Â about our sine wave again, here. if I have a sine wave going at, you know,

Â say 440 hertz then, I have 440 peaks and I have 440 troughs happening every

Â second. so the minimum that I need to capture

Â digitally in terms of those dots, those, those amplitude readings would be for

Â each cycle of my sine wave, I need to make sure that I have at least one sample

Â to represent somewhere on my peak, somewhere above the zero crossing.

Â and then, something somewhere below the peak to represent you know, below the

Â zero crossing. Somewhere you know, down by my trough.

Â so I need 440 peaks and 440 troughs or 440 above zeros and 440 below zeros to be

Â able to capture these 440 cycles of my sine wave in a second.

Â 2:49

So I simply would multiply 440 by 2 and I'd end up with 880 as a sampling rate

Â that I would need. so in reality, you know, we're not

Â looking at every individual sine wave or frequency component that we want to

Â represent. We want to come up with some general

Â sampling rate that's going to work really well for a lot of things.

Â so what should that sampling rate be? we can kind of deduce this logically.

Â we talked about the range of human hearing is going from roughly 20 hertz up

Â to 20,000 hertz. So if we take, you know, 20,000 hertz and

Â we multiply it by 2, it's simply easy math here.

Â we end up with 40,000 hertz. So, we know that the sampling rate must

Â be greater than 40,000 hertz. and so the number that we usually end up

Â seeing is 44,100 hertz. the reason for this has to do with the

Â history of the early days of digital recording and some decisions at Sony and

Â other manufacturers made in the late 1970s that aren't really worth getting

Â into here. But that number has largely stuck.

Â that's what we use on compact discs, in particular, is 44,100 hertz is their

Â sampling rate. You'll sometimes see other sampling

Â rates. you'll see like 48,000 hertz for

Â instance. you'll sometimes see higher rates like

Â 96,000 hertz or even 192,000 hertz. It's in very high fidelity recordings.

Â And the reason for that, of course, is that you know, if we had this sign wave

Â here. Sure it's nice to be able to capture at

Â least one sample somewhere on the peak, and one somewhere on the trough, but

Â that's not going to be enough to really capture the entire shape of that sine

Â wave, that entire curve. if you want to get a really, really nice

Â representation of it, you're going to want as many samples as possible all

Â along the way. so the higher a sampling rate is the

Â better resolution we'll, we'll get and the better will be it'll represent those

Â curves. so I'm going to talk briefly here about

Â what happens if our sampling rate is too low.

Â we get something called foldover. So, so if our sampling rate is too low,

Â it's not just that the other, you know the frequencies above the, the Nyquist

Â frequency which is that highest frequency we can represent.

Â it's not just that those frequencies disappear from our sound, but they

Â actually they turn into other frequencies in the sampling rates.

Â So, I want to show you what I mean here. here we've got a sine wave here in, on,

Â on, on this top image here. And we can look at the number of cycles

Â here from peak to peak, peak to peak, peak to peak, peak to peak.

Â so there's four plus a little bit more in this, this image and this is the sampling

Â rate of 44,100 hertz. And if we take that sine, same sine wave

Â and we reduce it down to something crazy low, like, 284 hertz, we end up with

Â something like what you see in the bottom.

Â So here we're still getting a periodic sounds here.

Â It's not a sign wave anymore because we, we've lost kind of resolution of that

Â curve. And it's it's also not the same number of

Â cycles anymore. But we are getting cycles.

Â We're getting one full cycle plus, you know, a little bit more in, in this

Â particular square of time. and so we're going to here that as a

Â periodic sound. It's going to have a frequency to it.

Â But it's not going to be the original frequency that we expected of that, that,

Â that 440 hertz sine wave that we had in the top image.

Â So now I want to look at the sampling rates in practice inside of Reaper.

Â And so, what I have in this demo here, is I have just a simple 440 hertz sine wave

Â loaded on my track here. And and I have a special plug in here

Â which lets me change the sampling rate of this sound dynamically, so we can hear

Â what happens with that sign wave at, at different sampling rates.

Â right now it's set at 44,100 hertz. and then over here we have a spectrum

Â analyzer, so I can see what frequencies are actually present in the sounds.

Â So [SOUND] at 44,100 hertz, I have my one sign wave peaks right here at 440 Hz.

Â That's the way I would expect. As I start lowering that sampling rate at

Â first it doesn't matter because I'm still you know following the Nyquist Theorem.

Â But as it gets lower and lower and lower, we start to see the folding over

Â happening, and we start to hear it as well.

Â [NOISE]. As those foldover frequencies start

Â coming in to my sound, I'll go back to 44,100 Hz.

Â so again hear a similar phenomenon if instead of just listening to a sine wave

Â we look at a real sound like a drum something like this.

Â 7:41

[MUSIC] So again, that's at 44,100 Hz. so that's a good sampling rate for the

Â sound but as, I bring this down, we'll start to hear a lot of frequency content

Â getting lost. At first it, it'll sound like we're just

Â losing some of the higher frequencies, so it sounds a little bit darker.

Â And then we'll, as it gets lower and lower, we'll start hearing more of that

Â foldover, and actually hear other pitches start coming in.

Â [MUSIC] So you can get a sense both of the frequency constant that's lost as I

Â lower the sample rate. and also the frequency content that's

Â folding over as I lower that sample rate. the, the final example I wanted to show

Â you was, was to go back to that chirp sound.

Â The one that sweeps gradually from 20 hertz all the way up to 20,000 hertz.

Â and so this is a really clear demo of, of, of this practice of foldover.

Â So again, if I'm at, at 44,100 hertz, I'll just hear that original chirp the

Â same way we, we've heard it before. [SOUND] And we can see this on the

Â sonogram here, as it's going up and up and up steadily in pitch.

Â [SOUND] but as I lower that sampling right, we'll start to hear it, hear and

Â see it folding over at certain points. [SOUND] So you can see the foldover as

Â it's going down much lower than it was before, and the more I lower this, the

Â lower that foldover's going to start happening.

Â [SOUND] So we're not getting the chirp from 20 to 20,000 Hz anymore.

Â It's getting kind of stuck when it hits that Nyquist frequency and coming back

Â down going up and down and up and down as it's folding over.

Â [SOUND] So just to quickly review here. In this module we talked about the

Â Nyquist Theorem. as a way to figure out an appropriate

Â sampling rate, that our sampling rate needs to be at least double the highest

Â frequency we want to represent. and we talked about how we kind of

Â arrived at 44,100 hertz as a fairly standard sampling rate.

Â and we talked about foldover and other effects that can happen when we're

Â recording at a sampling rate that's too low.

Â In the next video, we're going to get into the question of bit-width and how we

Â decide what resolution we need to represent the amplitude of each sample.

Â