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

From: Erik de Castro Lopo <mle+la@email-addr-hidden-nerd.com>
Date: Sat Apr 01 2006 - 14:11:34 EEST

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
Received on Sat Apr 1 16:15:05 2006

This archive was generated by hypermail 2.1.8 : Sat Apr 01 2006 - 16:15:05 EEST