Reply by Andreas Huennebeck April 8, 20052005-04-08
Jerry Avins wrote:

>> Sure guys. I buy that. I think the reason why I couldn't hear much of the >> folding distortion was that I used a sound to test which didn't have much >> frequency content in the regions where the folding distortion occured. > > Let me get this straight. Are these your points? > > You know you're doing it wrong, but you don't believe it matters much. > It sounds a little strange, and you want to know why. > It's not worth doing it right because you know what the problem isn't. > > Does that sum it up?
It looked like this to me until Fred gave the answer shown above. I interpret his answer so that he finally understood it. bye Andreas -- Andreas H�nnebeck | email: ah@despammed.com ----- privat ---- | www : http://www.huennebeck-online.de Fax/Anrufbeantworter: 0721/151-284301 GPG-Key: http://www.huennebeck-online.de/public_keys/andreas.asc
Reply by Jerry Avins April 7, 20052005-04-07
Fred T. Weiler wrote:
>>Let me get this straight. Are these your points? >> >>You know you're doing it wrong, but you don't believe it matters much. >>It sounds a little strange, and you want to know why. >>It's not worth doing it right because you know what the problem isn't. >> >>Does that sum it up? >> >>Jerry > > > Hey hey hey. Calm down and show some respect for god's sake. > I'm not arguing against *anyone* here. I've got the answers and I > believe all of you who explained how it works. > > Thanks all of you who contributed to the discussion in a polite > manner.
I don't think respect is at issue. You seem like an affable guy who's not out to hurt or insult anyone. I'd like to think the same of myself. But I hunt and peck at a keyboard, and before writing a treatise or an impassioned bit of advocacy, I want to know where the matter stands. The question was real. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by Fred T. Weiler April 7, 20052005-04-07
> Let me get this straight. Are these your points? > > You know you're doing it wrong, but you don't believe it matters much. > It sounds a little strange, and you want to know why. > It's not worth doing it right because you know what the problem isn't. > > Does that sum it up? > > Jerry
Hey hey hey. Calm down and show some respect for god's sake. I'm not arguing against *anyone* here. I've got the answers and I believe all of you who explained how it works. Thanks all of you who contributed to the discussion in a polite manner. Fred
Reply by Jerry Avins April 7, 20052005-04-07
Fred T. Weiler wrote:
>>Jerry's A and B are both excellent reasons why you might not hear the effect, >>but it is certainly there and can be very audible. From my experience, the type >>of audio which exhibits "folding distortion" most clearly is a swept high >>frequency sine wave. Sweep a sine wave from about half of the original Nyquist >>rate up to the original Nyquist rate (i.e. if 44.1kHz, sweep from 11 to 22 kHz) >>over about 10 seconds. Then throw away every other sample and listen to the >>effect. This should be _very_ obvious. The decimated sweep will go in the >>_opposite direction_ as the old one! >>Another good test is a swept triangle or square wave. After decimating, you >>will hear a weird combination of upward and downward moving frequency >>components. > > > Sure guys. I buy that. I think the reason why I couldn't hear much of the folding > distortion was that I used a sound to test which didn't have much frequency > content in the regions where the folding distortion occured. > > Fred
Let me get this straight. Are these your points? You know you're doing it wrong, but you don't believe it matters much. It sounds a little strange, and you want to know why. It's not worth doing it right because you know what the problem isn't. Does that sum it up? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by Howard Long April 7, 20052005-04-07
Hi Fred

FWIW I just remembered that I put the pseudo code of my algorthm on this NG
a couple on months ago. In case it's of any value to you, here it is again.
50% Overlap-Add


Constants...


FFTLen = 2048
SampleSize = FFTLen / 2


Arrays...


Real[0..FFTLen-1] zero padded samples, and result of FFT'd samples
Imag[0..FFTLen-1] imag result of FFT'd samples
HReal,HImag[0..FFTLen-1] for frequency response and its impulse response
LastReal,LastImag[0..SampleSiz�e-1] saved result for overlap-add next
iteration


Algorithm...
For each set of SampleSize samples:
o Take samples into Real[0..SampleSize-1]
o Real[SampleSize..FFTLen-1] = 0 // zero pad
o Take in place real FFT on Real[0..FFTLen-1] into Real,Imag[0..FFTLen-1]


// Here is a flat response, you can pop in whatever you like, for my
application it will insert a notch at high magnitude signals to limit them
to a prescribed limit. Remember to mirror around SampleSize/2!
o HReal[0..SampleSize-1]=1
o HImag[0..SampleSize-1]=0


// to get impulse response
o Inverse FFT in place HReal,HImag [0..SampleSize-1]
// get impulse response centred correctly
o Rotate IFFT results in HReal,HImag [0..SampleSize-1] by SampleSize/2


o Apply Hanning window to HReal, HImag [0..SampleSize-1]


// Zero pad impulse response
o HReal,HImag[SampleSize..FFTLen�-1]=0
// Get impulse response into frequency domain
o Take in place complex FFT on HReal,HImag [0..FFTLen-1]


// Apply filter in frequency domain by multiplication
o Perform a complex multiply HReal,HImag by Real,Imag [0..FFTLen-1] leaving
results in Real,Imag
// Now back to the time domain
o Perform inverse FFT on Real,Imag [0..FFTLen-1]


// Add in artifacts from last sample
o Real, Imag[0..SampleSize-1] += LastReal,LastImag[0..SampleSiz�e-1]
// Save new artifacts for next sample
o LastReal,LastImag[0..SampleSiz�e-1]=Real,Imag[SampleSize..FFT�Len-1]


o Send out Real[0..SampleSize-1]


Cheers, Howard


Reply by Fred T. Weiler April 7, 20052005-04-07
> Jerry's A and B are both excellent reasons why you might not hear the effect, > but it is certainly there and can be very audible. From my experience, the type > of audio which exhibits "folding distortion" most clearly is a swept high > frequency sine wave. Sweep a sine wave from about half of the original Nyquist > rate up to the original Nyquist rate (i.e. if 44.1kHz, sweep from 11 to 22 kHz) > over about 10 seconds. Then throw away every other sample and listen to the > effect. This should be _very_ obvious. The decimated sweep will go in the > _opposite direction_ as the old one! > Another good test is a swept triangle or square wave. After decimating, you > will hear a weird combination of upward and downward moving frequency > components.
Sure guys. I buy that. I think the reason why I couldn't hear much of the folding distortion was that I used a sound to test which didn't have much frequency content in the regions where the folding distortion occured. Fred
Reply by Jon Harris April 6, 20052005-04-06
"Jerry Avins" <jya@ieee.org> wrote in message
news:2q2dnXPnvomZ2snfRVn-3g@rcn.net...
> Fred T. Weiler wrote: > >>A harmonic at 18 kHz becomes a non harmonic at 22.05 - 18 kHz. Look up > >>"folding". > >> > >> ... > > > > > > Yes, folding distortion. I know. That's in theory. However, if I take an
audio file
> > and throw away every second sample and listen to it at half the sample rate, > > then the degradation of the sound won't be that noticable other than you may > > notice that the sample rate has been cut in half. > > > > Can you then explain why? Yes, I know that there's folding distortion in
theory,
> > but not in practice. > > > > Fred > > A. The program material may have little or no energy above the new Fs/2. > (But if so, there should be no quality loss at all at the lower > sample rate.) If the recording is made with a microphone and a sound > card, a filter suitable for the lowest sample rate may be used for > all rates. Can you take a spectrogram of the original file? > > B. You may not be sufficiently sensitive to the effect. (But you do hear > "metallic" unnaturalness.) Ask others for their impressions.
Jerry's A and B are both excellent reasons why you might not hear the effect, but it is certainly there and can be very audible. From my experience, the type of audio which exhibits "folding distortion" most clearly is a swept high frequency sine wave. Sweep a sine wave from about half of the original Nyquist rate up to the original Nyquist rate (i.e. if 44.1kHz, sweep from 11 to 22 kHz) over about 10 seconds. Then throw away every other sample and listen to the effect. This should be _very_ obvious. The decimated sweep will go in the _opposite direction_ as the old one! Another good test is a swept triangle or square wave. After decimating, you will hear a weird combination of upward and downward moving frequency components.
Reply by Jerry Avins April 6, 20052005-04-06
Fred T. Weiler wrote:
>>A harmonic at 18 kHz becomes a non harmonic at 22.05 - 18 kHz. Look up >>"folding". >> >> ... > > > Yes, folding distortion. I know. That's in theory. However, if I take an audio file > and throw away every second sample and listen to it at half the sample rate, > then the degradation of the sound won't be that noticable other than you may > notice that the sample rate has been cut in half. > > Can you then explain why? Yes, I know that there's folding distortion in theory, > but not in practice. > > Fred
A. The program material may have little or no energy above the new Fs/2. (But if so, there should be no quality loss at all at the lower sample rate.) If the recording is made with a microphone and a sound card, a filter suitable for the lowest sample rate may be used for all rates. Can you take a spectrogram of the original file? B. You may not be sufficiently sensitive to the effect. (But you do hear "metallic" unnaturalness.) Ask others for their impressions. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Reply by Jerry Avins April 6, 20052005-04-06
Fred T. Weiler wrote:
>>Consider your idee fixee: if every second sample of a set of valid >>samples is discarded, the result is still a set of valid samples. How >>many times in a row would you apply that theorem? Why stop there? > > > I'm not saying it's "the same". If I said that then I expressed myself wrong. > What I mean is that you'll get distortion above the Nyquist frequency,
No. All the energy above the new Fs/2 will be folded below the new Fs/2 with undiminished intensity. Distance from the folding frequency will be maintained, but the direction will be opposite. Convince yourself by calculating samples of 11 cycles of an 11 Hz signal sampled at 20 Hz. Then plot every second sample and see what you get. (If it isn't full amplitude at 1 Hz, there's a mistake.)
> which is getting lower on the downsampled signal.
That's simply not so. You keep repeating it despite being tole otherwise. Hence "idee fixee".
> For each time you > downsample by dividing the sample rate in half, the more distortion > you'll get above the Nyquist frequency.
Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Reply by Fred Marshall April 6, 20052005-04-06
"Fred T. Weiler" <nospam@nospam.com> wrote in message 
news:02W4e.21514$d5.158014@newsb.telia.net...
> > >> A harmonic at 18 kHz becomes a non harmonic at 22.05 - 18 kHz. Look up >> "folding". >> >> ... > > Yes, folding distortion. I know. That's in theory. However, if I take an > audio file > and throw away every second sample and listen to it at half the sample > rate, > then the degradation of the sound won't be that noticable other than you > may > notice that the sample rate has been cut in half. > > Can you then explain why? Yes, I know that there's folding distortion in > theory, > but not in practice. > > Fred
Only in theory?????? Let's take a real case: Signal sampled at 44kHz. Components at 5, 10, 15 kHz so also at 39, 34 and 29 kHz. Resampled at 22kHz. 5, 10 and 15 remain. 39,34, 29 become 17, 12, 7. So, now there is effectively 5, 7, and 10 below fs/2 and correspondingly, 17,15,12 above fs/2. The 15 effectively becomes 7 (which is the difference frequency between 29 and the new sample rate of 22). It is at whatever amplitude it had originally. Now, if you want to say that there are *no* components of significant amplitude above 11kHz to begin with then of course this doesn't happen. That must be what you mean? Otherwise, you may not be able to readily hear the 15kHz component - and thus not note its absence. However you might hear the introduced 7kHz component very well indeed! Since you're using an auditory measure, just inject a high amplitude "whistle" at 21kHz in the original. You likely won't hear it and won't notice its absence after resampling. However, it translates to 1kHz which you will surely hear. Fred