Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Why is perfect resampling impossible? (Read 26615 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Why is perfect resampling impossible?

Reply #50
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.

Why is perfect resampling impossible?

Reply #51
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.

Why is perfect resampling impossible?

Reply #52
Many engineers consider "bit transparent" to be the same as "diff signal not audible".

Why is perfect resampling impossible?

Reply #53
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 ...}

Why is perfect resampling impossible?

Reply #54
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.

Why is perfect resampling impossible?

Reply #55
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.)"

Why is perfect resampling impossible?

Reply #56
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


Why is perfect resampling impossible?

Reply #58
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

Why is perfect resampling impossible?

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

The answer is no.


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

Why is perfect resampling impossible?

Reply #60
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.

Why is perfect resampling impossible?

Reply #61
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

Why is perfect resampling impossible?

Reply #62
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%.

Why is perfect resampling impossible?

Reply #63
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.

Why is perfect resampling impossible?

Reply #64
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.

Why is perfect resampling impossible?

Reply #65
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.

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.

Why is perfect resampling impossible?

Reply #66
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)

Why is perfect resampling impossible?

Reply #67
bandpass, I understand your point. This is a good test, when it works.


 

Why is perfect resampling impossible?

Reply #69
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

Why is perfect resampling impossible?

Reply #70
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.