[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: Julius Smith (jos_AT_w3k.org)
Date: la syys   04 1999 - 21:11:16 EDT


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.

In that case you could upsample once when loading the .wav file
using a high-quality converter. This would increase the load time, of course,
which could be a problem if you want to support dynamic loading of wave files
in response to MIDI "program select" during a musical performance.

>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.

I'm not sure I understand what you're saying, but when you are doing interpolation, you
never have to play back at any rate other than the final one you want.
That's what interpolation is for. The quality of the interpolation is
an independent issue controlled by wavetable samping density and interpolation-filter
quality (number of multiply-adds and coefficients used).

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

Not if your table is oversampled enough. With a sufficiently oversampled wavetable,
the audible distortion is ZERO with linear interpolation.

>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 CPU load should be constant when going down in pitch. In that case, the
waveform is interpolated to many samples per sample, and
the filter length stays fixed.

>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.

Going up in pitch, the wavetable has to be decimated. That requires anti-aliasing
filtering, and the farther up you shift, the more filtering is required. This is a basic
fact no matter what interpolation method you use.

If you want, you can also fix the filter length
used in bandlimited interpolation, but this will give a poorer result because
the filter really should get longer to carve away more and more of
the original signal band.

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

At that high a frequency, I'd use elliptic. (Chebyshev is next best.)
In floating-point, 6th order is not too high from a coefficient-precision point
of view, if that's what you're asking.

>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 ?

The correct comparison would be

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

and then listen to how they sound.
In other words, either method can be implemented at pretty much
any complexity level, so just make them be the same, run some listening tests,
and choose the best one.

Julius


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