PDA

View Full Version : Resampling to a higher Sampling Rate = Loss Of Quality or...?


Terranigma
8th November 2007, 23:28
Hello, maybe one of you guys can clear up this question. Does resampling from lets say, 44100 to 48000khz = loss of quality, or perhaps it may seem that way since 48000khz can hold higher frequencies than 44100khz?

e.g. (Analysis using spectral display in adobe).
Original (44100khz):
http://img260.imageshack.us/img260/4949/originalwavsf6.png

48000Khz:
http://img106.imageshack.us/img106/526/resampled48000ki3.png

192000khz:
http://img211.imageshack.us/img211/5820/resampled192000qu9.png

Coolpplse
9th November 2007, 03:29
doing 44.1khz -> 48khz always causes rounding errors, and good filters can eliminate most of those errors but not all

Doing 44.1khz -> 88.2khz doesnt lose quality I believe since theres no rounding errors at that samplerate...

unskinnyboy
9th November 2007, 18:58
Upsampling to a sampling rate which is a multiple of the signal's sampling rate would allow for a perfect reconstruction of the signal (at least theoretically). That's what Nyquist-Shannon theorem states. But, depending on the hardware/software process used, it can introduce errors if not done properly.

So, 44.1 kHz -> 88.2 kHz would work. 44.1 kHz -> 48 kHz or 192 kHz won't work. OK, they would work, but the interpolation won't be perfect.

3dsnar
12th November 2007, 08:11
To clarify.
resampling applies an anti-aliasing (lowpass) FIR filter to the input signal during the resampling process.
This causes some errors, including Gibbs effect in the time domain, and some frequency domain distortions (since the frequency characteristics of these filters is inperfect)

Resampling 44,1 -> 48 is possible, because you upsample 160 times and than downsample 147 time. This normally would be very ineficient, however something called polyphase filterbank and polyphase filtering routine is used, which applies both in one shot.

Anyway, this is still pretty computationally complex (44,1 -> 48), hence older resamplers used to use shorter FIR impulse responces for constructing the polyphse matrix, and therefore this particular convertion had alwas (than e.g. 44,1 -> 88,2) been viewed as more problematic and results of lower quality.

Today, a good resampler can make this conversion nearly perfectly (i.e. errors are inaudible, although present).

Cheers,
3d.

Terranigma
12th November 2007, 17:03
Thanks for the replies guys. So, lets say that i'd like to have this 44100khz audio as 48000khz without losing any sort of quality. Would copying (instead of resampling) the wave spectrum from 44100khz to a blank 48000khz file be a workaround? I've noticed that the wave spectrum (the frequencies) remained intact when I chosed to do it like this. :p

Raptus
12th November 2007, 21:01
Upsampling to a sampling rate which is a multiple of the signal's sampling rate would allow for a perfect reconstruction of the signal
...
So, 44.1 kHz -> 88.2 kHz would work. 44.1 kHz -> 48 kHz or 192 kHz won't work. OK, they would work, but the interpolation won't be perfect.
That's a myth. Summing up 3dsnars post with other words:
The quality of the resampling is dictated by the quality of the used FIR filter (frequency response, phase and impulse response). It has nothing to do with sample rate ratio.

Apart from that you have some added requantization noise, but that can be minimized using 24bit or floating point processing with noise shaped dither to 16bit afterwards.

madshi
12th November 2007, 22:23
@3dsnar and @Raptus,

do you happen to have a link to free source code which does resampling by using high quality FIR filters?

Thanks!

Maccara
13th November 2007, 07:18
Would copying (instead of resampling) the wave spectrum from 44100khz to a blank 48000khz file be a workaround?

No. It will need resampling (cooledit/audition does this automatically).

Raptus
13th November 2007, 09:14
@madshi: Try SSRC: http://shibatch.sourceforge.net/
PPHS would also be interesting for faster speed and arbitrary sample rate conversion, but AFAIK it's not OpenSource.

madshi
13th November 2007, 09:41
@madshi: Try SSRC: http://shibatch.sourceforge.net/
PPHS would also be interesting for faster speed and arbitrary sample rate conversion, but AFAIK it's not OpenSource.
Thank you! :)

Did some searching and found that r8brain comes with a free to use win32 dll. It's not open source, but my main need is a free and easy way to add high quality resampling to my win32 freeware. So now I have to decide whether to use SSRC or r8brain...

Raptus
13th November 2007, 10:24
Both SSRC and R8brain seem excellent choices, judging by the graphs shown here (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=56635&view=findpost&p=508935) and here (http://src.infinitewave.ca/), which show the spectrum of a sinesweep resampled from 96Khz to 44.1 over time, revealing noise and frequency fold-backs caused by improper filtering. Shocking to see so many expensive pro audio software behaving really bad :eek:

EDIT: Just saw that the passband/transition of r8brain free isn't ideal, probably also the phase. Can't have everything I suppose...

madshi
13th November 2007, 10:56
EDIT: Just saw that the passband/transition of r8brain free isn't ideal, probably also the phase. Can't have everything I suppose...
Now if only I knew what this meant practically... :) Too bad I'm a noob with these kind of graphs.

The main purpose I need the resampling for is for undoing PAL speedup (so basically I need to slow audio down by roughly 4%). Do those graphs help deciding whether r8brain or SSRC would be the better choice (quality wise)? I don't care much about processing time. Only the quality is important.

Thank you!!

Raptus
13th November 2007, 11:22
It means that the frequency response is okay-ish, the roll-off starts a bit early (just above 18Khz), good would be above 20Khz, excellent above 21Khz. Some golden ears *might* ABX a difference.

But that matters only for 44.1Khz. If your are resampling audio at 48Khz or from higher rate to 48Khz this becomes less of an issue because the roll-off is shifted up.

So, answering your question: Yes, _I_ would go with r8brain free in spite of the issue mentioned, because it's other qualities are excellent. I would recommend that the users don't go below 48Khz, though.

madshi
13th November 2007, 11:41
So, answering your question: Yes, _I_ would go with r8brain free in spite of the issue mentioned, because it's other qualities are excellent. I would recommend that the users don't go below 48Khz, though.
Thanks for your help!

The most often used conversion in my tool will be from 48000 to 46033.92 (25.000 -> 23.976). Would you still go with r8brain in this situation?

Raptus
13th November 2007, 11:51
The most often used conversion in my tool will be from 48000 to 46033.92 (25.000 -> 23.976).
That's the wrong way ;)
Remember that you would be playing back the 46033Hz signal at 48Khz, so it would be faster, not slower. You should do it the other way, from 48Khz to 50050.05Hz, and then play back that signal at 48Khz, hence slower.

If r8brain supports this sample rates, I would use it.

EDIT: spelling, jeez.

madshi
13th November 2007, 12:00
Oooooooopsie... :D Thanks!

madshi
13th November 2007, 12:06
Might be a bit OT, but since some experts are already listening I'll ask here:

I'm wondering, for undoing PAL speedup. Do I need to calculate with "23.976" or with "24.000 / 1.001"? You know, it's slightly different. In the first case I'd resample from 48000 to "50050,05005005005005...". In the latter case I'd resample from 48000 to exactly 50050.

I guess my real question is: Are DVDs mastered to 23.976 or are they mastered to 24.000 / 1.001?

(P.S: r8brain supports floating point output sample rate, so "50050,05005..." would be possible).

Raptus
13th November 2007, 12:13
The spec states x/1.001, where x = 24, 30 or 60.

Even if some discs don't follow the spec, the difference would be only 0.172 frames after 2 hours of film ;)

madshi
13th November 2007, 12:29
The spec states x/1.001, where x = 24, 30 or 60.
Thank you.

Even if some discs don't follow the spec, the difference would be only 0.172 frames after 2 hours of film ;)
Ok, that would be about 7ms. I guess I can live with that... :)

tebasuna51
13th November 2007, 12:36
The main purpose I need the resampling for is for undoing PAL speedup (so basically I need to slow audio down by roughly 4%).

I don't understand for what you need resamplig to slow/speedup the audio (PAL <> NTSC video framerate). This method don't preserve the pitch. Or is part of a more complex process?

madshi
13th November 2007, 12:46
This method don't preserve the pitch.
Which is exactly what I want/need. Studios usually don't use pitch correction when doing PAL speed up. So the pitch on PAL audio tracks is almost always too high (so called "Mickey Mouse effect"). Consequently I must not use pitch correction when undoing PAL speed up, either. Or else I'd preserve the too high pitch.

Raptus
13th November 2007, 13:22
W...Or else I'd preserve the too high pitch.
exactly.

Btw, in case r8brain refuses to resample to sample rates higher than 48Khz because of the limitations of the free version, just flag your input as 46033.96603Hz and resample to 48Khz :D

madshi
13th November 2007, 14:10
Btw, in case r8brain refuses to resample to sample rates higher than 48Khz because of the limitations of the free version, just flag your input as 46033.96603Hz and resample to 48Khz :D
Yep, good idea!

nautilus7
13th November 2007, 15:35
@madshi

From what i 've read here you plan to add framerate conversion to next version of eac3to, right?

Terranigma
13th November 2007, 15:37
No. It will need resampling (cooledit/audition does this automatically).

Well, goldwave doesn't resample automatically. It allows for exact copying without doing so, and doing so this way allowed the frequencies to remain untouched (because a 48000khz file should be able to retain everything that a 44100khz file can).

If you have goldwave, create a new wave file at 48000khz, then copy the 44100khz audio to this new file. This is what I was talking about. =P

madshi
13th November 2007, 15:38
From what i 've read here you plan to add framerate conversion to next version of eac3to, right?
To a future eac3to version, yes. Don't know if it will make it into the very next version, though.

nautilus7
13th November 2007, 15:55
OK, that's good!

Maccara
13th November 2007, 20:25
Well, goldwave doesn't resample automatically.

Of course it does. What gave you that idea? Even if it doesn't ask about it, it has to resample - no need for me to test it. There are only 2 options for a software to do this: 1. do not allow user to paste and inform the audio params do not match 2. automatically convert to match the audio.

What you're implying is that 44->48 conversion could be done perfectly without errors, and it can't.

Read the goldwave helpfiles - I bet they mention it in the copy/paste part of the help, that the audio params are automatically converted to target params or something like that.

Terranigma
13th November 2007, 20:57
Read the goldwave helpfiles - I bet they mention it in the copy/paste part of the help, that the audio params are automatically converted to target params or something like that.

The Copy command copies the selection into the clipboard. The selection is not removed from the sound. The contents of the clipboard can then be mixed or placed into another sound using Mix, Paste, Paste New or Replace.

To copy:

1. Select the part of the sound you want to copy.
2. Choose Copy from the Edit menu or click on the Copy button.

_______________________________________________
Paste and Paste At

After copying a sound into the clipboard, you can use these commands to insert it into another sound. The Paste command inserts the clipboard at the start marker's position. Paste At inserts the clipboard at the location you specify: at the beginning of the file, at the finish marker, or at the end of the file. The length of the sound is increased so that the clipboard will fit. The clipboard is automatically converted to match the attributes of the sound.

To insert the clipboard into the sound:

1. Move the start marker to the place where you want to paste the clipboard sound.
2. Choose Paste from the Edit menu.

To append the clipboard to the end of the sound:

1. Choose Paste At from the Edit menu.
2. Choose End from the Paste At submenu.


Doesn't mention anything of the sort. Explain the following to me.

original:
http://img100.imageshack.us/img100/6448/original44100khzzo5.png

Resampled to 48000khz (adobe audition/quality 999):
http://img231.imageshack.us/img231/6352/resampled48000khzqp9.png

Copied to 48000khz (Goldwave):
http://img231.imageshack.us/img231/7181/copiedto48000khzaq2.png

(And of course the copied wouldn't be maxed since the frequencies aren't as high as it could be at 48000khz, or so I assume :p)


---
nvm, you're right. I tested the file after during the resampling process with goldwave, and the frequencies shows the same thing. Now I wonder why it doesn't mention it in it's manual that it does this.
Anyways, judging from the frequencies, would you say that the goldwave one is of higher quality?

Maccara
13th November 2007, 23:26
Now I wonder why it doesn't mention it in it's manual that it does this.
Just dl'd demo of GW 5.22 and they've added in the help files (in "paste" section): "The clipboard sound is automatically converted to match the attributes of the current sound.", so now they do mention it - probably enough people have wondered this.
Anyways, judging from the frequencies, would you say that the goldwave one is of higher quality?
Any decent editor should be able to do the conversion without audible errors - I'd expect goldwave to be able to do that too. (I know Audition has pretty good resampling functions)

Can't really tell just by just looking at those spectral images - slightly different, but can't judge which is "better" (didn't notice obvious aliasing errors, but didn't look too closely).

Btw, did you enable pre/post filters for conversion in audition? (should almost always be used)

Terranigma
14th November 2007, 00:01
Btw, did you enable pre/post filters for conversion in audition? (should almost always be used)
Yes, that's what I meant above by quality as 999 =P
http://img61.imageshack.us/img61/7455/prepostfilteringmq5.png

As you can see, I have the bit depth set to 32bits as well, because I read in another post that we should always change the bit-depth to 32bits or we'll lose some data (before editing). :scared:

Then once we're done editing, we should downsample back to 16bits using a triangular noise-shaping method.