PCM encoding vs high frequency representation problem?
Nov 11, 2006 at 6:37 PM Thread Starter Post #1 of 24

El Condor

100+ Head-Fier
Joined
Oct 30, 2006
Posts
237
Likes
10
Hello,

I stayed up late last night trying to understand sampling vs bandwidth and I think I got it down. I understand why sampling needs to be double the bandwidth
blink.gif
(Nyquist-Shannon sampling theorem).

From what I understand, it would be very clear that lower frequencies are privileged as far as accuracy in representation goes. Going higher in the frequency spectrum, what I perceive is that the frequencies will be less accuratly portrayed using PCM encoding. Is this correct? If this is the case, then how do anti-aliasing algorithms cope with this problem? 1Hz being the most precisely represented frequency, I understand that there would be a loss in representation accuracy in the sampling dimension of 1/2 for every Hz in excess of 1. Maybe I misunderstand all this but what are the implications on anti-aliasing and accurate representation of the underlying music in the higher frequency?

I'm really curious and want to understand all this so I can have a thorough understanding of what the DAC does when it oversamples and anti-aliases the signal (I think I got the oversampling down also. It makes sense to me in a context of converting digital to analog).

Anyways, any thought on the subject would be appreciated.
rs1smile.gif
.

I have a computer science background and I'm not completely ignorant about electronic (mostly digital that is. I don't understand analog signal processing as well) so feel free to shoot at will. If there's enough information available, I should be able to figure things out
tongue.gif
.
 
Nov 12, 2006 at 1:14 PM Post #2 of 24
From what I can understand the reason behind oversampling and anti-aliasing have nothing to do with the detail of the treble in the digital form, but much more to do with the analog filter afterwards. I don't know exact details because frankly I do not care for the technology but Non-OS DACs have some information just above 22kHz which needs to be very sharply filtered out, and these filters cause big problems in the (10-20khz) depending on design.

8x oversampling was designed to raise these artifacts up above 352khz and thus now the analog filter can be very basic, very smooth, and above all high enough not to have any impact at 20kHz. Anti-aliasing was brought in to smooth the result of the oversampling filter, to remove the jagged edges IIRC.
 
Nov 12, 2006 at 6:18 PM Post #3 of 24
Quote:

Originally Posted by Garbz
From what I can understand the reason behind oversampling and anti-aliasing have nothing to do with the detail of the treble in the digital form


First off, thanks for answering, I had almost given up on this post and was starting to look elsewhere for answers
tongue.gif
.

No, I'm aware that oversampling and anti-aliasing are not the same as the digital encoding (given my computer science background, I clearly understand the digital form), I was mostly wondering if I was correct in thinking that (as I put it in the previous post) "1Hz being the most precisely represented frequency, I understand that there would be a loss in representation accuracy of 1/2 in the sampling dimension for every Hz in excess of 1". (1Hz is the most precisely represented, 2Hz is half as precisely represented as 1Hz, etc.) which is the reason why sampling rate must equal double the higest frequency in the finite bandwidth. Otherwise, if the sampling rate is not double the highest frequency in the bandwidth, I perceive that the higher frequencies will not be accurately encoded.

What I perceive the use of oversampling and anti-aliasing does is restore the digital signal to its analog form. (Oversampling brings the signal to a form thats closer to the original analog signal and then, anti-aliasing smoothens the square edges to yield a restored curve).

Quote:

Originally Posted by Garbz
, but much more to do with the analog filter afterwards. I don't know exact details because frankly I do not care for the technology but Non-OS DACs have some information just above 22kHz which needs to be very sharply filtered out, and these filters cause big problems in the (10-20khz) depending on design.

8x oversampling was designed to raise these artifacts up above 352khz and thus now the analog filter can be very basic, very smooth, and above all high enough not to have any impact at 20kHz. Anti-aliasing was brought in to smooth the result of the oversampling filter, to remove the jagged edges IIRC.



I'm not certain I understand what you call the analog filter. Is the analog filter the combination of oversampling and anti-aliasing? (digital in analog out)

digital --(Oversampling)--> jagged analog signal --(Anti-aliasing)--> smoothened analog signal
 
Nov 12, 2006 at 8:51 PM Post #4 of 24
EC: Yup, that's correct - the higher the frequency, the fewer the sample points. Hence at 20 kHz all that remains are roughly two sample points, which - by passing the digital and/or anlogue filter stages (that's also where the jagged to smooth conversion happens, btw) - will always be finally represented as sine wave, however more complicated (e.g. triangular) the original waveform might have looked. Then again, a 20 kHz triangular wave can also be seen as an addition of a 20 kHz sine wave with a couple of higher frequencies - and as those would exceed the bandwith limit of 20 kHz, they simply aren't represented.

Greetings from Munich!

Manfred / lini
 
Nov 12, 2006 at 11:24 PM Post #5 of 24
Quote:

Originally Posted by lini
EC: Yup, that's correct - the higher the frequency, the fewer the sample points. Hence at 20 kHz all that remains are roughly two sample points, which - by passing the digital and/or anlogue filter stages (that's also where the jagged to smooth conversion happens, btw) - will always be finally represented as sine wave, however more complicated (e.g. triangular) the original waveform might have looked. Then again, a 20 kHz triangular wave can also be seen as an addition of a 20 kHz sine wave with a couple of higher frequencies - and as those would exceed the bandwith limit of 20 kHz, they simply aren't represented.

Greetings from Munich!

Manfred / lini




Greetings lini!

Thanks much for the answer! It seems this post is not very popular on the forum
tongue.gif
, but I'm glad you clarified this particular point.

Another quick question for you, what is the usual sequence a signal goes through when going through an oversampling DAC? What I understand is this:

Ditigal --(Oversampling)--> Jagged rectangular analog signal --(Anti-Aliasing)--> Smooth analog signal

Is this correct, are there other steps I'm missing (there probably are)?

Are Oversampling and Anti-Aliasing filters considered analog filters? I would say Anti-Aliasing is but I'm uncertain about Oversampling.

Thanks much again for your help!
rs1smile.gif
 
Nov 13, 2006 at 12:26 AM Post #6 of 24
EC: Oh, well, actually the anti-aliasing filter is already applied beforehand - i.e. what you get on your cd is already limited to 20 kHz max. After the d/a conversion it rather is a reconstruction filter - at the end of which the signal will have to pass an analogue filter for the final smoothing, that could already considered as being a part of the analogue output stage. Whether that's really an extra stage with separate components or one that's integrated into the dac chip doesn't really matter.

Regarding the actual sequence and stages involved, it can be much more complicated - and it will depend on the type of dac, too. Also digital and analogue filtering will often be used together. So you'd probably best go to a few manufacturer sites and check out a few datasheets of a couple of dac and adc chips to learn more. Often enough, one can also find some interesting articles on d/a and a/d conversion there...

Greetings from Munich!

Manfred / lini
 
Nov 13, 2006 at 2:13 AM Post #7 of 24
The analog filter I was mentioning is like lini said a true analog filter. Implimented after the DAC chip itself. I am still not certain how this figure relates to the "stop band attenuation" figure on the DAC chip. Is that digital or analog?

Hahah very confusing indeed. Anyway needless to say a 20khz sine wave looks nothing like a sinewave at 44.1khz
 
Nov 13, 2006 at 2:40 AM Post #8 of 24
I don't know anything about the filters and stuff you're talking about, but any waveform composed of sine waves can be perfectly represented up to 22kHz with a 44kHz sampling rate. It's a misconception that the sample dots are just connected and guessed. Yes, there's only 2 for a 22kHz wave, but this 2 dots is enough to exactly reconstruct the wave. That's how the nyquist theorem works.

The only time a wave couldn't be exactly reconstructed is if it isn't a sine wave because it needs to be represented as a sine wave and it can take frequencies of more than 22kHz to reconstruct that other kind of wave. I don't think this is an issue with music though.
 
Nov 13, 2006 at 4:56 AM Post #9 of 24
Zenja: I don't agree to the "any waveform composed of sine waves can be perfectly represented up to 22kHz with a 44kHz sampling rate" in the first paragraph. It should rather be: The sine waves up to 22 kHz in any waveform can be perfectly represented with a 44 kHz sampling rate. Or: Any waveform can be perfectly represented with a 44 kHz sampling rate, provided the sine waves its composed of don't exceed 22 kHz. Oh, and the outcome is no guesswork, either: The results are clearly determined by the reconstruction filter - the dac delivers discrete levels, the filter will make the connections.

Greetings from Munich!

Manfred / lini
 
Nov 13, 2006 at 5:37 AM Post #10 of 24
Quote:

Originally Posted by lini
Zenja: I don't agree to the "any waveform composed of sine waves can be perfectly represented up to 22kHz with a 44kHz sampling rate" in the first paragraph. It should rather be: The sine waves up to 22 kHz in any waveform can be perfectly represented with a 44 kHz sampling rate. Or: Any waveform can be perfectly represented with a 44 kHz sampling rate, provided the sine waves its composed of don't exceed 22 kHz. Oh, and the outcome is no guesswork, either: The results are clearly determined by the reconstruction filter - the dac delivers discrete levels, the filter will make the connections.

Greetings from Munich!

Manfred / lini



From what I'm understanding, I would have a tendency to agree to agree with lini also, the sentence is upside down
tongue.gif
. Also, although it is theoritically possible to attain a perfect reconstruction, I seriously doubt that such a reconstruction does in fact occur in practice because of drop in resolution at higher frequencies. The higher the frequencies, the more likely aliasing is likely to take place it seems.

Things are starting to make more sense altogether now.

So the DAC delivers a piecewise constant curve (jagged rectangles) and the reconstruction filter smoothens the curve. I thought at first that anti-aliasing was taking care of the smoothing but it obviously isn't the case. What does anti-aliasing do exactly then? I'm not sure I understand it making sense if it's performed before the curve is smoothed out? How does anti-aliasing make sense in a context of piecewise constant curve?
 
Nov 13, 2006 at 6:27 AM Post #11 of 24
Quote:

Originally Posted by Zenja
I don't know anything about the filters and stuff you're talking about, but any waveform composed of sine waves can be perfectly represented up to 22kHz with a 44kHz sampling rate.


It should be mentioned that this is after complex filtering and reconstruction. When I said that a 20khz sine wave looks nothing like a sine wave at 44.1khz I meant if you actually look at the wave form itself in its pulse code modulated form. This is not a surprising outcome seeing how the wave will only have 2 sampling points in it, and the sine function is continuous and not discrete.

Here's what a 20kHz sine looks like at 48kHz, It's a wonder you get anything other than triangles out at the other side. But while it is voodoo to me it does work:
attachment.php
 
Nov 13, 2006 at 8:42 AM Post #12 of 24
Quote:

Originally Posted by Garbz
It should be mentioned that this is after complex filtering and reconstruction. When I said that a 20khz sine wave looks nothing like a sine wave at 44.1khz I meant if you actually look at the wave form itself in its pulse code modulated form. This is not a surprising outcome seeing how the wave will only have 2 sampling points in it, and the sine function is continuous and not discrete.

Here's what a 20kHz sine looks like at 48kHz, It's a wonder you get anything other than triangles out at the other side. But while it is voodoo to me it does work:
attachment.php



Heh, that's that what the output actually looks like. That software is intentionally just connecting the dots with a straight line for some reason. It's not using the nyquist-shannon theorem. Here, I'll take a very zoomed in pic in Cooledit Pro of some music:
nyquist-shannon.png

This is using the algorithm to reproduce the original wave from the samples. As you can see, it's not jagged at all.

Yes, a DAC is going to only receive those dots and not the smoothened, reconstructed form. It's then the job of the DAC to reconstruct it just like the software in the screenshot did.

Quote:

Originally Posted by lini
Zenja: I don't agree to the "any waveform composed of sine waves can be perfectly represented up to 22kHz with a 44kHz sampling rate" in the first paragraph. It should rather be: The sine waves up to 22 kHz in any waveform can be perfectly represented with a 44 kHz sampling rate. Or: Any waveform can be perfectly represented with a 44 kHz sampling rate, provided the sine waves its composed of don't exceed 22 kHz.


I guess I should have worded it differently. That's what I meant. I tried to imply so with what I said after, but I often don't communicate exactly as I want to in writing
smily_headphones1.gif
 
Nov 13, 2006 at 2:07 PM Post #13 of 24
Quote:

Originally Posted by Zenja
Heh, that's that what the output actually looks like. That software is intentionally just connecting the dots with a straight line for some reason. It's not using the nyquist-shannon theorem. Here, I'll take a very zoomed in pic in Cooledit Pro of some music:
nyquist-shannon.png

This is using the algorithm to reproduce the original wave from the samples. As you can see, it's not jagged at all.

Yes, a DAC is going to only receive those dots and not the smoothened, reconstructed form. It's then the job of the DAC to reconstruct it just like the software in the screenshot did.



I guess I should have worded it differently. That's what I meant. I tried to imply so with what I said after, but I often don't communicate exactly as I want to in writing
smily_headphones1.gif



Interresting program. I don't know what your program's functionalities are, but the real test would be to feed it a stream of high frequencies in the range of 22.05Khz to test this particular limit case maybe with a base wave of 60Hz. If it's possible to zoom in enough on a portion of the reconstructed wave, the conclusion I draw from understanding all this is that you would be able to see the difference between the original 22.05Khz + 60Hz analog wave and the reconstructed one in the 22.05Khz range (assuming a sampling frequency of 44.1Khz) after digitally encoding it properly (we could even go 24 bit encoding to make sure and reduce delta errors to a minimum).
 
Nov 13, 2006 at 11:50 PM Post #14 of 24
22.05kHz can not actually be displayed. Nyquests theorm requires the sampling rate to be significantly greater than frequency. Even 21kHz is pushing it with some modulation resulting.

Zenja yeah soundforge connects the dots, I think it's a setting somewhere to smoother over it or whatever. It makes it easier to see when aliasing filters are failing after resampling etc. My frame was of a pure 20kHz signal at -0dB not of music. The fact that there's a curvy line through it or not makes no difference, the location of the dots are the important thing
wink.gif
. The point was a sine function is hard to approximate without more than 2 dots.

As for the comparison:
attachment.php


The top one has a 16:1 zoom, the bottom a 1:1. You can clearly see (or rather can't because the dots are so close together) that a 60hz wave has many samples to approximate it.
 
Nov 14, 2006 at 12:59 AM Post #15 of 24
Quote:

Originally Posted by Garbz
22.05kHz can not actually be displayed. Nyquests theorm requires the sampling rate to be significantly greater than frequency. Even 21kHz is pushing it with some modulation resulting.


Well, the theoritical limit for a perfect reconstruction of signal for a finite bandwidth is to sample at exactly twice the bandwidth.

a sample taken at 44.1Khz can have a frequency resolution of up to 22.05 Khz. 22.05 Khz being represented, in this case, by a maximum of 2 points. Theoritically, the signal can be reproduced perfectly, but in practice, I perceive that aliasing would be a big factor. To be able to cleanly reproduce the higher frequencies, one would have to sample at more than double the bandwidth. This would effectively yield more than 2 points for the higher frequencies which would reduce the aliasing effect. But then again, I'm not fluent in Nyquist so maybe I'm missing something (like a way to resolve aliases to perfectly reproduce the original waveform)
rs1smile.gif
.

Quote:

Originally Posted by Garbz
Zenja yeah soundforge connects the dots, I think it's a setting somewhere to smoother over it or whatever. It makes it easier to see when aliasing filters are failing after resampling etc. My frame was of a pure 20kHz signal at -0dB not of music. The fact that there's a curvy line through it or not makes no difference, the location of the dots are the important thing
wink.gif
. The point was a sine function is hard to approximate without more than 2 dots.

As for the comparison:
attachment.php


The top one has a 16:1 zoom, the bottom a 1:1. You can clearly see (or rather can't because the dots are so close together) that a 60hz wave has many samples to approximate it.



What was your sampling rate? 44.1Khz?

EDIT: Hmmm, I just noticed that you used a sampling rate of 48Khz. I don't understand then because you should easily be able to represent 20Khz (more than only 2 points per Hz). The Nyquist Frequency for a sampling rate of 48Khz is 24Khz and the bandwidth is below 24Khz (only 20Khz).
 

Users who are viewing this thread

Back
Top