DSPRelated.com
Forums

mixing pcm

Started by Willy March 17, 2006
hello,

be aware, I'm new to DSP algorithms :)

I have more pcm streams. first I have to change the sample rates of
some pcm streams and than I have to "add"  all streams in a (new) pcm
stream (with a given sample rate).
How can I do this?

As I read on the dspguru.com, changing the sample rate might be done
with using multirate algorithm. But how can I do the "sampling" of
the streams?

Thanks.

Cheers,
Willy

Do you have access to the samples in a memory buffer? I am not a guru
in DSP either, but I did some audio programming on the PC.

What you can do is calculate a fixed point divisor of the sample rate
and your output rate.
Say if your sample rate is not higher than 65535, then you can use
16.16 fixed point

So basically to get this increment
(sample rate << 16) / output rate

This will give you a 32bit value (assuming you are doing a 32/16 div)
and then the upper 16bits will have your whole increment and the lower
your fractional output.

Now just have a running counter, repeatedly add this 32-bit value to an
accumulator, and take the high 16-bits as an index to the sample
buffer. If you are in fact "sampling" your samples, than you can use
this number to decide when to skip a sample in the output.

-Isaac

Sorry I forgot to add, that you must add for every output sample sent.

"Willy" <backhaus_willy@yahoo.de> writes:

> hello, > > be aware, I'm new to DSP algorithms :) > > I have more pcm streams. first I have to change the sample rates of > some pcm streams and than I have to "add" all streams in a (new) pcm > stream (with a given sample rate). > How can I do this? > > As I read on the dspguru.com, changing the sample rate might be done > with using multirate algorithm. But how can I do the "sampling" of > the streams?
Willy, Sample rate conversion is a non-trivial task, in general. Even just adding two streams together at the same sample rate can be more involved than you might suspect. We can try to help you here, but beware this is not really a project for a beginner. To proceed, give details on the input stream sample rate(s) and the output stream sample rate. -- % Randy Yates % "Rollin' and riding and slippin' and %% Fuquay-Varina, NC % sliding, it's magic." %%% 919-577-9882 % %%%% <yates@ieee.org> % 'Living' Thing', *A New World Record*, ELO http://home.earthlink.net/~yatescr