[openbeos] Re: Resampling algorithms for audio mixer

  • From: "François Revol" <revol@xxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Wed, 28 Nov 2007 21:45:25 +0100 CET

> 2007/11/27, cyanh256@xxxxxxxxxxxx <cyanh256@xxxxxxxxxxxx>:
> > The other thing I noticed while skimming through was that
> > there doesn't seem to be any kind of encoder state
> > preservation between calls to the resampling function.
> > When working with small buffers (typical of soundcard
> > buffers in BeOS -- I'm using a buffer size of 64 frames),
> > there's the danger of inaccuracies appearing at the initial
> > (or last) samples, which could become audible as a tone
> > at these buffer sizes. Providing some way for the function
> > to know what samples occured at the end of the previous
> > buffer (such as passing a state struct into the resampling
> > function) generally clears it up.
> 
> What about "interpolating remaining one sample behind the input
> buffer" (so that you cannot have to interpolate values beyond  the
> innput buffer) and passing the last 3 or 4 samples of the previous
> input buffer through a struct, as you suggested, so that the values
> you now have to inteprolate before the input buffer are well defined?
> 

Unless it's used elsewhere than the system mixer that shouldn't be a 
problem, just maintain a list of opaque cookies keyed on the 
media_destination (the input index).
Or put the state into a resampler object, and override a base class.
You'll need one object per input anyway as input rates will differ on 
each input and so must be stored somewhere.
There is no reason for an input to receive non-consecutive buffers, 
since it's connected to a single output, so it should be enough to 
store the state there.

François.

Other related posts: