Mail Archives: djgpp/1999/08/13/15:07:03
Actually, adding is the correct way to do it. However, there are a few
things to be taken into account:
* The sample format (unsigned or signed, 8 or 16 bits [for egs] etc)
* The overflow that can occur when adding two samples. ie, the result
of adding the values is greater or lower than the greatest
representable value or lowest representable value respectively.
The usual way of dealing with 2nd is clipping, ie if:
sample = sample_a + sample_b
yields
sample > MAX_REPRESENTABLE_VALUE
then sample is made equal to MAX_REPRESENTABLE_VALUE. This generally
requires that sample is capable of holding values larger than MRV
(theoretically, at least twice as big).
The volume shouldn't "go through the roof" - in theory (and in
practice, if you are doing things right) the two sounds should sound
as if they are being played simultaneously.
Davin.
On Fri, 13 Aug 1999 11:11:19 +0100, "Michael Stewart"
<mike AT reggin DOT freeserve DOT co DOT uk> wrote:
>Sahab Yazdani wrote in message <37B1ED4C DOT 25700BCB AT geocities DOT com>...
>>Well I finally wrote my SoundCard Handler and its working properly.
>>
>>Now I have just one problem.
>>
>>I don't know how to mix two sounds together.
>>I tried adding them, but the volume just goes through the roof and only
>>the louder of the too is audiable.
>>
>>what I'm doing right now...
>>
>>mixingblock is a short int
>>and data is an unsigned char
>>
>>*mixingblock+=*data;
>>
>>and then _farnspokew-ing them to the actual buffer
>
>I've never done sound before but would it not be better to average the
>values rather than add them ?
>
>
__________________________________________________________
*** davmac - sharkin'!! davmac AT iname DOT com ***
my programming page: http://yoyo.cc.monash.edu.au/~davmac/
- Raw text -