IPB

Welcome Guest ( Log In | Register )

3 Pages V  < 1 2 3  
Reply to this topicStart new topic
Why is perfect resampling impossible?
bandpass
post Jun 16 2012, 16:01
Post #51





Group: Members
Posts: 326
Joined: 3-August 08
From: UK
Member No.: 56644



In theory a filter could be tight enough for the error to fall far enough below the quantisation and still be of finite length but it would still need to be horribly long, probably not implementable.

For any practical demonstration of 'perfect' resampling along the lines suggested, I think the best one could show would be

trim(down(up(x))) = trim(x)

where the only constraint on x is to have a small amount (e.g. < 1%) of freq. headroom (and 'trim' removes a short section of audio from each end of the signal).

Also, the bit-depth must be increased for the intermediate file, and dithering must be disabled for the downsample.

A possible test signal say, at 48kHz (as the maths is easier), is a linear sweep over 10s from 3k down to 0, up to 24k, then down to 21k. Trim away the first and last 1s after conversion and the result is a fullband sweep (without Gibbs at the ends). I don't think any resampler would ever pass this test. It could do if you trim away a little more at the end though, as this effectively maps to non-zero freq. headroom requirement.
Go to the top of the page
+Quote Post
bandpass
post Jun 18 2012, 07:35
Post #52





Group: Members
Posts: 326
Joined: 3-August 08
From: UK
Member No.: 56644



QUOTE (Kees de Visser @ Jun 16 2012, 15:31) *
A colleague mastering engineer recently claimed to have measured his Weiss Saracon SRC to be bit-transparent for a 24/44.1->24/96->24/44.1 roundtrip. I was rather surprised since there's low-pass filtering and probably re-dithering involved. Assuming the source material contained some energy close to the Nyquist frequency, wouldn't bit-transparency be quite unlikely ?

Yes, I find this hard to believe: even with dithering disabled, the test signal would need to be band-limited (if only by a small amount), and carefully engineered not to have quantisation error (but I don't think that's possible with a non-zero signal), and to fade in and out very gently to avoid Gibbs at the ends.

If the resampler has error amplitude Er, then for an error-free round trip, 2 × Er + Eqi must be < Eqo, where Eqi and Eqo are the (maximum) quantisation error of the intermediate and original signals; so even if Er is 0, Eqi must be < Eqo.

Perhaps you could ask your colleague for further details of the test? Given that perfect resampling is impractical, it would be interesting to establish test criteria for 'practically perfect' resampling—the 'Poppins test', perhaps.
Go to the top of the page
+Quote Post
Alexey Lukin
post Jun 18 2012, 16:47
Post #53





Group: Members
Posts: 191
Joined: 31-July 08
Member No.: 56508



Many engineers consider "bit transparent" to be the same as "diff signal not audible".
Go to the top of the page
+Quote Post
Alexey Lukin
post Jun 18 2012, 17:01
Post #54





Group: Members
Posts: 191
Joined: 31-July 08
Member No.: 56508



QUOTE (Woodinville @ Jun 16 2012, 00:21) *
As i'm sure somebody's pointed out that you can be "perfect to quantization noise level or below" which is appropriate.

In the most general case, this is impossible too, JJ. There are digital signals for which sinc interpolation does not converge towards a fixed analog signal as you increase the support of sincs. In other words, as you use better-and-better-quality reconstruction, your reconstructed signal changes and never stops, and rises infinitely in amplitude (which never brings it within a quantization step of a perfect reconstruction because a perfect reconstruction in fact diverges to infinity). A simplest example of such digital signal is {...1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1 ...}
Go to the top of the page
+Quote Post
Alexey Lukin
post Jun 18 2012, 17:09
Post #55





Group: Members
Posts: 191
Joined: 31-July 08
Member No.: 56508



QUOTE (bandpass @ Jun 16 2012, 11:01) *
For any practical demonstration of 'perfect' resampling along the lines suggested, I think the best one could show would be
trim(down(up(x))) = trim(x)
where the only constraint on x is to have a small amount (e.g. < 1%) of freq. headroom (and 'trim' removes a short section of audio from each end of the signal).

This "frequency headroom" is the key. Most audio signals do not have this headroom as they undergo A/D conversion, so there's no sense in trying to "perfectly" reconstruct them. For such signals it's better to use some reasonably-steep reconstruction filter (like 3-ms long), rather than try to be "perfect" and get a lot of ringing near Nyquist that decays as 1/t.

This post has been edited by Alexey Lukin: Jun 18 2012, 17:10
Go to the top of the page
+Quote Post
knutinh
post Jun 18 2012, 20:20
Post #56





Group: Members
Posts: 569
Joined: 1-November 06
Member No.: 37047



QUOTE (Pio2001 @ Aug 28 2004, 02:46) *
So we'd need an FFT size of the power of 2 superior to the number of samples.

http://www.fftw.org/
"Arbitrary-size transforms. (Sizes with small prime factors are best, but FFTW uses O(N log N) algorithms even for prime sizes.)"
Go to the top of the page
+Quote Post
knutinh
post Jun 18 2012, 20:25
Post #57





Group: Members
Posts: 569
Joined: 1-November 06
Member No.: 37047



QUOTE (Woodinville @ Jun 16 2012, 06:21) *
Perfect resampling would require a filter of infinite length. You could never succeed in completing the first sample.

But a _file_ of finite length contains only a (finite) discrete set of frequencies?

-k
Go to the top of the page
+Quote Post
greynol
post Jun 18 2012, 22:16
Post #58





Group: Super Moderator
Posts: 10000
Joined: 1-April 04
From: San Francisco
Member No.: 13167



QUOTE (knutinh @ Jun 18 2012, 12:25) *
But a _file_ of finite length contains only a (finite) discrete set of frequencies?

The answer is no. smile.gif


--------------------
Placebophiles: put up or shut up!
Go to the top of the page
+Quote Post
Woodinville
post Jun 18 2012, 22:20
Post #59





Group: Members
Posts: 1402
Joined: 9-January 05
From: JJ's office.
Member No.: 18957



QUOTE (Alexey Lukin @ Jun 18 2012, 09:01) *
QUOTE (Woodinville @ Jun 16 2012, 00:21) *
As i'm sure somebody's pointed out that you can be "perfect to quantization noise level or below" which is appropriate.

In the most general case, this is impossible too, JJ. There are digital signals for which sinc interpolation does not converge towards a fixed analog signal as you increase the support of sincs. In other words, as you use better-and-better-quality reconstruction, your reconstructed signal changes and never stops, and rises infinitely in amplitude (which never brings it within a quantization step of a perfect reconstruction because a perfect reconstruction in fact diverges to infinity). A simplest example of such digital signal is {...1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1 ...}


Except, Alexey, that signal (1, 0, 1, 0, ...) is only permissable if it's infinitely long. Otherwise, the signal that created that in the analog domain could not possibly have been properly sampled, as it has content outside -fs/2 to fs/2.

Your signal is exactly 1/2 (i.e. DC) and .5*cos(n*pi), which is exactly at fs/2, and which therefore can not ever be recorded in the real world without violating the sampling theorem. Ditto for reconstruction.


--------------------
-----
J. D. (jj) Johnston
Go to the top of the page
+Quote Post
Woodinville
post Jun 18 2012, 22:23
Post #60





Group: Members
Posts: 1402
Joined: 9-January 05
From: JJ's office.
Member No.: 18957



QUOTE (greynol @ Jun 18 2012, 14:16) *
QUOTE (knutinh @ Jun 18 2012, 12:25) *
But a _file_ of finite length contains only a (finite) discrete set of frequencies?

The answer is no. smile.gif


If it is sampled, however, and therefore consists of 'n' samples in the time domain, it can be precisely reproduced by 'n' samples in a frequency domain.

This is not the same as what the continuous fourier transform of the analog original (it being a finite length signal) will be, of course.


--------------------
-----
J. D. (jj) Johnston
Go to the top of the page
+Quote Post
Alexey Lukin
post Jun 18 2012, 22:43
Post #61





Group: Members
Posts: 191
Joined: 31-July 08
Member No.: 56508



QUOTE (Woodinville @ Jun 18 2012, 17:20) *
Except, Alexey, that signal (1, 0, 1, 0, ...) is only permissable if it's infinitely long. Otherwise, the signal that created that in the analog domain could not possibly have been properly sampled, as it has content outside -fs/2 to fs/2.

Right, it has to be infinitely long for summation to diverge. But you've missed my point about reconstructing signals that were never sampled, but rather just produced (or edited, or distorted) in digital.
If we only consider finite-length signals, then I agree that "perfect" reconstruction (down to a quantization step) is achievable, but the filters should be quite long.
Go to the top of the page
+Quote Post
Woodinville
post Jun 19 2012, 00:25
Post #62





Group: Members
Posts: 1402
Joined: 9-January 05
From: JJ's office.
Member No.: 18957



QUOTE (Alexey Lukin @ Jun 18 2012, 14:43) *
QUOTE (Woodinville @ Jun 18 2012, 17:20) *
Except, Alexey, that signal (1, 0, 1, 0, ...) is only permissable if it's infinitely long. Otherwise, the signal that created that in the analog domain could not possibly have been properly sampled, as it has content outside -fs/2 to fs/2.

Right, it has to be infinitely long for summation to diverge. But you've missed my point about reconstructing signals that were never sampled, but rather just produced (or edited, or distorted) in digital.
If we only consider finite-length signals, then I agree that "perfect" reconstruction (down to a quantization step) is achievable, but the filters should be quite long.


Oh, sorry, missed that. We agree then.


--------------------
-----
J. D. (jj) Johnston
Go to the top of the page
+Quote Post
bandpass
post Jun 26 2012, 16:43
Post #63





Group: Members
Posts: 326
Joined: 3-August 08
From: UK
Member No.: 56644



QUOTE (Alexey Lukin @ Jun 18 2012, 16:47) *
Many engineers consider "bit transparent" to be the same as "diff signal not audible".

Many people like FLAC because it's zero-risk, even if they can't discern an audible difference between it and say, 320kb/s mp3.

So perhaps folk would also like to use a demonstrably bit-perfect resampler, as far as that is possible.

If one generates two files with 0-24kHz sine sweeps (with tails, as described above) at two different sample rates >= 48kHz, then one should be able to resample one, and obtain the other (subject to slight trimming).

If, after trimming away t% of the high end of the sweep, the difference signal is < 2-n-1, then one could claim that the resampler is n-bit transparent to 100-t % (band occupancy).

So a resampler's performance (perhaps at a site like the infinitewaves one) could be given in just two numbers (okay, you might want to add a range of rate-changes over which it has been tested).

For example, after a quick check with libsamplerate: after trimming the top 7% of the resampled sweep, I get a difference signal peaking at ~-128dB ~= 2-21.2, so this resampler is 20-bit transparent, to 93%.
Go to the top of the page
+Quote Post
Alexey Lukin
post Jun 26 2012, 17:56
Post #64





Group: Members
Posts: 191
Joined: 31-July 08
Member No.: 56508



This test may not exactly work for many resamplers because of subsample signal shifts. Resamplers do not usually guarantee some particular timing or latency of the resampled signal.
Go to the top of the page
+Quote Post
Alexey Lukin
post Jun 26 2012, 17:58
Post #65





Group: Members
Posts: 191
Joined: 31-July 08
Member No.: 56508



For example, when resampling a 3-point file from 88k to 44k, where should the first point go? There are at least 2 options which seem logical; and they result in different latencies.
Go to the top of the page
+Quote Post
bandpass
post Jun 26 2012, 21:15
Post #66





Group: Members
Posts: 326
Joined: 3-August 08
From: UK
Member No.: 56644



QUOTE (Alexey Lukin @ Jun 26 2012, 17:58) *
For example, when resampling a 3-point file from 88k to 44k, where should the first point go? There are at least 2 options which seem logical; and they result in different latencies.

Given that the test above worked, libsamplerate and the sweep generator agree that time starts at 0. However, it doesn't matter so much: it's just one of the details of the test that would have to be well-defined for it to become a useful standard.

QUOTE (Alexey Lukin @ Jun 26 2012, 17:56) *
This test may not exactly work for many resamplers because of subsample signal shifts. Resamplers do not usually guarantee some particular timing or latency of the resampled signal.

Well, there'd be no point in coming up with a new test if every resampler were currently expected to pass it. But it's a very powerful test: if you happen to need a resampler with zero group delay then this test determines that—and that every other aspect of the implementation is correct.

People tend to want (at least the option of) perfection wherever they believe it should be possible to have it: in their playback chain, from their de-emphasis filter, in file compression; if it's available, they'll want it from their resampler too. If folk find it a useful test, then those resamplers that don't currently pass it would probably 'fall in behind' it, much like, for example, with the 'acid test' for web browsers.

Maybe we could save a little energy too: if people understand they're getting 'bit-perfect' conversion at standard settings, they might think twice before using the 200dB (in some cases) stop-band rejection option all the time.
Go to the top of the page
+Quote Post
benski
post Jun 26 2012, 21:18
Post #67


Winamp Developer


Group: Developer
Posts: 670
Joined: 17-July 05
From: Brooklyn, NY
Member No.: 23375



Setting aside floating point precision issues, you should be able to achieve bit-perfect conversion by selecting a filter kernel of length 2n+1. However, this is going to be a VERY large (and slow) filter, especially on the downsampling filter in non-integer ratios (e.g. 44.1kHz->48kHz)
Go to the top of the page
+Quote Post
Alexey Lukin
post Jun 26 2012, 21:33
Post #68





Group: Members
Posts: 191
Joined: 31-July 08
Member No.: 56508



bandpass, I understand your point. This is a good test, when it works.
Go to the top of the page
+Quote Post
knutinh
post Jun 27 2012, 10:00
Post #69





Group: Members
Posts: 569
Joined: 1-November 06
Member No.: 37047



QUOTE (greynol @ Jun 18 2012, 23:16) *
QUOTE (knutinh @ Jun 18 2012, 12:25) *
But a _file_ of finite length contains only a (finite) discrete set of frequencies?

The answer is no. smile.gif

I dont understand your post. Please elaborate.

A finite size file contains finite information. How can it contain anything but a finite set of frequencies?

-k
Go to the top of the page
+Quote Post
knutinh
post Jun 27 2012, 10:06
Post #70





Group: Members
Posts: 569
Joined: 1-November 06
Member No.: 37047



QUOTE (benski @ Jun 26 2012, 22:18) *
Setting aside floating point precision issues, you should be able to achieve bit-perfect conversion by selecting a filter kernel of length 2n+1. However, this is going to be a VERY large (and slow) filter, especially on the downsampling filter in non-integer ratios (e.g. 44.1kHz->48kHz)

Are you talking about regular zero-insertion->convolution->sample dropping? What is "n"?

As long as the filter has a transition-band between passband and stop-band, ripple in the passband and finite attenuation in the stop-band, how can such resampling be theoretically flawless (in practice, for our application, it probably will be)?

-k
Go to the top of the page
+Quote Post
bandpass
post Jun 27 2012, 10:27
Post #71





Group: Members
Posts: 326
Joined: 3-August 08
From: UK
Member No.: 56644



Whether or not perfect resampling is theoretically possible, I think we've established above that it's not practical.

The only way to demonstrate bit-perfect conversion with a resampler you might actually want to use for real tasks, is to band-limit the signal, just a tad, e.g. by pre-filtering a real-world signal, or by using a generated test-signal.

With a pre-filtered real-world signal, the demonstration would have to be 'round trip' (which has issues re the validity of the intermediate signal); with a generated signal, the demonstration can be of a single conversion.
Go to the top of the page
+Quote Post

3 Pages V  < 1 2 3
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: 24th July 2014 - 10:49