[PD] a little pitchshifter
Charles Henry
czhenry at gmail.com
Wed Mar 7 02:19:54 CET 2007
> 2007/3/6, Peter Worth <peterworth2 at googlemail.com>:
> > i kind of hoped that tabread4 would do some kind of interpolation
> > which might magically stop aliasing..
hmmm.... could we have some way of interpolating, just short of magic,
that would stop aliasing during downsampling?
tabread4~ takes an input of the integer/non-integer value to look up
in the table. What if, as a function of the derivative of this signal
input, we could adjust the interpolating function to eliminate high
frequencies that would be aliased?
first off, any interpolating polynomial causes distortion. First
place to start is with the sinc function, which is not a polynomial.
sinc(t)=sin(pi*t)/t
It is the optimal interpolating function for band-limited signals, and
is valid when the signals are infinitely long. Over all frequencies
less than the Nyquist frequency, the continuous signal is exactly as
it was before sampling. There is some funkiness at exactly the
Nyquist frequency, because only the cosine component (using
real-valued signals) is left after sampling. (This is always a good
case to consider first)
sinc(fs*t) has a spectrum of unity for frequencies between -fs/2 and
fs/2. Now suppose we want to use the sinc as an interpolating
function, where the playback speed is increased. Then we get rid of
the excess spectrum, to eliminate aliasing.
Where we have a playback speed of k (where k>1) we can modify our
interpolating function to sinc(fs*t/k), changing the spectrum to
-fs/(2k) to fs/(2k), preventing aliasing.
So, there's a lesson to be learned from the sinc function. If we
wanted to interpolate values at a higher speed that normal, we would
stretch our interpolating function out over a longer time.
If we take Lagrange interpolating polynomials and continue to increase
the degree, we will get successively better approximations to the sinc
function. *But* the polynomials will always have infinite frequency
content--They are not band-limited, but they are compact.
Possibly, we could take these polynomials, and just stretch them out,
like the sinc, to get comparable performance (not perfect, but quick)
There's another way to interpolate values that is based on Fourier
Transforms. Taking our signal, we compute a discrete fourier
transform, and replace the discrete vectors of the inverse transform
with continuous functions. Then, we have a continuous signal that
interpolates in between samples, and to play at higher speeds, we
would throw away the higher frequencies, to prevent aliasing.
Using this method, our interpolating function of order N becomes
(2/N)*[1+sum{ j=1:N/2 ; cos(pi*t*fs*j) }
We could limit the number N to say, 4 or 8, and throw away some of the
cosines as needed.
The fourier method, I just mentioned, is not in fact a good
interpolator, but if you were playing back at higher speeds than
normal, I don't think it should matter.
Somebody, please give me a job. I have nothing to do at the machine
shop except analyze math problems while running the CNC. Well, later,
Chuck
More information about the Pd-list
mailing list