Re: [linux-audio-dev] Mixing signals

From: Steve Harris <S.W.Harris@email-addr-hidden>
Date: Mon May 23 2005 - 12:24:24 EEST

On Mon, May 23, 2005 at 11:03:30 +0200, Richard Spindler wrote:
> On 5/23/05, Viceic Predrag <viceic@email-addr-hidden> wrote:
> > Could someone please help with this apparently simple problem?
>
> I'm not a "professional" either, but this is what I do:
>
> unsigned int TLData::MixChannels(float *A, float *B, float* out,
> unsigned int count)
> /*Mix function for (-1)-(1) float audio*/
> {
> unsigned int i;
> float *p_output = out;
> float *p_A = A;
> float *p_B = B;
> for ( i=count; i > 0;i--){
> if (*p_A<0 && *p_B<0) {
> *p_output =(*p_A+1)*(*p_B+1)-1;
> } else {
> *p_output =2*(*p_A+*p_B+2)-(*p_A+1)*(*p_B+1)-3;
> }
> p_output++;
> p_A++;
> p_B++;
>
> }
> return count;
> }

I've no idea what your trying to do cos I missed the original post, but
just FYI, you will generally be better off doing x[i] rather than *x and
incrementing x. Modern C compilers (eg. gcc 4) can vectorise array
operations as long as you dont obfuscate them with pointer maths.

- Steve
Received on Mon May 23 16:15:08 2005

This archive was generated by hypermail 2.1.8 : Mon May 23 2005 - 16:15:09 EEST