Re: [linux-audio-dev] [newbie] mixing audio streams

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] [newbie] mixing audio streams
From: Jan Weil (Jan.Weil_AT_web.de)
Date: Sat Mar 13 2004 - 19:49:25 EET


Hi,

On Sat, 2004-03-13 at 17:13, Alex Marandon wrote:

[snip clipping problem]

>
> /* -- mixage, cf. http://www.vttoth.com/digimix.htm -- */
> for ( i = 0; i <= BUFFER_SIZE; i++ ) {
> mixed_buffer[i]
> = buffer1[i] + buffer2[i] - buffer1[i] * buffer2[i] / DYNAMIC_RANGE;
> }
>

buffer1 is declared as a short (i. e. usually 16 bits).
I'd guess this introduces your clipping problems.
Try this instead:

mixed_buffer[i] = buffer1[i] + buffer2[i] -
                (long) buffer1[i] * buffer2[i] / DYNAMIC_RANGE;

HTH,

Jan


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sat Mar 13 2004 - 19:48:42 EET