Calculus AB Content: Add a video exploring the sinc() function and its uses
In the Calculus AB course, Limits and Continuity, there is a video on limit of sin(x)/x.
This is an important function, called the sinc() function. It would be nice to add a separate video discussing this as a practical use case. The most familiar use case is digital signal processing in finite impulse response (FIR) filters.
In a simple FIR filter, your filter kernel is the normalized sinc function, sin(πx)/(πx) or sinc(πx). It requires a number of stages, symmetric to the left and right, so you can store a look-up table of only half the entries, except that sinc(0) is rendered as 1 (the limit of sinc(x) as x approaches zero).
Digital audio is rendered as a number of samples set at a particular spacing in time. The samples represent the amplitude, range [0,1], or range [-1,1]. Whichever range you use is irrelevant.
A simple ideal FIR filter provides equal frequency response for all frequencies. This is impossible because of the Nyquist theorem: at a given sample rate fs, only frequencies—sinusoidal components, of which the whole audio stream is the sum of sinusoids—less than one-half fs can be represented. This is fun to prove!
The visual proof of the Nyquist limit is this: take a wheel—we already know sine and cosine are the x and y coordinates on a unit circle—and rotate it, taking one thousand pictures per second. Put a dot on the rim of the wheel at the right side.
Rotate the wheel at one turn per second anticlockwise—we'll call this forwards—and each picture shows the dot moving anticlockwise around the circumference of the wheel by 1/1000 turns.
Now rotate the wheel anticlockwise at 250 rotations per second. The dot moves anticlockwise 1/4 of a rotation in each picture, anticlockwise. Turn the wheel 499 rotations per second and at the first picture the dot is at start, the second the wheel has moved 499/1000 turns, and the third it's moved 998/1000 turns.
Now: rotate the wheel 500 turns per second.
Now we might say, "Oh, look, the wheel is rotating forward half way each turn," but is it? Let's try rotating the wheel 501 turns per second, and stop. It's 1/1000 of the way past one-half a turn; but now start over and rotate the wheel backwards at 499 turns per second and what happens? It ends at the same location! So you can't really know if a signal is a certain frequency unless you sample it at more than half that frequency—more than half because we represent the rotation by sine, and sine of half a rotation is zero, so instead of the dot moving left and right we only see the samples staying at exactly zero.
In digitally recorded audio, this creates aliasing: once you go past the Nyquist limit, the frequency starts counting down; and when you double the limit, it starts counting up again. We can't distinguish between a sine wave at ten hertz below half the sampling rate and at ten hertz above it.
So what does all this have to do with the sinc() function, and why is the limit of sinc(x) as x approaches zero so important?
Well it turns out that an ideal sinc() filter can reduce the sampling rate while removing higher frequencies. So how does this work?
In an ideal sinc() filter, for every sample given, that sample is multiplied at every sample interval by the sinc() function with the function centered on the sample. This means that for your first sample, x=0, and at your second sample, x=π—note that this is half a rotation, hence the Nyquist theorem—and so forth. On top of all of these points, you move x=0 to the position of your second sample, and your first sample is then x=-π. By shifting the sinc() function to the right by π for each sample, multiplying the sinc() function's value by the value of that sample at x=0, and rendering every sample as the sum of all of these overlapping values of sinc(), you produce exactly the same samples as output.
Now in real life we don't do this infinitely. We might sum up the values for 10 or so samples to each side and move on, which creates a frequency cutoff—frequencies above a certain point won't be reproduced in the output, attenuating slowly. But that's not all.
Let's say you have a sound recorded at 96,000 samples per second. This is significant because the current standard final sample rate is 48,000 samples per second. If your 96,000Hz fs recording is a sum of sines including sine functions at frequencies above the Nyquist theorem for 48,000Hz sample rate—for example, 30,000Hz can be represented in a 96kHz sample rate, but renders as 18,000Hz if recorded at 48kHz sample rate—how do you downsample this?
Well the answer is very simple: you run the sync function above, but every output sample—at 48kHz fs—is considered one step, and so every input sample is a movement along the x axis of π/2 (I think this is right?). As you add up all of the samples, the 48kHz output omits all samples above the Nyquist limit. I'm…not entirely sure why; it might have something to do with sin(x) being impossible to represent at the output sample rate, and so as you reconstruct the samples from the sinc() function you're not properly using values that can represent sine waves above that frequency.
Much easier is doing this without filtering frequencies at all: let's say you want to convert from 50,000Hz to 48,000Hz. This is hard: if we didn't have any frequencies above the 48kHz Nyquist limit, we could downsample from 96kHz by simply taking every other sample; but 50kHz to 48kHz requires interpolation. So how do we do that?
Well it's very simple: the same way you reconstruct the signal in the first place; except instead of summing on every step of π, you move the sinc function by π to center on the input samples, but sum the values of the sinc function at the x positions of 48kHz samples—positions between the 50kHz values. So long as you don't have any frequencies above the Nyquist value for 48kHz, the result is a digital representation of the sum of sines stored at a 48kHz sample rate instead of a 50kHz sample rate.
This is used in all kinds of things, from high-fidelity music production to filtering noise out of electronic signals in Internet infrastructure. If you have a digital keyboard, it likely uses many recordings of various instruments, and for some keys and for pitch bending uses a sinc filter to resample—to raise the pitch by 10%, simply play 10% more of the recorded samples per second, but this is more than just difficult and so the synthesizer treats the recorded instrument as if it's recorded at a slightly higher sample rate and then runs it through a sinc filter to adjust it back to the instrument's native sampling rate. This requires several samples to be generated after you press the key, and then regenerated after filtering, which contributes to a short but imperceptible pause between pressing the key and producing the final sound.
All of this relies on sinc(0) being equal to one—which it clearly isn't. However, because the limit of sinc(0) approaches one (which is why it needs to be one specifically, and not some other number), the function used is sinc(0) for all x≠0, and 1 for x=0; or put more concisely, it's not sinc(x), but rather the limit of sinc(x) as x approaches the desired value which is used.
So there's the use of sin(x)/x in the world around you, so now you know that all this math stuff isn't just useless trivia that you'll never need outside of college.
A bejegyzéshez nem írhatók újabb hozzászólások.