Forums

Live audio resampling problem!

Started by Unknown December 18, 2007
I am trying to decode audio streams sent from an arm board,
unfortunely the clock on the arm board can vary from time to time, as
a result the wave sample rate varies.
To keep high audio quality, the delay must be kept constant. Can
anyone give me some advice? Do I have to design a resample algorithm
whose conversion rate can be changed from time to time?
On Dec 18, 1:37 pm, "何必" <iseelin...@gmail.com> wrote:
> I am trying to decode audio streams sent from an arm board, > unfortunely the clock on the arm board can vary from time to time, as > a result the wave sample rate varies. > To keep high audio quality, the delay must be kept constant. Can > anyone give me some advice? Do I have to design a resample algorithm > whose conversion rate can be changed from time to time?
One solution is to keep a FIFO audio buffer on the receiving end and monitor how full it is. Adjust the sample rate of the audio entering the buffer so that it stays half full. A disadvantage of this solution is that the pitch of the audio will change when the sample rate does. It could trip up certain tone decoders, or it could be audible. Another solution is to drop/insert samples, but that can introduce audible clicks. John
On Dec 19, 5:15 am, John <sampson...@gmail.com> wrote:
> On Dec 18, 1:37 pm, "何必" <iseelin...@gmail.com> wrote: > > > I am trying to decode audio streams sent from an arm board, > > unfortunely the clock on the arm board can vary from time to time, as > > a result the wave sample rate varies. > > To keep high audio quality, the delay must be kept constant. Can > > anyone give me some advice? Do I have to design a resample algorithm > > whose conversion rate can be changed from time to time? > > One solution is to keep a FIFO audio buffer on the receiving end and > monitor how full it is. Adjust the sample rate of the audio entering > the buffer so that it stays half full. A disadvantage of this solution > is that the pitch of the audio will change when the sample rate does. > It could trip up certain tone decoders, or it could be audible. > > Another solution is to drop/insert samples, but that can introduce > audible clicks. > > John
I try to keep a FIFO buffer and adjust the sample rate using the this resample kit: http://www-ccrma.stanford.edu/~jobs/resample But I find that the quality of the resampled audio is not so good, audible noise is added? Can anyone tell me why?
Hello,

search for "interpolation".
In a nutshell, the idea is to find a suitable continuous function that
passes through the given samples at the input rate, and then evaluate said
function at the points in time where you would like to obtain samples at
the output rate.

There is some FIFO involved, and usually the interpolator looks "ahead"
for a couple of samples (in other words, there is some delay).

Here
http://yehar.com/dsp/deip.pdf
is a discussion of different techniques.

If you need a fast implementation in C that works reasonably well, check
out for example the interpolator from "fluid synth" on savannah.nongnu.org
in fluid_voice.c. 
It uses four-point Lagrange interpolation, if I remember correctly.

There may be danger of reinventing the wheel, because people have solved
this problem before. 
A patent search might turn up "something" - in quotation marks for a
reason.