digital audio guide

Digital Filtering and Exact Reconstruction of Digital Audio

Estimated Read Time: 4 minute(s)
Common Topics: frequency, function, sinc, signal, sample

Introduction

This elaborates some of the claims in my insights article on digital audio.

The Sinc Function

The first link in my insights article has a section on filters, but I will detail the most critical case. The bit depth is assumed to be so large for all practical purposes that it is infinite, and all calculations are done at that resolution. To clarify the statement above, we will start with two times upsampling and how it is done. You put the first sample in position one, zero in the second position, the second in position three, zero in the fourth, and so on. These zero samples add higher frequency stuff to the signal if you convert it to an analogue signal. So you want to get rid of it.

Technically, this is done by convolving it with the sinc function for the frequency you want to filter.

For those more into advanced math, see the Wikipedia article:
https://en.wikipedia.org/wiki/Sinc_function

For the rest of us, here is the intuitive explanation. Suppose we put an impulse function of unit height and short duration through an ideal filter with a cutoff of frequency f. Then, you get the sinc function for that cutoff frequency. In the linked Wikipedia article, you can look at one and see its function: $$ sine(x)/x $$ However, it is scaled depending on the cutoff frequency. For those who know some more advanced math, here is why. The Fourier transform of a Dirac delta function is one. Intuitively, the Fourier transform breaks down the function into its frequency spectrum. We replace it with a box function with zero outside of f and -f to band limit it. When you do an inverse Fourier transform to return to the time domain, you get the sinc function. An impulse is approximately proportional to the delta function.

It is symmetric about time t=0 with values forward and backward in time.

Using the Sinc Function

Suppose you have a signal sampled at a high frequency so, each sample, for all practical purposes, is an impulse multiplied of height A, the value of the signal for that sample. You pass that through your ideal filter at frequency f. Then, you will get the sum of all the sync functions multiplied by each sample value, A.

One way to approximate this is to sample the sinc function at the output sample frequency so you have an array of sampled numbers S(n) stored in memory. For a sinc function, that memory would need to be of infinite length, but since we can only keep numbers of finite precision after some length L, they will all be zero.

You have an array O(n) of length L. When a sample comes in, you first output O(1) and shift all the values down so O(n+1) is moved to O(n), leaving O(L) as zero. You multiply the sample by sinc value S(n) and add it to O(n). You keep repeating as signal samples arrive. This is called convolving with the sinc function.

This way, the digital signal is filtered at frequency f (at least approximately). This is done to the signal sampled at 2f when upsampled to 4f using zero for the missing samples, so the signal is the same as the original, but now sampled at 4f instead of 2f.

Of course, you can upsample it to any frequency you like. You pad the extra values with zeroes. When the frequency is very high, you get a good reconstruction of the original signal that is practically continuous because of how high the sampling is. You can make it analogue by converting it to one bit with noise shaping and passing it through a low-pass filter.

If the limit of this process is taken (it can’t be done by an actual digital processor – but mathematically, we can analyse it and see what happens in the limit), then you get exact reproduction in that limit. The limit is called infinitely large upsampling using an infinitely long sinc filter.

Note I mentioned downsampling in my original post a couple of times. It is easy to modify the above process to downsample instead of upsample. It is an excellent exercise working out the details. Remember, in the end, you can throw away samples more significant than two times the sampling frequency.

It also gives some idea of the computing power needed for high-quality digital audio.

If you are a real glutton for punishment, know Lebesgue integration and functional analysis, see:

https://d-nb.info/1114893048/34

Have fun

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply