HydrogenAudio

Hydrogenaudio Forum => Scientific Discussion => Topic started by: DonP on 2012-02-16 16:13:36

Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: DonP on 2012-02-16 16:13:36
Each of the additional waves only needs a couple of points to represent their frequency. As per usual it appears that CA article really doesn’t get what the Nyquist theorem is saying…
....
The whole point is that a perfect DAC will produce a perfect 8kHz signal when sampled at 16kHz.


This key mistake in citing the Nyquist theorem leads to no end of potential trouble.  The sampling frequency has to be greater than 2x the maximum signal frequency you want to reproduce.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: icstm on 2012-02-17 10:35:06
Each of the additional waves only needs a couple of points to represent their frequency. As per usual it appears that CA article really doesn’t get what the Nyquist theorem is saying…
....
The whole point is that a perfect DAC will produce a perfect 8kHz signal when sampled at 16kHz.


This key mistake in citing the Nyquist theorem leads to no end of potential trouble.  The sampling frequency has to be greater than 2x the maximum signal frequency you want to reproduce.
agreed, but what people do not understand is that this leads to a perfect storage of the signal (within the quantum of the bits storing the amplitude. It is not an approximation that improves with higher sampling.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: db1989 on 2012-02-17 19:47:34
The point was that you stated that a signal of n Hz can be perfectly represented by a sampling rate of 2n Hz, but that in fact this requires >2n Hz.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: pdq on 2012-02-17 20:08:34
As a further qualification, how close you can come to 2n Hz is a function of the period over which you observe the waveform. As you approach 2n Hz, the required time approaches infinity.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: greynol on 2012-02-17 20:09:33
Put another way it is impossible to know with any certainty the amplitude of a pure tone with only two regularly spaced points per cycle.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: [JAZ] on 2012-02-18 09:12:52
While I agree that this is a scientific-based forum and that it is adequate to correct this small imprecision that we're used to say (as in saying only 2x instead of >2x)....

... can we stop arguing about it at last? There's been what, already 5 posts about it?

Back on topic, the number was mentioned in relation to the fact that the frequency can be properly reconstructed from the sampled one, which is something that we all agree on. For this, the images posted by xnor are quite representable of that fact.

We can talk about the needed time in case of frequencies nearing half the sampling rate, like pdq's last post, but let's stop talking about ">" versus ">=".
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2012-02-18 11:11:33
Time for the graph at http://i238.photobucket.com/albums/ff228/j...ots/imaging.jpg (http://i238.photobucket.com/albums/ff228/jj_0001/plots/imaging.jpg)

This shows in the first plot a sine wave a bit below fs/2.

As you go down, the red is the sum of the first 2, next 2, next 2 and next ?100? I think (the plot was made with a different script may years ago) images, and the resulting waveform with the images, all of them over fs/2, is shown behind the red waveform.

Notice how only images cause it to square off.

I'm not going to figure out the amplitudes for a triangle right here and now today (it should be easy, of course) but you're welcome to take script below, which is an enhanced version of the one that made the plot above, fix it, and pot that here.

But I think this makes the point that drawing striaght lines around plots of incividual samples doesn't show what a lot of people think it does.


Code: [Select]
clear all;
close all;
fclose all;
clc;

len=8192;

f0= 2*pi* .4;

fs=2*pi;

overs=512;

w0=f0/overs;
ws=fs/overs;

ax=[ 1 len -1.5 1.5];

iter(1:len)=(0:len-1);
t=w0/ws*pi;
amp=sin(t)/t;
x(1:len)=amp*cos(iter*w0);

subplot(5,1,1)
plot(x,'k');
axis( ax );

# first image pair

wl=ws-w0;
wh=ws+w0;

tmp(1:len)=0;
t=wl/ws*pi;
amp=sin(t)/t;
tmp=tmp+amp*cos(iter*wl);
t=wh/ws*pi;
amp=sin(t)/t;
tmp=tmp+amp*cos(iter*wh);

subplot(5,1,2)
x=x+tmp;
plot(x,'k');
axis(ax);
hold on;
plot(tmp,'r');
hold off;


wl=2*ws-w0;
wh=2*ws+w0;

tmp(1:len)=0;
t=wl/ws*pi;
amp=sin(t)/t;
tmp=tmp+amp*cos(iter*wl);
t=wh/ws*pi;
amp=sin(t)/t;
tmp=tmp+amp*cos(iter*wh);

subplot(5,1,3)
x=x+tmp;
plot(x,'k');
axis(ax);
hold on;
plot(tmp,'r');
hold off


wl=3*ws-w0;
wh=3*ws+w0;

tmp(1:len)=0;
t=wl/ws*pi;
amp=sin(t)/t;
tmp=tmp+amp*cos(iter*wl);
t=wh/ws*pi;
amp=sin(t)/t;
tmp=tmp+amp*cos(iter*wh);

subplot(5,1,4)
x=x+tmp;
plot(x,'k');
axis(ax);
hold on;
plot(tmp,'r');
hold off;


tmp(1:len)=0;

for ii=4:1000
wl=ii*ws-w0;
wh=ii*ws+w0;


t=wl/ws*pi;
amp=sin(t)/t;
tmp=tmp+amp*cos(iter*wl);
t=wh/ws*pi;
amp=sin(t)/t;
tmp=tmp+amp*cos(iter*wh);
end

subplot(5,1,5)
x=x+tmp;
plot(x,'k');
axis(ax);
hold on;
plot(tmp,'r');
hold off;
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: db1989 on 2012-02-18 19:40:37
(as in saying only 2x instead of >2x)....

... can we stop arguing about it at last?

Who’s arguing about anything? Subsequent posts just elaborated upon the original correction—which, as DonP said in the first instance, is a very important one.

Quote
There's been what, already 5 posts about it? […] let's stop talking about ">" versus ">=".

Since it apparently offends you so much, perhaps you would like it to be split to a separate thread. Edit: Which I have just done. Also, somehow I had thought DonP was pawelq!
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: pdq on 2012-02-19 04:16:57
If you know that the waveform consists of a single unvarying sine wave whose frequency is less than half the sampling rate then a fairly small number of data points are required to determine the waveform's frequency and amplitude.

On the other hand, if there are multiple frequencies or the amplitude is not constant then you will need a longer observation period.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: greynol on 2012-02-19 19:29:35
On the other hand, if there are multiple frequencies or the amplitude is not constant then you will need a longer observation period.
A signal consisting of a tone with varying amplitude is not a pure tone.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: pdq on 2012-02-19 20:00:03
A signal consisting of a tone with varying amplitude is not a pure tone.

I understand that. On the other hand, a tone that is not infinite in duration is also not a pure tone.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Speedskater on 2012-02-20 02:02:46
On the other hand, if there are multiple frequencies or the amplitude is not constant then you will need a longer observation period.

We can't assign a single frequency to this type of waveform.
The amplitude may very depending on how the multiple frequencies sum.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: 2Bdecided on 2012-02-20 11:32:17
If you know that the waveform consists of a single unvarying sine wave whose frequency is less than half the sampling rate then a fairly small number of data points are required to determine the waveform's frequency and amplitude.

On the other hand, if there are multiple frequencies or the amplitude is not constant then you will need a longer observation period.
For any arbitrary waveform, correctly sampled, you can reconstruct all frequency components under fs/2 perfectly - but you need an infinite number of sample points.

If we consider quantisation it's far worse.

If however we consider that we don't care about anything beyond ~120dB down, it becomes easily realisable in 1990s-style DSP.

I know everyone here knows this. That computeraudiophile thread is just a parallel universe which I don't want to enter

Cheers,
David.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: icstm on 2012-02-20 12:06:03
If you know that the waveform consists of a single unvarying sine wave whose frequency is less than half the sampling rate then a fairly small number of data points are required to determine the waveform's frequency and amplitude.

On the other hand, if there are multiple frequencies or the amplitude is not constant then you will need a longer observation period.
For any arbitrary waveform, correctly sampled, you can reconstruct all frequency components under fs/2 perfectly - but you need an infinite number of sample points.
when you say an infinite number of sample points, over what period? An infinite number of sample points with 1sec, IS a higher sampling rate! An infinite number of points over an infinite is surely just handling the tails?
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Arnold B. Krueger on 2012-02-20 12:59:48
If you know that the waveform consists of a single unvarying sine wave whose frequency is less than half the sampling rate then a fairly small number of data points are required to determine the waveform's frequency and amplitude.

On the other hand, if there are multiple frequencies or the amplitude is not constant then you will need a longer observation period.
For any arbitrary waveform, correctly sampled, you can reconstruct all frequency components under fs/2 perfectly - but you need an infinite number of sample points.

If we consider quantisation it's far worse.

If however we consider that we don't care about anything beyond ~120dB down, it becomes easily realisable in 1990s-style DSP.

I know everyone here knows this. That computeraudiophile thread is just a parallel universe which I don't want to enter


Whenever infinity is mentioned, the temptation to become pedantic can be overpowering. Take this for exactly a pedantic question, because that is what it it is.

Isn't infinity an indefinite number? That's what I was taught in first semester calculus 48 years ago, if memory serves.  I'm under the impression from my work in calculus through grad school that equations involving infinity only make sense if you talk about infinity as the limit. IOW, a sampled wave approaches perfection as the number of sampled points approaches infinity.

In the real world nothing is perfect, and significance and relevance should be our greatest interest. As I think about it, in audio the number of sample points and the numerical precision of those samples are not serious limiting issues in our best or even mediocre currently implemented systems.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2012-02-21 09:36:39
If you know that the waveform consists of a single unvarying sine wave whose frequency is less than half the sampling rate then a fairly small number of data points are required to determine the waveform's frequency and amplitude.

On the other hand, if there are multiple frequencies or the amplitude is not constant then you will need a longer observation period.
For any arbitrary waveform, correctly sampled, you can reconstruct all frequency components under fs/2 perfectly - but you need an infinite number of sample points.


Ok, if you have 'n' samples, you'll get n/2+1 distinct lines out of a DFT.  Given positive and negative frequencies, you get n, exactly, as one would expect (depending on how you wish to count complex, of course).

You do need order of 1/df time for df being how close to fs/2 in Hertz you are, i.e. df = fs/2 - fmax where fs is sampling frequency and fmax is the highest frequency in the material.

It's order 1/df because that's the best you can do.  But you won't do much worse than 10 times that at any reasonable SNR.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: 2Bdecided on 2012-02-21 11:14:01
In the real world nothing is perfect, and significance and relevance should be our greatest interest. As I think about it, in audio the number of sample points and the numerical precision of those samples are not serious limiting issues in our best or even mediocre currently implemented systems.
I agree entirely.

I think brick wall filters are both vilified and lauded unnecessarily. Wrongly vilified, because you can't hear their action. Wrongly lauded, because any filter that you can't hear when applied twice, but is sufficiently down at fs/2 and above, is good enough for ADC and DAC.

Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: 2Bdecided on 2012-02-21 11:20:22
Ok, if you have 'n' samples, you'll get n/2+1 distinct lines out of a DFT.  Given positive and negative frequencies, you get n, exactly, as one would expect (depending on how you wish to count complex, of course).

You do need order of 1/df time for df being how close to fs/2 in Hertz you are, i.e. df = fs/2 - fmax where fs is sampling frequency and fmax is the highest frequency in the material.

It's order 1/df because that's the best you can do.  But you won't do much worse than 10 times that at any reasonable SNR.
When I first read this, I was a bit uncomfortable with the straight connection you made between a DFT and what frequencies you can store/reconstruct. I thought "what about windowing / glitches / non-periodic etc issues?". Still a bit concerned that what the DFT tells you is what is present if you loop the samples you have ad infinitum, but other than that I think I agree. As I'm not even worthy to polish your shoes I have no choice to agree anyway , but I had to stop and think for a bit.

Cheers,
David.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2012-02-21 20:12:02
When I first read this, I was a bit uncomfortable with the straight connection you made between a DFT and what frequencies you can store/reconstruct. I thought "what about windowing / glitches / non-periodic etc issues?". Still a bit concerned that what the DFT tells you is what is present if you loop the samples you have ad infinitum, but other than that I think I agree. As I'm not even worthy to polish your shoes I have no choice to agree anyway , but I had to stop and think for a bit.

Cheers,
David.


You're absolutely right that by just taking a DFT you're imposing circularity, and by doing so, you're incorporating any end-discontinuities, i.e. you're using a rectangular window (same thing).

But you still have the stated number of frequencies, it just includes information you probably didn't want.

If you window, you don't have quite the resolution you would otherwise have, but you get more "far frequency" resolution, of course, i.e. you don't have that end discontinuity splashing things all over the place.

It's fun to plot rectangular vs. han vs. blackman vs. some kaiser window, plot two things, first plot the passband to .5dB or so, and then plot the far-frequency response. Unsurprisingly you find lots of differences, but what they are can be surprising.  The narrowest passband is rectangular, if you think about it, that's because it has the widest scope (don't forget df * dt > 1 for the problem we're talking about here).  But, of course, you have that horrid far-frequency response. The blackman is wider than most anything, but yessiree it falls off like a brick... Perhaps unsurprisingly there is a conservation happening. Life is like that
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2012-02-21 20:23:01
I think brick wall filters are both vilified and lauded unnecessarily. Wrongly vilified, because you can't hear their action. Wrongly lauded, because any filter that you can't hear when applied twice, but is sufficiently down at fs/2 and above, is good enough for ADC and DAC.


Well, something fun to try. Build the sharpest 20kHz passband filter you can with whatever FIR design program you have available.

Not one that goes 20kHz passband, 22kHz stop band, but as sharp as your software will design.

Then filter castinetts with it and see what happens. Use ABX, of course. Just give it a try.

Note, I just tried this in octave. remez in octave needs work
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: xnor on 2012-02-21 21:59:36
I tried this and couldn't hear any difference.

edit: used a linear phase fir filter, 200 dB down at ~21.6 kHz
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2012-02-22 17:07:51
I tried this and couldn't hear any difference.

edit: used a linear phase fir filter, 200 dB down at ~21.6 kHz


How long? Try 90dB down and as sharp as you can make it.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: xnor on 2012-02-22 18:20:22
Even a 8192 samples long filter doesn't cause anything I could hear. Maybe because the passband has to be a lower to make the filter audible, e.g. 18 kHz instead of 21 kHz? Anyway the filter is quite steep. -6 dB at 21 kHz and -90 dB at 21.0157 kHz.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Porcus on 2012-02-22 18:41:53
Isn't infinity an indefinite number? That's what I was taught in first semester calculus 48 years ago, if memory serves.  I'm under the impression from my work in calculus through grad school that equations involving infinity only make sense if you talk about infinity as the limit. IOW, a sampled wave approaches perfection as the number of sampled points approaches infinity.


Well, in first-semester calculus, infinity is not a number at all. In higher courses, it might even be treated just as a number. Now you are talking about 'the' limit, and that 'the' is not necessarily a unique concept (first-semester calculus may or may not involve the distinction between pointwise and uniform limits).

For each given frequency < half the sampling frequency, a sine wave on time interval [-T, T] will be sampled better as T grows, and -- in the appropriate sense -- tend to perfection.
But:
Fix the time interval [-T,T] and let the frequency increase to half the sampling frequency. Then the sample quality tends to pretty bad. (And no, you don't have do do a sweep.)

So transients near the Nyquist may be badly sampled, in principle. But even if you can hear 22.05, it does not mean that you will hear that this is bad -- this physiology issue beats me, but: do you really hear a tone before the hair cells in the  inner ear have reached a steady resonance with the sound? That takes some oscillations, sampler takes some oscillations to pick up the frequency, wouldn't it?
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: greynol on 2012-02-22 18:49:22
That takes some oscillations, sampler takes some oscillations to pick up the frequency, wouldn't it?

No, it wouldn't.  A simple impulse will set them in motion, just like any other mechanical device.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: pdq on 2012-02-22 18:52:35
I recall a study in which members of an orchestra were asked to compare two tones very close in frequency (I think it was A440).

Many of the members were able to distinguish tones only 1 Hz apart, and one member was able to distinguish tones only 0.1 Hz apart.

I then ask myself, did he need to hear the tones for a full ten seconds each so that there was one full cycle difference between them?
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: greynol on 2012-02-22 18:54:21
Regarding what happens at the edges, sinc pulses die out fairly rapidly, don't they; especially when realistic levels are taken into account?
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2012-02-22 19:25:29
Even a 8192 samples long filter doesn't cause anything I could hear. Maybe because the passband has to be a lower to make the filter audible, e.g. 18 kHz instead of 21 kHz? Anyway the filter is quite steep. -6 dB at 21 kHz and -90 dB at 21.0157 kHz.


You want to make the filter as steep as possible, not with as much rejection as possible. If I had access to matlab right now I'd give you firpm paramaters, but I tried what I recall in octave via remez and it just died instead.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2012-02-22 19:27:18
I recall a study in which members of an orchestra were asked to compare two tones very close in frequency (I think it was A440).

Many of the members were able to distinguish tones only 1 Hz apart, and one member was able to distinguish tones only 0.1 Hz apart.

I then ask myself, did he need to hear the tones for a full ten seconds each so that there was one full cycle difference between them?


Different problem than you're thinking of for frequency determination, you have here a fixed reference, and a high SNR environment to determine match or not.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: xnor on 2012-02-22 20:07:43
You want to make the filter as steep as possible, not with as much rejection as possible. If I had access to matlab right now I'd give you firpm paramaters, but I tried what I recall in octave via remez and it just died instead.

It doesn't get much steeper than that with 8192 samples. I used a windowed sinc filter (Fc=21 kHz) and chose the best window function I could find to give about 90 dB rejection - not more - in my second try. Diffing the original file with the filtered one leaves some high frequency, low level ringing behind. Can't hear that either at normal levels.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: bandpass on 2012-02-22 21:57:10
Regarding what happens at the edges, sinc pulses die out fairly rapidly, don't they; especially when realistic levels are taken into account?

Not really; it's because they they die out slowly that we need to window them to make reasonably-lengthed filters.

You want to make the filter as steep as possible, not with as much rejection as possible. If I had access to matlab right now I'd give you firpm paramaters, but I tried what I recall in octave via remez and it just died instead.

You can use sox to create some sharp FIRs (if you're happy to use a slightly longer filter than remez/firpm would give); e.g.

Code: [Select]
sox castanets-2_2496.wav output.wav sinc -a 90 -n 32767 -21k


For 90dB attenuation low-pass, 32767 taps, 6dB corner @ 21kHz; which gives a TBW of 16.6Hz.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Porcus on 2012-02-22 23:04:26
A simple impulse will set them in motion, just like any other mechanical device.

That is not to say that this 'motion' can be used to detect a frequency.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2012-02-23 04:00:04
For 90dB attenuation low-pass, 32767 taps, 6dB corner @ 21kHz; which gives a TBW of 16.6Hz.


What I'm thinking of and trying to build is a remez-designed filter with a cutoff frequency of 20kHz and a -90dB point of about 20050 (not 22050!) Hz. I managed do that after some fiddling in Matlab. No such luck in octave.

I'm not saying that it's a good idea to use such a filter, to be sure.

It's also possible to make a "bad" filter by having too much passband ripple, but that's kind of cheating.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: icstm on 2012-02-23 10:16:49
You want to make the filter as steep as possible, not with as much rejection as possible. If I had access to matlab right now I'd give you firpm paramaters, but I tried what I recall in octave via remez and it just died instead.
That brings back memories, problem is I cannot remember any of it now. I would probably have to review my own code (I became quite good to commenting my code to read like pseudo code, which should hopefully help me now). Now all I need to do is dig out my old 10-yr old PC that should still have a copy of MatLab...
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: bandpass on 2015-04-10 16:07:23
Well, something fun to try. Build the sharpest 20kHz passband filter you can with whatever FIR design program you have available.

Not one that goes 20kHz passband, 22kHz stop band, but as sharp as your software will design.

Then filter castinetts with it and see what happens. Use ABX, of course. Just give it a try.
...
What I'm thinking of and trying to build is a remez-designed filter with a cutoff frequency of 20kHz and a -90dB point of about 20050 (not 22050!) Hz.

I've been trying this with a remez design of Fp=20000, Fs=20001, and dp=ds=–90dB, which gives a filter around 5 seconds long.

Nothing bad happens AFAICT—I can't ABX it with castanets.

Dunn's pre/post echos (http://www.nanophon.com/audio/antialia.pdf) can be heard by cranking up the volume, but they are a further 6dB below the nominal rejection level, so nothing untoward.

Samples & filter coefficients (@ 44100, 48k, & 96k) are here (https://dl.dropboxusercontent.com/u/8835547/lpf.zip) if anyone wants to play.

(http://i59.tinypic.com/4v5nqo.png)
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Wombat on 2015-04-10 16:50:03
Nothing bad happens AFAICT—I can't ABX it with castanets.

Nice pics for illustrating the frequencies of ringing, better as this impulse crap we see elsewhere.
Since the strong ringing happens at 20kHz it should be not touched by the filter of the DAC playing it back.
If this isn't abxble what is?
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: krabapple on 2015-04-10 18:50:11
Nothing bad happens AFAICT—I can't ABX it with castanets.

Nice pics for illustrating the frequencies of ringing, better as this impulse crap we see elsewhere.
Since the strong ringing happens at 20kHz it should be not touched by the filter of the DAC playing it back.
If this isn't abxble what is?


Well we don't absolutely know that 'this isn't abxable'.

False negatives, and all that  ;>
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: greynol on 2015-04-10 19:11:15
We could pull a ten year old off the street.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Wombat on 2015-04-10 19:50:01
I don't want to hijack this thread to much but this talk about ringing everywhere makes me wonder.
You can't argue much about it. To many audiophiles and people insist on this is what matters most with HiBitrate music.
Archimago lately did some about how software is handling dsd conversion.
dsd encoders (http://archimago.blogspot.de/2015/04/analysis-dsd-decoders-2015-windows-mac.html)
Unfortunately on his blog everyone can add his own view. You see jk_audio rates the dsd conversation to 24/96 on the amount of ringing as it was the most well understood thing in audio.
For a 96kHz samplerate this means no matter how the funny impulse picture looks like it only is slight noise at the filters edge.
To me this means if some low noise at frequencies way above our hearing damage sound it may be better to record nothing at all above 20kHz.
I feel a bit lost arguying about these things and slightly seem to get paranoid about 'RINGING' because i find nothing that convinces me at all.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: ExUser on 2015-04-10 21:06:56
"Ringing" is an arbitrary term we've assigned to a visually-perceived phenomenon. I believe that claims of ringing's audibility are strongly overstated. Perhaps some of the more savvy folks will clue me in here.

What "audiophiles and people" claim is irrelevant to what is actually true. My experience is that when "audiophiles" talk about a phenomenon that is visually-apparent but I struggle to even perceive audibly, the audiophiles are most likely out to lunch.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: greynol on 2015-04-10 21:12:45
Audibility depends on the frequency (wrt human thresholds) and the signal being filtered.  In the case of Meridian et. al, I'm not buying it.

One can argue that terms are arbitrarily chosen for all kinds of phenomena.  In the case of filters, I believe it is aptly chosen.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Arnold B. Krueger on 2015-04-11 13:42:23
Put another way it is impossible to know with any certainty the amplitude of a pure tone with only two regularly spaced points per cycle.



Another way to look at it is that as the sampled frequency closely approaches the Nyquist frequency, the tone burst fidelity decreases considerably.

Here are some examples of the same downsampling from 2496 to 1644, but with vastly different width transition bands

Link to pictures in the uploads forum (http://www.hydrogenaud.io/forums/index.php?showtopic=107570&view=findpost&p=895418)
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: xnor on 2015-04-11 18:39:26
There is actually very simple way to explain why this is:

Imagine a single sine wave cycle: it starts out at 0, rises to +1 (at 90°), drops to 0 again (180°), drops further to -1 (270°), rises to 0 again (360°).
(http://www.rasmus.is/uk/t/F/Su36k03_m04.gif)

If you take just 2 samples starting at 90° we get (+1, -1) and everything is fine, right? Well, what if we start a 0° or 180° ... we get (0, 0) which is digital silence, and not a tone.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: krabapple on 2015-04-12 02:18:23
I don't want to hijack this thread to much but this talk about ringing everywhere makes me wonder.
You can't argue much about it. To many audiophiles and people insist on this is what matters most with HiBitrate music.
Archimago lately did some about how software is handling dsd conversion.
dsd encoders (http://archimago.blogspot.de/2015/04/analysis-dsd-decoders-2015-windows-mac.html)
Unfortunately on his blog everyone can add his own view. You see jk_audio rates the dsd conversation to 24/96 on the amount of ringing as it was the most well understood thing in audio.


you mean  jr_audio.

freudian slip there? ;>


All I'll say about that thread is, Archimago is being very polite.  I see Oohashi et al. and the 'hypersonic effect' have made their predictable entrance 
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: greynol on 2015-04-12 03:30:50
If you take just 2 samples starting at 90° we get (+1, -1)

What if I had sampled that sine wave at 30 and 210 and gave you the data.  How do you know how loud it was initially?
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2015-04-12 06:00:54
Waaaiiittt.

When dealing with anything close to FS/2, you have to consider, carefully, what the bandwidth of the signal you're putting in actually is.

If it's one cycle of a sine wave, like you all keep talking about, that has an enormous bandwidth, not just a line at the frequency of the sine wave that was windowed.

It's all about the input bandwidth. If it's over fs/2 weird stuff happens. No more, no less.

Because of the requirement for filtering, the closer you get to fs/2, the more delay you must have in a filter. At fs/2 the delay goes to infinity.

It's that simple. Really.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: splice on 2015-04-12 08:45:40
We could pull a ten year old off the street.


I see what you did there. Or just another Freudian slip?
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Arnold B. Krueger on 2015-04-12 13:17:38
If you take just 2 samples starting at 90° we get (+1, -1)

What if I had sampled that sine wave at 30 and 210 and gave you the data.  How do you know how loud it was initially?


As we all know that's the point. Given only two values for samples along a wave, and an infinite number of different wave frequencies, phase shifts, and amplitudes can fit them.

Given 3 points, or even just slightly more than 2 points, and those values define exactly one combination of frequency, phase, and amplitude.

The only wave form that can be accurately reproduced just below a brick wall filter's corner frequency is a pure sine wave.

Apply any signal you want to a good digital channel, but only modulated sine waves will be passed above half Nyquist. 

As those sine waves frequencies approach Nyquist, smaller and smaller proportions of any modulation of the sine wave will be accurately reproduced.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: xnor on 2015-04-12 13:18:21
What if I had sampled that sine wave at 30 and 210 and gave you the data.  How do you know how loud it was initially?

Exactly, you get this ambiguity with any amount of phase shift. Starting at 0° resulting in silence was the extreme example of that.

But you can use an alternating sequence of +1, -1. You could for example turn it into a FIR filter, a high pass, by attenuating it such that your gain is 0 dB at Fs/2. Here's a thought experiment: what happens if we approach an infinitely long sequence ...


If it's one cycle of a sine wave, like you all keep talking about, that has an enormous bandwidth, not just a line at the frequency of the sine wave that was windowed.

Yes, of course, but only if the amplitude was zero outside that range of the single cycle.

In the image I posted the sine continues with a dashed line in both directions, so interpret that 'single cycle' as just looking at a section of a pure tone of infinite duration.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: [JAZ] on 2015-04-12 15:05:29
Yes, of course, but only if the amplitude was zero outside that range of the single cycle.

In the image I posted the sine continues with a dashed line in both directions, so interpret that 'single cycle' as just looking at a section of a pure tone of infinite duration.

This concrete discussion needs not take any longer. The theorem only guarantees signals >2Fs, not >=2Fs. Basically, if the sampled frequency is smaller than the sampling frequency, after some amount of time, all the possible points have been sampled.
If it is exactly 2F, this cannot happen, and only when knowing the phase (and this one not being 0 or 180degree), it might get reconstructed. (which is a special case that resamplers do not contemplate) . Actually, no, it cannot either, you need another assumption which is knowing the signal,and if you know the signal, you've "sampled" it in some other way. (Although, in fact, it can only be a sine, because any other signal would have been theoretically filtered away due to the Sampling frequency cutoff)
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: greynol on 2015-04-12 16:06:52
We could pull a ten year old off the street.


I see what you did there. Or just another Freudian slip?

Pull as in pull into a test, or simply replace with poll.  This would be with proper consent; I certainly don't want people to think that I'm suggesting kidnapping.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: xnor on 2015-04-12 18:01:30
Well, JAZ, you can theoretically create a tone at Fs/2, but there will be no phase information. Using the DFT to calculate the Nyquist bin, you will get a sum of the samples multiplied by effectively exp(-i*pi*n), which is alternating +1+0i, -1+0i, so a phase of zero. So it's similar to the DC bin.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2015-04-15 16:48:43
Look, the only way you can do fs/2 is if the signal is infinitely long, which of course does not exist in the real world. Otherwise its bandwidth extends beyond fs/2 well over quantizing levels.

This really isn't rocket science.

Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Arnold B. Krueger on 2015-04-15 21:18:14
What I'm thinking of and trying to build is a remez-designed filter with a cutoff frequency of 20kHz and a -90dB point of about 20050 (not 22050!) Hz.

Quote

I've been trying this with a remez design of Fp=20000, Fs=20001, and dp=ds=–90dB, which gives a filter around 5 seconds long.


Nothing bad happens AFAICT—I can't ABX it with castanets.


Samples & filter coefficients (@ 44100, 48k, & 96k) are here (https://dl.dropboxusercontent.com/u/8835547/lpf.zip)

if anyone wants to play.



I'd be amused to hear about how you came to use that 24/96 recording, as it seems to be exceptionally similar to some original recorded work I posted on www.pcabx.com back in Y2K.

No complaints and of course its PD as far as I'm concerned, but it appears to be one of my lost children, and I'm always interested in how they come to be used in a worthwhile way.

;-)
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: xnor on 2015-04-15 22:35:36
jj, well.. it depends on what you mean with 'do'.

If I have a signal of +1, -1, +1, -1 ... then I can simply upsample by inserting zeros, send it off to a D/A converter. If the initial sample rate was 44.01 kHz then we should see a 22.05 kHz tone at the output.

Obviously, there is trickery involved (I leave this to the reader to figure out) and you are right if you respect the sampling theorem. It's also not really useful.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Woodinville on 2015-04-16 03:42:10
jj, well.. it depends on what you mean with 'do'.

If I have a signal of +1, -1, +1, -1 ... then I can simply upsample by inserting zeros, send it off to a D/A converter. If the initial sample rate was 44.01 kHz then we should see a 22.05 kHz tone at the output.

Obviously, there is trickery involved (I leave this to the reader to figure out) and you are right if you respect the sampling theorem. It's also not really useful.


Well, if we're using already sampled data, ...

Which is the flaw of FFT's in this context. You need to consider the Fourier Transform, not a cyclic transform.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: bandpass on 2015-04-16 09:05:50
I'd be amused to hear about how you came to use that 24/96 recording, as it seems to be exceptionally similar to some original recorded work I posted on www.pcabx.com back in Y2K.

No complaints and of course its PD as far as I'm concerned, but it appears to be one of my lost children, and I'm always interested in how they come to be used in a worthwhile way.

;-)

Yes, it's castanets-2_2496.wav.  The site (including downloads) is in fact still available: http://web.archive.org/web/20050201005114/http://pcabx.com/ (http://web.archive.org/web/20050201005114/http://pcabx.com/)
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: Arnold B. Krueger on 2015-04-16 10:40:24
I'd be amused to hear about how you came to use that 24/96 recording, as it seems to be exceptionally similar to some original recorded work I posted on www.pcabx.com back in Y2K.

No complaints and of course its PD as far as I'm concerned, but it appears to be one of my lost children, and I'm always interested in how they come to be used in a worthwhile way.

;-)

Yes, it's castanets-2_2496.wav.  The site (including downloads) is in fact still available: http://web.archive.org/web/20050201005114/http://pcabx.com/ (http://web.archive.org/web/20050201005114/http://pcabx.com/)



That is a very helpful link and it is about the best we've got, but the image of the site one finds there is incomplete because the original PCABX web site was composed of three separate sites, only one of which was linked by a registered web site name. It in turn linked 2 other unregistered web sites that were accessed only by IP addresses. This was done to minimize operational costs.  Once upon a time I put all three web sites together on one CD and gave out a few copies of it, but I've lost track of it.
Title: Representing frequency of n Hz needs sampling rate >2n Hz, not =2n
Post by: 2Bdecided on 2015-04-16 10:57:09
OT: The internet archive is one of the most frustrating things in existence. Almost everything I've ever wanted to access has been "partially" archived there. It's not for the reason you suggest Arny. It seems to leave things out almost at random. e.g. some of your samples linked via IP addresses are there, others hosted at the same IP address are not. It often only picks a selection of images, audio files, forum posts. documents etc rather than the whole lot. It seems that its web crawler just doesn't know how to crawl.

Of course if you're really lucky, there's nothing there at all, which makes you thankful for something. The problem is some niave people think "Oh, it's OK, the whole internet is saved there" when it's not. Mostly, our recent on-line history has gone.

As for the whole "web 2.0" dynamic experience, good luck accessing any of that when it's gone offline. I bet already it's impossible to properly experience what facebook looked like just a couple of years ago.

Cheers,
David.