# Sounds interfering with music? (SDL_Mixer)

## Recommended Posts

My game is an action game, and as should be with action games, a lot is going on. However, I wouldn't expect to strain SDL_Mixer when playing two sounds at once. I'm initializing in a manner that seems to be normal enough:
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048)
Mix_AllocateChannels(64)

In the game, when two characters are hit at the same time, it triggers causes one of the "hit" sounds to play twice. In its current state, these are the only two sounds playing aside from the music. The sounds play without incident. The music, however, suffers a very audible quarter-second silence what may be either after, or shortly before the end of the sound. This is odd, because another hit sound can be triggered in the same manner (and MUCH more frequently, playing what may be up to 16 times at one point), but aside from the music maybe "fuzzing" a bit, it happens without incident. I've come to the conclusion that it's the file and/or sound data itself -- a .wav file being saved in Audacity. Is there any way to put a stop to this? Thanks in advance. NOTE: I've tried changing the format values, the buffer value, and the rate. Nothing.

##### Share on other sites
In what format is the music played (mp3/ogg/mod) ? I guess it's quite cpu heavy to mix 3 sounds together when music needs to be decoded like in mp3/ogg. Maybe you could try using mod for music playback ? I also encountered that using a smaller Audiobuffer (the 2048 in your example, i used 512) reduced sound stuttering on an ARM based machine(the GP2X) with SDL Mixer.

##### Share on other sites
I'm using .ogg. I'd like to stick to doing so, if only because I've never seen this encountered elsewhere and it's being brought about very erratically. I'm almost certain it's something being brought about by the specific sound itself, because the other one causes no such thing.

EDIT: Replaced the sound with something a helluva lot more high-quality and even longer than what I had before, absolutely no problem. I think the fact that the sound I was using is deep or something is messing things up. I'd love it if someone could clear this up.

**Same with the smaller sound. The new sound plays on top of itself over and over and the music is fine with it.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628294
• Total Posts
2981882

• 9
• 9
• 11
• 10
• 10