Re: Music decompression and resampling




"Stefan Monnier" <monnier@xxxxxxxxxxxxxxxx> wrote in message
news:jwvlku4m9y2.fsf-monnier+comp.compression@xxxxxxxxxx
Faced with the need to resample (from 44.1 to 48 KHz) some music that
I have in lossy compressed form (Ogg and MP3 in this case), I started to
wonder whether it wouldn't be better to do the resampling as part of the
decompression rather than as a separate step.

I doubt it personally.

also, you are doing upsampling, which is fairly easy to implement and
fairly
cheap using linear interpolation.

Linear interpolation from 44.1 to 48KHz results is really poor
sound quality. And I'm not anal-retentive about my sound quality (I use
a crappy old $100 stereo with a $10 USB soundcard and the aliasing
introduced by linear upsampling is very noticeable).

dunno, not having tried it.

in my case I had usually gotten acceptable results, eg, using linear
interpolation between, eg, 8kHz and 11kHz...

then again, in my case I often wasn't worrying too much about quality (in
these cases often introducing much more destructive algos as well...).


"Stefan Monnier" <monnier@xxxxxxxxxxxxxxxx> wrote in message
news:jwvfykcm9p1.fsf-monnier+comp.compression@xxxxxxxxxx
now, I am using floats, but this is not a big deal anymore (floats are
fast enough, the gains of fixed point likely being fairly minor here).

I'm decompressing&resampling on an embedded 125MHz MIPS processor without
FPU support, where the difference is very noticeable (the standard Vorbis
decompressor cannot do the job in real-time, whereas the Tremor
decompressor
that uses fixed-point only needs 40% CPU to keep up).

ok, in that case, the changes needed for fixed point are fairly minor (I had
just assumed here you were working on a typical desktop processor, so
yeah...).


looking around, seems like most of the links for interpolation lead to
highly mathy answers (as it was for prediction), so I am lazy and more
likely to beat against the problem manually. the problem though I think is
making the interpolator "fast enough" when going above linear interpolation.

trial and error, got a working-seeming quadratic interpolator:
x=0.25;
k=(c-(2*b-a));
f=(0.125*(1.0-4*(x-0.5)*(x-0.5)));
g=b*(1-x) + c*x - k*f;

for samples a, b, and c, where:
x is a value between b and c;
k is a linear error for predicting c;
f is a curve effecting the weight of k in the result (note, the 0.125 was
trial and errored out as well, and may have something to do with "slope" for
all I know, then again, it may be a constant, the actual slope being
contained entirely in k);
g is the prediction (a modified linear prediction, f*k gives the predicted
error).

cubic could be similar, but maybe more complex, I don't know...

a guess: the cubic variety (a, b, c, d, between b and c) would likely
consist of adding another linear predictor going backwards (predicting b
from c and d), and offsetting by another error, but I don't know here...


Stefan


.



Relevant Pages

  • Re: Interpolating PCGS Price Guide?
    ... Can one do a simple interpolation to arrive at the price ... The link is to some graphs for a few different US coins relating grade ... it looks like the linear interpolation is OK ...
    (rec.collecting.coins)
  • Re: forecasting?
    ... more, you could try linear in 1/SQRT, leading to 41.4 at week 7. ... prediction tighter than "somewhere between 39 and 49" is no more than a guess. ... but its prediction is likely an upper bound for the week ... seems presumptuous in the absence of external knowledge of the physical ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Array Type programming
    ... you asking how to do a linear interpolation. ... Generally, when asked to do an interpolation between table values, ... and the temperature is +10 above the standard ... > temperature range, the climb fuel will be 2345kgs, and the ...
    (microsoft.public.excel.programming)
  • Re: how to express weighted average in this case?
    ... Randy Poe wrote: ... You've just re-invented Lagrange interpolation. ... it won't always lie in the triangle. ... How about piecewise linear interpolation? ...
    (sci.math)
  • Re: how to express weighted average in this case?
    ... You've just re-invented Lagrange interpolation. ... As t varies from 1 to T, A will describe a curve which will ... it won't always lie in the triangle. ... How about piecewise linear interpolation? ...
    (sci.math)