Almost all games I know on arcades have allocated channels for each sound effect. So, all explosion sound effects are on PCM channel 0, for example. Thus, when a new effect starts playing, it stops the first and starts the second simultaneously. The way I do this in my engine is I have a certain amount of audio channels, and then I have a few functions to allocate those channels.
I have the "allocate this specific channel", which will only allow the channel you specify, and allocate it to a stream until it's over (I used this pretty much only for the music, on channel 0). Then I also have a "allocate any channel", which allocates from the list of free channels, except if one of the channels is playing the specified stream, in which case it will return that one instead.
So, an example sound effect function would be:
Code: Select all
void SFX_Explode1(void)
{
int chan = Audio_Allocate(AUDID_EXPLODE1);
Audio_PlayStream(chan, AUDID_EXPLODE1);
}
and an example music function would be:
Code: Select all
void MUSIC_Stage1(void)
{
int chan = Audio_AllocateFixed(0);
Audio_PlayStream(chan, AUDID_STAGE1);
}
Or something along those lines
