[linux-audio-dev] Re: Bandlimited interpolation suitable for realtime audio

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-dev] Re: Bandlimited interpolation suitable for realtime audio
From: Benno Senoner (sbenno_AT_gardena.net)
Date: pe syys   03 1999 - 19:57:28 EDT


Hello,

On Thu, 02 Sep 1999, Julius Smith wrote:
> Hi again,
>
>>
>
> >... my concern is that if we oversample by 2,
> >since we allow to sample-playback modules to be routed through various
> >modules like FX-processors , filters etc, we have to run the entire engine
> >at twice the samplefrequency, and this means twice the CPU load,
> >Is there no other way to allow flexible voicerouting AND avoiding
> >to run the entire engine at twice the samplefrequency ?
>
> The oversampling need only affect the wavetables themselves.
> It just means doubling the memory over what you would have had. Consider,
> for example, how it would work if you somehow encoded the wavetables as exact
> continuous functions. In principle, they would be oversampled by infinity.
> However, the playback oscillator just asks for them at intervals of the
> current sampling period (which can change to any value at any time, without
> regard for the "phase alignment" of the sampling points).

Ok, but we are speaking of sample playback engines,
that means I have arbitrary data (a WAV file) sampled that 44.1kHz , and want
to play the data at pitches up to 1 octave higher but without aliasing effects.
Assume we use only linear interpolation, and we want to play the data at
1.5 of the original pitch.
Without oversampling we would advance the source offset pointer by 1.5
on each step (step-size), and use interpolation (through evaluating non integer
part) the get the values of of samples at non-integer boundaries.
But in this case we are already in the aliasing area.

By oversampling by a factor of 2 , we reduce the stepsize to 0.75 with no
aliasing noise, but we have to play the data back at 88.2kHz,
or lowpassfilter the result at 20kHz, and then extract only the even (or odd)
samples and send the result to our 44.1kHz DAC.
Correct me please if I miss something.

If this is the only approach for oversampling, then the drawback is it's use of
in a comple audio engine like audiality,
since you have to run the entire signal-path at twice the samplingrate,
until you output the results to the DAC.
This is very expensive in terms of CPU usage.
Another approach could be to put a 20kHz lowpassfilter after each
polinomial interpolator/oversampler,
but that means if you play 30 voices on your soft-sampler you have to
activate 20 low-passfilters which means additional CPU consumption.

> >I think the overhead between linear and higher order polinomial
> >interpolation is not very big compared to using bandlimited interpolation,
> >(5-6 mulitiplications per sample is not very much)
>
> Ok, but if you compare, I think you'll find that quadratic interpolation is not nearly as big of an
> improvement over linear as linear interpolation is over no interpolation.
> The reason is that if the wavetable is very "smooth" (which can always be
> provided by densely sampling the original bandlimited audio), then the exact
> "Taylor series expansion" (infinite-order polynomial interpolation, if you
> will), has coefficients which rapidly decrease with order. In other words,
> linear interpolation will nail it to the last LSB if your table is oversampled
> enough, so that there's no reason to waste multiply-adds on higher-order
> interpolation. (You may need a few guard bits below.) The main appendix in
> my "theory of operation" paper gives a precise derivation of what I'm saying
> for the case in which the wavetable contains a sinc function. In that case,
> linear interpolation is "exact" to working provision provided there are a few
> hundred samples per zero-crossing of the sinc function stored in the
> wavetable. In a general wavetable synthesizer, this spec could translate to
> some number of samples per zero-crossing of the _highest harmonic_ present in
> the wavetable. Of course, when the highest harmonic is very weak (as it
> normally is), requirements are really less stringent than this. >

I want an interpolation method that has good quality , even when you play
the data at let's say -2 octaves, but does not use too much multiply-adds.

Using linear interpolating condributes to "edges" into the signal , which means
harmonic distortion.

I experimented a bit with the "natural cubic spline" ( 3rd order) ,
I tested this by sampling 2 periods (4*PI) of a pure sine ,
using 20 points.
for the first 17 samples the maximum error between interpolated signal
and original sine is about -68dB which is quite good if you consider that
there are only 10 points per 2PI period.
The last 3 samples show higher errors , up to -35dB, but I think this is
because the interpolator does not know how the sine wave continues.
It's interesting that the last sample is one step before the next zero cross,
and if I choose 21 points (therefore including the last zero cross),
the maximum error stays below the -68dB mark even for the last samples.
The algorithm takes about 12 multiplications per sample or so.

comments about this algorithm ?
(There seems to be some software aroung which uses the spline approach
to perform audio interpolation)

> Another point is that if you're willing to spend 5-6 mulitiplications per sample on interpolation,
>I don't believe polynomial interpolation is superior to bandlimited
>interpolation at that complexity level. To compare them, we have to view
>polynomial interpolation in terms of its frequency response as a "bandlimited
>interpolation filter". (After all, both methods simply implement time-varying
>linear filters on the original samples, so on that level they are equivalent
>--- they only differ fundamentally in the coefficients used.)

About the complexity level of bandlimited interpolation:

Using polinomial interpolation the number of multiplications per sample stays
constant, regardless of pitch, we just have to traverse the wave table faster
or slower.
Using bandlimited interpolation , lowering the pitch by 2 octaves produces four
times the CPU load of the playback at normal pitch.
The big advantage of bandlimited interpolation is that you can play the data
at higher pitches without aliasing problems + higher pitches = no increased CPU
load.
correct me please if I'm wrong.

> >Has the Spline approach ( 4th order) some signal quality advantages
> >(worst/best in terms of dB) over let's say quatratic/cubic interpolation ?
> >(assuming a max transposition range of -2 octaves / +1 octave).
>
> Well, it's order is one higher than cubic so it should be that much better than cubic.
> I consider all of these cases to fall under the topic of "Lagrange
> interpolation". An excellent reference, available online, is >

> TITLE = "Discrete-Time Modeling of Acoustic Tubes Using
> Fractional Delay Filters",
>
> It can be found online at
>
> http://www.acoustics.hut.fi/~vpv/publications/vesa_phd.html

nice paper , very heavy math .. :-)

But even this paper mentions something about Splines (only references) in
the Lagrange interpolation chapter.

> Ultimately, the question is how do you want to design the lowpass filter that guards against aliasing.
> The bandlimited interpolation formulation allows you to address that issue
> explicitly rather than just "getting what you get" with polynomial
> interpolation.

What kind of 20kHz lowpass filter would you recommend ?
Butterworth / Bessel / Chebyshev ? which order ? ( is 6th order to heavy ?)

Which factors are more important for sample-playback engines ?
(like impulse response , step response etc.)

I jus did a quick math:

let's assume a spline interpolator + 6th order ( 36dB/oct) Butterworth
lowpass at 20kHz
12 multiplications for the interpolator and 9 for the lowpass filter =
21 multiplications.

Let's assume playback at pitch -2 octaves:
nr.of multiplications / output-sample:

104 for bandlimited interpolation
21 for the cubic interpolation + lowpass filter.

correct ?

(David: your thoughts about quality vs. performance tradeoffs ?)

this page for interactive filter design with realtime-generated graphs is quite
nice.
http://www-users.cs.york.ac.uk/~fisher/mkfilter/

regards,
Benno.

Benno Senoner
E-Mail: sbenno_AT_gardena.net
Linux low-latency audio / scheduling latency benchmarks
http://www.gardena.net/benno/linux/audio


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:25:53 EST