IPB

Welcome Guest ( Log In | Register )

Sample rate conversion
MannyCalavera
post Apr 11 2011, 18:50
Post #1





Group: Members
Posts: 8
Joined: 18-July 07
Member No.: 45403



Hello everyone.

I have a question regarding sample rate conversion algorightms.
I don't know how they work, but I guess you guys are more familiar with this biggrin.gif

Let's say I have a 48 kHz wave file that I want to use in something I have to mix
with some 96 kHz material at certain places. This requires the 48 kHz file be resampled
and in the end back to 48.

So in short: does resampling 48 --> 96 --> 48 change the original or can the original
be restored 100% ?

I'm using Wavelab for this.
Go to the top of the page
+Quote Post
 
Start new topic
Replies
Axon
post Apr 12 2011, 20:09
Post #2





Group: Members (Donating)
Posts: 1985
Joined: 4-January 04
From: Austin, TX
Member No.: 10933



If you are just mixing, then you ought to be able to get the same results (to within -144db or better) by resampling the 96k content down to 48k, and mixing at 48k. The reason is that mixing is a purely linear operation.

48k->96k, being a 2x oversample, is among the most numerically conservative resampling possibilities. If the resampler is correctly implemented, 50% of all the samples should be numerically exact, with zero quantization error.
Go to the top of the page
+Quote Post
2Bdecided
post Apr 13 2011, 15:21
Post #3


ReplayGain developer


Group: Developer
Posts: 5362
Joined: 5-November 01
From: Yorkshire, UK
Member No.: 409



QUOTE (Axon @ Apr 12 2011, 20:09) *
If the resampler is correctly implemented, 50% of all the samples should be numerically exact, with zero quantization error.
That's an interesting use of the word "correctly" - a 2x resampler can easily be (and often is) perfect in terms of frequency and phase response, while giving 100% "new" samples.

You can easily design it to do as you suggest, but that's not necessarily the way all are designed.

Cheers,
David.
Go to the top of the page
+Quote Post
Axon
post Apr 13 2011, 22:43
Post #4





Group: Members (Donating)
Posts: 1985
Joined: 4-January 04
From: Austin, TX
Member No.: 10933



QUOTE (2Bdecided @ Apr 13 2011, 09:21) *
That's an interesting use of the word "correctly" - a 2x resampler can easily be (and often is) perfect in terms of frequency and phase response, while giving 100% "new" samples.

You can easily design it to do as you suggest, but that's not necessarily the way all are designed.


Feh. Yes, you are correct. Thanks for the catch.

I think that if I restrict my statement to the domain of windowed sinc filters, it's accurate. But any filter possessing an asymmetric response around the -6db point at Fs/2 is categorically not in that domain. While asymmetric filters are 2x more complex to implement, obviously they exist, particularly in software implementations where the symmetric optimization may not get performed. (offhand, I can't recall any specific instance of such a filter, but I am quite sure they exist.)

... Right? smile.gif

This post has been edited by Axon: Apr 13 2011, 22:48
Go to the top of the page
+Quote Post
Canar
post Apr 14 2011, 00:03
Post #5





Group: Super Moderator
Posts: 3373
Joined: 26-July 02
From: To:
Member No.: 2796



QUOTE (Axon @ Apr 13 2011, 14:43) *
I think that if I restrict my statement to the domain of windowed sinc filters, it's accurate. But any filter possessing an asymmetric response around the -6db point at Fs/2 is categorically not in that domain.
I have a question that's marginally off-topic, but this post triggered all my keyword detectors. Windowed sinc is symmetric. What would similar functions be in the asymmetric case? The symmetric, acausal nature of sinc has always bugged me, but I've never found a reference containing asymmetric, causal analogues that I could use in SRC contexts.


--------------------
You cannot ABX the rustling of jimmies.
No mouse? No problem.
Go to the top of the page
+Quote Post
Axon
post Apr 14 2011, 03:26
Post #6





Group: Members (Donating)
Posts: 1985
Joined: 4-January 04
From: Austin, TX
Member No.: 10933



QUOTE (Canar @ Apr 13 2011, 18:03) *
QUOTE (Axon @ Apr 13 2011, 14:43) *
I think that if I restrict my statement to the domain of windowed sinc filters, it's accurate. But any filter possessing an asymmetric response around the -6db point at Fs/2 is categorically not in that domain.
I have a question that's marginally off-topic, but this post triggered all my keyword detectors. Windowed sinc is symmetric. What would similar functions be in the asymmetric case? The symmetric, acausal nature of sinc has always bugged me, but I've never found a reference containing asymmetric, causal analogues that I could use in SRC contexts.

Yeah, you better split this mofo right now before the OP's head explodes.

I was using the term "windowed sinc" previously with the implicit assumption that the sinc function is critically sampled, ie, with lowpass frequency Fs/2. If it's not that -- more specifically, if it's both lower than, and relatively prime to, Fs/2 -- then you'll get your asymmetric response, and you'll also get every sample modified. That's the simplest example I can think of.

Lemme do a bit of armchair mathematical derivation to outline what I'm riffing from. I'm going to wave my hands *really* widely here, so I apologize in advanced for abuses of notation, convention, or for that matter, logic. For starters, I'll write this assuming a normalized, ordinary-frequency Fourier transform, but using the variable omega (w) instead of xi. I am also assuming Fs=1, and I write Fs/2 largely as a more easily identifiable representation of the frequency "1/2".

The basic principle here is the interpolating filter, ie, one which can be used when interpolating between sampled data values: for interpolating kernel k(t) convolved with a discrete-time signal with sampling period 1, k(0)=1 and k(N)=0 for nonzero integer N.

The sinc function is the "simplest" analytic function satisfying this requirement. I base this statement from the following identity:



(This is a nice time to ask: Can an admin please add MathJax support to the site? smile.gif smile.gif )

The inner term there, (1-x2/n2), can be rewritten as (n-2)(n+x)(n-x). That (n-2) is just a constant which can be ignored, so what we're left with is a function which could be notionally defined as a polynomial with a zero at every nonzero integer. That's precisely what is necessary for an interpolating kernel.

This implies, at least the way I see it currently, that any interpolating function can be written in the form k(t) = h(t) sinc(t), as long as h(0)=1, and h(t) is defined across the support of k(t). Furthermore, the windowed (time-limited) interpolation functions can be written h(t) = g(t/a) rect(t/a), where "a" controls the window width and g(t) is the basic window function evaluated over [-1/2, 1/2]. So a Hann-windowed sinc kernel is going to be something like g(t) = (1+cos(pi t))/2.

The statement k(t) = h(t) sinc(t) in the time domain is equivalent to K(w) = H(w) * rect(w) in the frequency domain. If we assert:
  • h(t) is even ---> H(w) is also even (this will be true for all linear-phase filters)
  • H(w) is bandlimited to <Fs (strictly impossible for windowed kernels, but usually a very safe approximation)

... then, around w=+1/2, we can approximate rect(w) ~~ 1 - u(w-1/2) (and similarly for w=-1/2). From this -- and I apologize again if I'm skipping way too many steps here -- by looking at the bare convolution integrals, it's fairly easy to see that K(1/2)=(1/2) K(0). For a normalized filter response, ie K(0)=0db, then K(1/2)=-6db.

In summary, when performing integral upsampling with a lowpass filter, the kernel k(t) is interpolating (preserves the value of the original samples) if and only if: *either*
  • The kernel can be written k(t) = h(t) sinc(t)
  • h(0)=1
  • h(t) is even
  • The approximation "H(w)=0 for w>Fs" is reasonably accurate
  • The domain of h(t) includes the support of k(t) (ie, no infinities)
*or* the Fourier transform of the kernel can be written K(w) = H(w) * rect(w), for H(w) even; more specifically,
  • K(Fs/2) = (1/2) K(0)
  • K(w) - (1/2) is approximately odd around w=+-Fs/2 (the symmetry obviously breaks down near w=0)
Go to the top of the page
+Quote Post

Posts in this topic
- MannyCalavera   Sample rate conversion   Apr 11 2011, 18:50
- - saratoga   QUOTE (MannyCalavera @ Apr 11 2011, 13:50...   Apr 11 2011, 18:58
- - Arnold B. Krueger   QUOTE (MannyCalavera @ Apr 11 2011, 13:50...   Apr 12 2011, 14:29
- - Axon   If you are just mixing, then you ought to be able ...   Apr 12 2011, 20:09
|- - 2Bdecided   QUOTE (Axon @ Apr 12 2011, 20:09) If the ...   Apr 13 2011, 15:21
|- - Axon   QUOTE (2Bdecided @ Apr 13 2011, 09:21) Th...   Apr 13 2011, 22:43
|- - Canar   QUOTE (Axon @ Apr 13 2011, 14:43) I think...   Apr 14 2011, 00:03
|- - Axon   QUOTE (Canar @ Apr 13 2011, 18:03) QUOTE ...   Apr 14 2011, 03:26
- - Wombat   QUOTE (2Bdecided @ Apr 13 2011, 15:21) Yo...   Apr 13 2011, 16:05
|- - bandpass   Given 10 seconds of 440Hz tone and upsampling from...   Apr 13 2011, 20:25
|- - Wombat   QUOTE (bandpass @ Apr 13 2011, 20:25) Giv...   Apr 13 2011, 20:47
|- - bandpass   QUOTE This must be lowpassed already even if i don...   Apr 13 2011, 21:19
- - Wombat   I admit i have no clue about some things you talk ...   Apr 14 2011, 00:44
|- - Canar   QUOTE (Wombat @ Apr 13 2011, 16:44) I adm...   Apr 14 2011, 00:52
||- - Wombat   QUOTE (Canar @ Apr 14 2011, 00:52) Sample...   Apr 14 2011, 00:58
||- - Canar   QUOTE (Wombat @ Apr 13 2011, 16:58) Exact...   Apr 14 2011, 01:03
|- - saratoga   QUOTE (Wombat @ Apr 13 2011, 19:44) I adm...   Apr 14 2011, 01:03
- - Wombat   QUOTE (saratoga @ Apr 14 2011, 01:03) Alt...   Apr 14 2011, 01:11
|- - saratoga   QUOTE (Wombat @ Apr 13 2011, 20:11) QUOTE...   Apr 14 2011, 01:17
|- - bandpass   QUOTE (saratoga @ Apr 14 2011, 01:17) Obv...   Apr 14 2011, 07:30
|- - Axon   QUOTE (bandpass @ Apr 14 2011, 01:30) QUO...   Apr 14 2011, 19:38
|- - bandpass   QUOTE (Axon @ Apr 14 2011, 19:38) Strictl...   Apr 14 2011, 20:24
- - Wombat   QUOTE (bandpass @ Apr 14 2011, 20:24) aft...   Apr 14 2011, 20:46
|- - bandpass   QUOTE (Wombat @ Apr 14 2011, 20:46) I sti...   Apr 14 2011, 22:16
|- - Alexey Lukin   QUOTE (bandpass @ Apr 14 2011, 17:16) Bec...   Apr 14 2011, 22:26
|- - Wombat   QUOTE (bandpass @ Apr 14 2011, 22:16) Usi...   Apr 14 2011, 22:27
|- - bandpass   QUOTE (Alexey Lukin @ Apr 14 2011, 22:26)...   Apr 15 2011, 07:18
- - Alexey Lukin   48 -> 96 kHz conversion may leave signal sample...   Apr 14 2011, 21:35
- - Wombat   QUOTE (Alexey Lukin @ Apr 14 2011, 21:35)...   Apr 14 2011, 21:49
- - Wombat   I am getting slowly mad in here or lowpass myself ...   Apr 14 2011, 22:49
|- - bandpass   Okay, curiousity got the better of me: in the 48k ...   Apr 15 2011, 10:39
- - Wombat   Many thanks bandpass for your efforts. Very intere...   Apr 15 2011, 16:24
- - Alexey Lukin   I've just verified that SoX never preserves th...   Apr 15 2011, 17:10
- - Wombat   QUOTE (Alexey Lukin @ Apr 15 2011, 17:10)...   Apr 15 2011, 18:11
|- - bandpass   All I have told you is what I have observed throug...   Apr 15 2011, 22:17
- - Alexey Lukin   This is only due to the fact that you used the sin...   Apr 16 2011, 06:27
- - bandpass   QUOTE (Alexey Lukin @ Apr 16 2011, 06:27)...   Apr 16 2011, 08:41
- - Alexey Lukin   Agreed.   Apr 16 2011, 08:45


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st December 2014 - 20:40