Mail Archives: djgpp/1998/05/04/02:11:32
hi !
On Thu, 30 Apr 1998, Shadow Seeker wrote:
> >I'm diving further into sound programming and just got the wav part
> >to work.. Now i've been looking for info about sound mixing for
> >hours without finding anything comprehensible.. Is there someone out
> >there who holds the secret or know where it is?
>
>
> I solved this by creating four streaming buffers, four would be the number
> of channels you wish to use. And, you then take the average of the four
> buffers. And output that to the sound port like you would the data of a
> normal Wav file. Then when you wish to play a sound all you need to do is
> copy it to one of the channels.
>
> This is very basic, things get more complex when you wish to mix different
> frequencies, but it is mixing..
>
> \/\/outer
>
>
Your algorithm is too slow !
Leave the samples in memory.
Make 4 struct for channels:
typedef struct {
char *sample;
long bytesleft;
char volume;
} CHANNEL;
CHANNELS chans[4];
sample=NULL, if no sound on that channel.
When you want to hear a sound, you put the address of the sound to
chan[x]. you have to find an x, when the chan[x].sample=NULL.
You put the len of the sample in chan[x].bytesleft and the volume to
chan[x].volume;
I think you dont need the volume, but you can code that too.
The maximum volume for chan[].volume is 64. (if there are four channels)
You have to multiple the sample with volume, than >>8 ofcoz in asm.
Copying is too slow.
I tell you, my engine after mixing does some FILTERING.
But my engine is not in DJGPP, and it only supports Sound Blaster.
It is not enought !
-- Archee/CoNTRACT CODER ( 01dsolt AT vpg DOT hu )
oldnikk:stonee,sutyi
web: http://gondolat.vpg.hu/~01dsolt
- Raw text -