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: Digital audio signal bandwidth/capacity, frequency resolution (Read 6466 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Digital audio signal bandwidth/capacity, frequency resolution

One can happily live with basic knowledge of audio and even think that his knowledge is decent, but only this moment I was looking through the window pondering some basic audio concepts and realized that in fact I am stupid, because I can't answer myself these relatively simple questions (feel free to move this topic out of scientific section if you feel so):

  • A fact (Nyquist): at 16 kHz sampling rate I can reproduce 8 kHz sound at max. At 4 Hz I can reproduce 2 Hz sound max.
    A question: can I at 4 Hz sampling rate reproduce 1,5 Hz sound? 1,75 Hz? 1,24587 Hz? At 16 kHz sampling rate, can I reproduce 7,999999 kHz sound? How, if sampling clock has constant tick intervals? If not, what determines the maximum precision/resolution of possible to reproduce frequencies at given sampling rate?
  • A fact (waves): there's no limitation that air may vibrate at only one frequency - single medium may contain complex frequency content. A signal sampled at 16 kHz may contain both 4 kHz & 1 kHz waves.
    A question: what's the limit? How many discrete frequencies can contain a sample of given length at given sample rate? Is it dependent on bit depth? Thinking in bandwidth terms, there must be a limit, because there's no way for a 1 second long mono sample, sampled at 8 kHz & 2 bits to contain more than ~2 KB of data, which is finite. Is the limit related to FFT with window size equal to the number of samples?

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #1
Frequency resolution is determined by the Fourier uncertainty principle for both analog and digital signals.  For your 4hz signal you can resolve arbitrarily narrow frequency widths if you observe for long enough.

Tldr: total bandwidth is sampling rate, frequency resolution is observation time.  Watch 10 cycles and you can measure frequency twice as good as watching 5.

Edit:  A simple link explaining this for digital audio:  https://www.onosokki.co.jp/English/hp_e/c_support/faq/fft_common/fft_general_4.htm

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #2
A fact (Nyquist): at 16 kHz sampling rate I can reproduce 8 kHz sound at max. At 4 Hz I can reproduce 2 Hz sound max.
That's a theoretical limit based on an infinitely steep filter, which would be of infinite length and hence take an infinite time to settle. In reality we are more modest and stay away from the theoretical limit by some margin.

Quote
A question: can I at 4 Hz sampling rate reproduce 1,5 Hz sound? 1,75 Hz? 1,24587 Hz?
Yes, all of those.

Quote
At 16 kHz sampling rate, can I reproduce 7,999999 kHz sound?
In principle, yes, but that would require a rather extreme filter which you probably will find impractical.

Quote
How, if sampling clock has constant tick intervals?
You'd use a reconstruction filter of very high order, which would take almost forever to settle.

Quote
If not, what determines the maximum precision/resolution of possible to reproduce frequencies at given sampling rate?
The question of precision or resolution isn't the same as the question of frequencies that can be reproduced. If you are specifically asking about the precision of frequency, then saratoga gave the answer. The precision depends on how long you are prepared to wait. It's got nothing to do with the nyquist limit.

Quote
A fact (waves): there's no limitation that air may vibrate at only one frequency - single medium may contain complex frequency content. A signal sampled at 16 kHz may contain both 4 kHz & 1 kHz waves.
A question: what's the limit? How many discrete frequencies can contain a sample of given length at given sample rate?
Infinitely many, but you won't be able to tell them all apart. The extreme case is a single sample. It contains all frequencies.

Quote
Is it dependent on bit depth?
No.

Quote
Thinking in bandwidth terms, there must be a limit, because there's no way for a 1 second long mono sample, sampled at 8 kHz & 2 bits to contain more than ~2 KB of data, which is finite. Is the limit related to FFT with window size equal to the number of samples?
If you limit data in this way, you don't get fewer frequencies, you get a reduced ability to tell them apart. Samples don't encode frequencies, they encode amplitudes at specific points in time.

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #3
Can we put some real numbers/calculations in?
In practical terms of everyday equipment: lets say that I connect sine tone generator to line in of my computer, I set recording software to record 1 s at 4 Hz sampling rate and set tone generator to 1,24587 Hz. Then I record another 1 s long infra-beep with tone generator set to 1,246 Hz. If both recordings were roughly synchronized in phase and bit depth was very low, they would be digitally identical. That's because the difference between both frequencies is less than 4/2,56 (where's that 2,56 from? Is it rounded?) or 4/2? Or ...?
Judging by intuition, if bit depth was high enough (lets assume that there's no noise), one would catch the difference in the above 1 s recordings...

P.S.: in my previous post by "samples" I often meant recordings of some length...  sorry for the confusion, these are habits from music creation software...

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #4
Quote
I set recording software to record 1 s at 4 Hz sampling rate and set tone generator to 1,24587 Hz. Then I record another 1 s long infra-beep with tone generator set to 1,246 Hz. If both recordings were roughly synchronized in phase and bit depth was very low, they would be digitally identical.
No, because you'll be sampling each wave at a different point (at a different angle along the sine wave) and you'll get different amplitudes.  

If you wait long enough, the two waveforms will drift in and out of phase and the samples will be significantly different  (i.e. You might be sampling one waveform at 90 degrees and sampling the other waveform at 60 degress, etc.)

As has been said, there is a time-factor, and the more time you have to sample the more (theoretical) accuracy you can get.   Real sound doesn't last long enough to get that kind of accuracy and real soundcards don't do that kind of long-term analysis either.     And thankfully, our ears aren't that good either.  ;)

Quote
1.  A fact (Nyquist): at 16 kHz sampling rate I can reproduce 8 kHz sound at max. At 4 Hz I can reproduce 2 Hz sound max.

A question: can I at 4 Hz sampling rate reproduce 1,5 Hz sound? 1,75 Hz? 1,24587 Hz? At 16 kHz sampling rate, can I reproduce 7,999999 kHz sound?
I like to think about the Nyquist limit as what you can't do, rather what you can do...    That is, you need at least  two samples per cycle to define the waveform, and you absolutely cannot reproduce 8.000001 kHz.

BTW -  If you "get lucky" and you sample at the positive & negative peaks, you can digitize an 8kHz waveform at 16kHz.   If you're unlucky and you sample exactly at all of the zero-crossings and you get nothing. 

Or, you can digitally/mathematically create an 8kHz "waveform" at 16kHz.   (Mathematically, you have to calculate a cosine wave because the sine of zero and 180 degrees is zero.)


P.S.
You can generate near-Nyquist "waveforms" in Audacity, and you'll see some interesting results.   (If you zoom-in you don't see sine waves, you'll see triangle waves because Audacity's display just "connects the dots" with no filtering or reconstruction. ) 

For example, try generating 22049Hz at 44.1kHz and you'll see the modulation of the raw data.   (You can also get "interesting" results at near 1/4 the sample rate.)

If you try the same experiment at a lower sample rate & frequency where you can actually hear the signal, you can hear the modulation as the waveform reconstruction filter in your soundcard does a very-imperfect job near the limit.

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #5
Can we put some real numbers/calculations in?
In practical terms of everyday equipment: lets say that I connect sine tone generator to line in of my computer, I set recording software to record 1 s at 4 Hz sampling rate and set tone generator to 1,24587 Hz. Then I record another 1 s long infra-beep with tone generator set to 1,246 Hz. If both recordings were roughly synchronized in phase and bit depth was very low, they would be digitally identical. That's because the difference between both frequencies is less than 4/2,56 (where's that 2,56 from? Is it rounded?) or 4/2? Or ...?
Judging by intuition, if bit depth was high enough (lets assume that there's no noise), one would catch the difference in the above 1 s recordings...

P.S.: in my previous post by "samples" I often meant recordings of some length...  sorry for the confusion, these are habits from music creation software...

Just do the math for yourself:

Figure out how many degrees apart the samples are for both frequencies and take the sine of the first few samples at each frequency and convert the result into whatever bit depth you want.

I suspect you'll find the resolution is better than you might have guessed.

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #6
In practical terms of everyday equipment: lets say that I connect sine tone generator to line in of my computer, I set recording software to record 1 s at 4 Hz sampling rate and set tone generator to 1,24587 Hz. Then I record another 1 s long infra-beep with tone generator set to 1,246 Hz. If both recordings were roughly synchronized in phase and bit depth was very low, they would be digitally identical. That's because the difference between both frequencies is less than 4/2,56 (where's that 2,56 from? Is it rounded?) or 4/2? Or ...?
Judging by intuition, if bit depth was high enough (lets assume that there's no noise), one would catch the difference in the above 1 s recordings...
Yes, you would get a slight difference in the sample values. But what would that mean?

Note that you have taken 4 samples of a waveform, that had time to complete a bit more than a full period during this time. This means that you haven't sampled a sine wave, you have sampled a short burst of a sine wave. Starting and stopping the sampling is the same as if you had started and stopped the signal itself before taking the samples.

The spectrum of a sine burst does not show sharply defined frequencies, the frequency of the sine wave appears blurred.

If you think that your short piece of sine wave had a narrowly defined frequency, you are actually extending the signal in your mind into infinite time in both directions, but the sampling isn't allowed to see that. You know something that the sampling can't, because you don't give it enough time (i.e enough samples).

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #7
Where is the FAQ on the new HA boards?

Some of it was out of date, but there was a good thread called something like "44.1kHz plethora of distortion". In that thread someone went through all this.

Regards,
David.

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #8
Where is the FAQ on the new HA boards?

Some of it was out of date, but there was a good thread called something like "44.1kHz plethora of distortion". In that thread someone went through all this.
This one?

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #9
Understanding time<->frequency domain relationship is extremely important to understand this whole topic.

What do you think these samples (normalized to +/- 1.0) represent: ... 0, 0, 0, 1, 0, 0, 0 ...?
It's an impulse that contains all frequencies from 0 Hz to fs/2. Guess what you get if you sum cos(2*pi*f*t) from f=0 to fs/2, i.e. all frequencies.

How long do you think a tone needs to be to have exactly one frequency (a non-zero value only at precisely that frequency in the frequency domain)?
Indefinitely long.

Quantization just lowers SNR.
"I hear it when I see it."

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #10
No, because you'll be sampling each wave at a different point (at a different angle along the sine wave) and you'll get different amplitudes.
If you wait long enough, the two waveforms will drift in and out of phase and the samples will be significantly different  (i.e. You might be sampling one waveform at 90 degrees and sampling the other waveform at 60 degress, etc.)
Yes, but in my example there are short recordings with waves being in sync at the start and with very little difference in frequency - at low bit depths they might get quantized to the same values for quite a long time - I wonder if for longer than human hearing would need to tell the difference in case of listening to the original sounds (not necessarily the ones that I gave as an example, which of course are far below human hearing range).
Also, at high enough bit depth it would be possible to catch the difference even on 2nd sample, perhaps it would be enough for a good enough DAC to properly recreate that difference even on relatively short recording?
My confusion comes from the fact that there's nothing about bit depth in relation to the ability of telling the frequencies apart, while in above example intuition says that there could be a relation...
Quote
BTW -  If you "get lucky" and you sample at the positive & negative peaks, you can digitize an 8kHz waveform at 16kHz.   If you're unlucky and you sample exactly at all of the zero-crossings and you get nothing.

P.S.
You can generate near-Nyquist "waveforms" in Audacity, and you'll see some interesting results.   (If you zoom-in you don't see sine waves, you'll see triangle waves because Audacity's display just "connects the dots" with no filtering or reconstruction. ) 

For example, try generating 22049Hz at 44.1kHz and you'll see the modulation of the raw data.   (You can also get "interesting" results at near 1/4 the sample rate.)

If you try the same experiment at a lower sample rate & frequency where you can actually hear the signal, you can hear the modulation as the waveform reconstruction filter in your soundcard does a very-imperfect job near the limit.
Yes I'm aware of imperfectness of simply "connecting the dots" on graphical representations of PCM and that there's quite some magic happening in the DACs, including cases where it's possible to get out of digital peak range.
How can "safe Nyquist distance" be calculated for today equipment? I know that CDDA should be lowpass filtered at ~20kHz...
The spectrum of a sine burst does not show sharply defined frequencies, the frequency of the sine wave appears blurred.

If you think that your short piece of sine wave had a narrowly defined frequency, you are actually extending the signal in your mind into infinite time in both directions, but the sampling isn't allowed to see that. You know something that the sampling can't, because you don't give it enough time (i.e enough samples).
That's something important to know, thanks.
But can it be said that it's a kind of deficiency of sampling? Can human hearing tell the difference of "real" sounds faster in comparison to some bad case of ADA or DA conversion (by bad case I mean "Nyquist correct" but of low sampling rate, low bit depth, and/or relatively short time)?
Quantization just lowers SNR.
Can it be said that on lower bit depths lower SNR makes it harder to tell the frequencies apart?

And coming back to the 2nd point of my original post, let me rephrase it: how can one calculate the limit of number of possible to tell apart frequencies of PCM data of given sampling rate/length/bit depth? Lets assume that the PCM data is a "recording" of a bunch of constant sine beeps, without any meaningful amplitude modulation in time (i.e. the beeps don't have any meaningful envelope).

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #11
Yes, but in my example there are short recordings with waves being in sync at the start and with very little difference in frequency - at low bit depths they might get quantized to the same values for quite a long time - I wonder if for longer than human hearing would need to tell the difference in case of listening to the original sounds (not necessarily the ones that I gave as an example, which of course are far below human hearing range).

Keep in mind your example is the special case of two perfect sin waves (infinitely narrow bandwidth signals) and furthermore you presume that the bandwidth of each signal is known in advance (just not the center frequencies).  This is a special case of the more general time/frequency resolution tradeoff for which is it possible to estimate the center frequency (which is just a single parameter) with extreme accuracy because of all the prior knowledge (specifically that all other frequencies are zero).

Also, at high enough bit depth it would be possible to catch the difference even on 2nd sample, perhaps it would be enough for a good enough DAC to properly recreate that difference even on relatively short recording?

Of course.  You have only two unknowns.  You only need two samples to solve that algebraic equation, at least under the presumption of infinite SNR and zero bandwidth. 

My confusion comes from the fact that there's nothing about bit depth in relation to the ability of telling the frequencies apart, while in above example intuition says that there could be a relation...

That is because your question and your example are different problems.  In your example you have prior knowledge that makes the estimation process very simple.  In time frequency analysis, you very rarely have such perfect prior knowledge. 

And coming back to the 2nd point of my original post, let me rephrase it: how can one calculate the limit of number of possible to tell apart frequencies of PCM data of given sampling rate/length/bit depth?

See the link in the first reply to this thread. 

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #12
Again, you need to understand time<->frequency domain relationship. There's a physical, mathematical, even logical limit. Go ahead and paint a 10ms long 10 Hz tone... If you don't understand the relationship you will never understand digital audio.

Also, human hearing is limited. Short tones don't sound like tones anymore, but more like thumps.
Small changes in frequency are imperceptible. That's true for long tones and even more so for short ones. You'd be surprised how bad your hearing is. :P Two tones with just a tiny frequency difference are also imperceptibly different from a single tone (at the same amplitude of course).
...

Sure, when you are close to the noise floor then the waveform will look and sound differently - noisy, duh - but you will still hear a difference in frequency, if the tones are long enough and the frequency difference large enough for your hearing.
"I hear it when I see it."

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #13
Where is the FAQ on the new HA boards?

Some of it was out of date, but there was a good thread called something like "44.1kHz plethora of distortion". In that thread someone went through all this.
This one?
That's the one, thanks. Still worth a read.

Re: Digital audio signal bandwidth/capacity, frequency resolution

Reply #14
There are two issues here.  One is determining the frequency of an unknown signal. That is dependent on observation length.

The other is determining two very similar signals both of which are known. THAT depends also on SNR, since you can compare the two known signals to the data.
-----
J. D. (jj) Johnston