Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Sampling rate, Nyquist, file content and mirror images (Read 1653 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Sampling rate, Nyquist, file content and mirror images

Hi,
I've been trying to find the answers to my below questions for some time but couldn't so maybe someone here can help me.

Let's assume we have a 44,1kHz file. For such a file a Nyquist freq would be 22,05kHz.
1. Does thet mean that this file contains a "proper" (according to standard) representation of audio signal up to 22,05kHz?
2. Can this file contain signals above the 22,05? Be it proper audio or noise or hiss or other errors etc. If those signals are there according to Nyquist they would not be "properly represented" or they just can not be properly played by our equipment?
3. Can this file contain signals above the sampling rate - 44,1?
4. If we look at most measuring tools (SPAN or other visualizations) we see that there are some signals up to the Nyquist. But recent foobar plugin called "spectrum Analyzer" has an option to  enable or disable the rendering of the mirror image of the spectrum (Anything above the Nyquist frequency). If this is enabled and the visible area is set to 96kHz we can see that there is information above 22,05kHz but up to 96kHz. What is it? Can there be some musical informations (even if distorted) or would it always be some noise. And can those signals really exceed the actual sampling rate of the file or is it just a visual glitch? In other words is the sampling rate any border for the signal to be carried inside the file (no matter if proper or distorted).

Re: Sampling rate, Nyquist, file content and mirror images

Reply #1
1 Theoretically yes. In practice a filter is not infinite steep, even a brickwall needs some "space". In practive you will see that the filter kicks in at 21 and rolls off fast to make sure there is no signal left before 22.05 is hit.

2 If the input is not band-limited (frequencies above 1/2 fs), the part above 1/2 fs contributes to the sample but can't be reconstructed properly.

4 Playback is another issue. Inherent to the DA conversion is the image, a mirroring of the audio signal starting at 1/2 fs. As it is a artifact it has to be filtered out.
TheWellTemperedComputer.com

Re: Sampling rate, Nyquist, file content and mirror images

Reply #2
It's not "perfect" but neither is our hearing...    A lot of people (including me) don't fully-understand the theory and how it relates to real-world audio. 

But the way I like to state it that the signal can't go over half the sample rate.  I don't say the signal can go up-to half the sample rate.

And to over-simplify it - You need at-least one sample for the top-half and one for the bottom-half of the waveform.   Less than that, you can't get the true waveform and you get aliasing (false lower frequencies).

As for another limitation, there's an "interesting" experiment you can do with Audacity, down at a frequency where you can hear the result -
Generate a 3999Hz signal at a sample rate of 8kHz.    You'll see and hear 1Hz amplitude modulation.     Something similar happens at 1999Hz but you don't get the as much modulation.

Quote
4 Playback is another issue. Inherent to the DA conversion is the image, a mirroring of the audio signal starting at 1/2 fs. As it is a artifact it has to be filtered out.
I had an interesting revelation once - I was doing an experiment with an oscilloscope on a soundcard.    This particular soundcard had no filtering and I could see "nice clean" stair-stepped waveform.   I was shocked!   I had never noticed anything wrong with the sound!    Then I thought about it...   The harmonics and "mirroring" are above the audible range (the sample-rate was probably 44.1kHz), plus the amplifier probably filtered some of the ultrasonics and the speakers certainly "mechanically" filtered them out.

Quote
If we look at most measuring tools (SPAN or other visualizations) we see that there are some signals up to the Nyquist.
There are also limitations/imperfections with FFT when applied to real-world audio.   (Which again, I only partially understand but they mostly relate to time-windowing and the time-varying signal.)

Re: Sampling rate, Nyquist, file content and mirror images

Reply #3
Thak you for your answers.

Reading them I realized that I probably did not ask the right question or I did it in a wrong way.
So I will try and ask them again but differently with possible answers that come to my mind.

Let's assume that humans hear up to 20kHz. Let's gather a band of musicians with instrument that produce sounds up to 20kHz.
Now let's record them but only with sapling frequency of 10kHz.
According to Nyquist all sounds up to 5kHz would be recorded properly.
And now the questions and possible answers:
1. What would happen to frequencies from 5kHz(Nyquist) to 10kHz (sampling rate)?
a. those would not be recorded at all because they exceed Nyquist
b. those would be recorded with errors/distorted because they exceed Nyquist but fit into sampling rate
c. those would be recorded properly because they fit into sampling rate but would be playedback with errors/distorted becasue the exceed Nyquist
d. other possibility that does not come to my mind - what would that be?

2. What would happen to frequencies between 10kHz (sampling rate) and 20kHz (max. frequency produced by the instruments)?
a. those would not be recorded at all because they exceed sampling rate (and/or Nyguist)
b. those would be recorded with errors/distorted because they exceed sampling rate (and/or Nyguist)
c. those would be recorded properly but would be playedback with errors/distorted becasue the exceed sampling rate (and/or Nyguist)
d. other possibility that does not come to my mind - what would that be?


Re: Sampling rate, Nyquist, file content and mirror images

Reply #4
Let's assume that humans hear up to 20kHz. Let's gather a band of musicians with instrument that produce sounds up to 20kHz.
Now let's record them but only with sapling frequency of 10kHz.
According to Nyquist all sounds up to 5kHz would be recorded properly.
And now the questions and possible answers:
1. What would happen to frequencies from 5kHz(Nyquist) to 10kHz (sampling rate)?
a. those would not be recorded at all because they exceed Nyquist
b. those would be recorded with errors/distorted because they exceed Nyquist but fit into sampling rate
c. those would be recorded properly because they fit into sampling rate but would be playedback with errors/distorted becasue the exceed Nyquist
d. other possibility that does not come to my mind - what would that be?
In practice, any ADC would have a low-pass filter, which would filter out anything above 5 kHz (well, most of it anyway). In that case:
  • "According to Nyquist all sounds up to 5kHz would be recorded properly." - yes
  • "a. those would not be recorded at all because they exceed Nyquist" - yes

But let's say you have ADC that doesn't have a low-pass filter. In that case:
  • "According to Nyquist all sounds up to 5kHz would be recorded properly." - no, they would be affected by aliasing of 5-20 kHz frequencies back to 0-5 kHz range.
  • "d. other possibility that does not come to my mind - what would that be?" - they would alias to 0-5 kHz range.

Let's say that your musicians produce only one frequency: 6 kHz. When you record it at 10 kHz sample rate with ADC without low-pass filter then you will get a digital file with 4 kHz frequency in it. That's the alias of 6 kHz.

You can also see that if your musicians played two frequencies: 4 kHz and 6 kHz, then in the resulting file the original 4 kHz would be affected by the alias of 6 kHz.

2. What would happen to frequencies between 10kHz (sampling rate) and 20kHz (max. frequency produced by the instruments)?
Same as above.

Re: Sampling rate, Nyquist, file content and mirror images

Reply #5
In practice, any ADC would have a low-pass filter, which would filter out anything above 5 kHz (well, most of it anyway).
I don't know why I wrote "would" instead of "will" or even just "has".

And to clarify, they have low-pass filter in order to satisfy the conditions of the Sampling Theorem, i.e., the signal you are sampling can only have frequency components less than half the sampling rate.

Re: Sampling rate, Nyquist, file content and mirror images

Reply #6
It is not too difficult really, but I think it is necessary to change the viewpoint.

The Nyquist-Shannon sampling theorem more-or-less says that if and only if you sample a band-limited signal with a sampling frequency twice that of the highest frequency occuring in that signal, it is possible to perfectly reconstruct the signal.

In other words: if you want to eventually be able to reconstruct your signal, you must first use a low-pass filter on the input. If you take sampling frequency of 20kHz, you must low-pass the input so that no frequencies over 20kHz remain.

What happens if you don't? Well, that depends on quite a lot of things. As no perfect filter exists and thus low-passing a signal as required is actually not possible, there is always some form of distortion, but it will always be (much, much) butter than when you don't filter at all.
Music: sounds arranged such that they construct feelings.

Re: Sampling rate, Nyquist, file content and mirror images

Reply #7
Let's assume that humans hear up to 20kHz. Let's gather a band of musicians with instrument that produce sounds up to 20kHz.
Now let's record them but only with sapling frequency of 10kHz.
According to Nyquist all sounds up to 5kHz would be recorded properly.
And this means that all frequencies above or equal 5 kHz should be filtered out before recording.

And now the questions and possible answers:
1. What would happen to frequencies from 5kHz(Nyquist) to 10kHz (sampling rate)?
a. those would not be recorded at all because they exceed Nyquist
b. those would be recorded with errors/distorted because they exceed Nyquist but fit into sampling rate
c. those would be recorded properly because they fit into sampling rate but would be playedback with errors/distorted becasue the exceed Nyquist
d. other possibility that does not come to my mind - what would that be?
d.  6 kHz sine wave will be recorded as 4 kHz sine wave, 7 kHz sine wave will be recorded as 3 kHz sine wave, etc.


2. What would happen to frequencies between 10kHz (sampling rate) and 20kHz (max. frequency produced by the instruments)?
a. those would not be recorded at all because they exceed sampling rate (and/or Nyguist)
b. those would be recorded with errors/distorted because they exceed sampling rate (and/or Nyguist)
c. those would be recorded properly but would be playedback with errors/distorted becasue the exceed sampling rate (and/or Nyguist)
d. other possibility that does not come to my mind - what would that be?
d.  11 kHz sine wave will be recorded as 1 kHz sine wave, 12 kHz sine wave will be recorded as 2 kHz sine wave, etc.

Re: Sampling rate, Nyquist, file content and mirror images

Reply #8
If you take sampling frequency of 20kHz, you must low-pass the input so that no frequencies over 20kHz remain.
You mean low pass at 10kHz.

@wojak : One reason to sample at (say) 96kHz is to make it much easier to remove any frequency components greater than 48kHz prior to the sampler.  For a full audio bandwidth of 20kHz, it is easy to implement an analogue filter which is full gain up to 20kHz and practically zero gain by 48kHz.  Once in the digital domain, DSP techniques can then be used to further bandpass the signal at 22kHz max, and resample the (digital) signal for 44.1kHz CD rate.  This is better than trying to roll off the signal at 22kHz in the analogue domain.
It's your privilege to disagree, but that doesn't make you right and me wrong.

Re: Sampling rate, Nyquist, file content and mirror images

Reply #9
If you take sampling frequency of 20kHz, you must low-pass the input so that no frequencies over 20kHz remain.
You mean low pass at 10kHz.
Yes, indeed. Sorry about that mistake, I was trying to make it clearer but probably made it worse :-[
Music: sounds arranged such that they construct feelings.