[linux-audio-dev] linear resampling is crap ? (was: fast linear resampling on ARM - suggestions?)

Erik de Castro Lopo mle+la at mega-nerd.com
Sat Apr 1 11:11:34 UTC 2006


Stefan Westerfeld wrote:

> First algorithm: upsample by factor 2 (you can use my code as it is),
> then use linear interpolation. Why this is better than plain linear
> interpolation? Because low frequency signals can be better approximated
> by lines than high frequency signals, and after upsampling by factor 2
> your signals will tend to be low frequency signals.
> 
> Second algorithm: perform factor N upsampling (for instance factor 16
> upsampling), then use linear interpolation. The quality should become
> even better. The performance will not suck as badly as "factor 16
> upsampling" sounds, because you only need to compute those sample values
> that you need to do linear interpolation.

Upsampling followed by linear resampling can be a good approach. Linear 
resampling can produce high quality results if you can guarantee that the 
input signal is strictly band limited well below half the sample rate. I 
even have some rough figures for this on page 11 of this paper which was
given at the Audio Miniconf attached to 2005 Linux.conf.au :

    http://www.mega-nerd.com/tmp/secret_rabbit_code.pdf

    For the case of upsampling from 44100Hz to 48000Hz, with the source
    signal consisting of a single sine wave, I got the following SNR
    values:

                    Sine Freq    Signal to Noise ratio
                       333 Hz                146.0 dB
                       666 Hz                115.8 dB
                      1332 Hz                103.8 dB
                      2664 Hz                 49.8 dB
                      5328 Hz                 38.7 dB
                     10656 Hz                 28.4 dB
                     21312 Hz                 19.5 dB

However, beware that the upsample followed by linear resampling will
only work correctly when the output sample rate is greater than the
input sample rate. When this is not the case, extra filtering is needed
on the input side which complicates things somewhat.

> As for quality, I'd really like to know what quality can be attained by
> this approach at what speed. Could it even outperform libsrc on both,
> quality and performance, under some circumstances?

Linear resampling can outperfrom the best resampler in libsamplerate
under some conditions. That still doesn't make linear resampling a
good idea unless you can be 100% sure that your data *always* fits
the specific conditions where linear resampling performs well.

I'll say it again, libsamplerate is a *general purpose* resampler.
For any pair of constant input and output sample rates, it has a well 
specified worst case behaviour of greater than 96 db SNR. On top of
that, it *also* handles the case where the ratio between input and 
output sample rates is not constant.

Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"Unix and C are the ultimate computer viruses." -- Richard P Gabriel



More information about the Linux-audio-dev mailing list