I have a simple implementation, player jumps and it plays the jump sound. But the volume randomly drops. Weirdly enough, if I call the sound twice this doesn’t happen.
Here’s all the related code for sounds:
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0)
///
Mix_Volume(-1, 0.1 * MIX_MAX_VOLUME);
///
void GAppMain::play_sounds()
{
if (mPlayJumpSound) {
/// this solution (sending jump sound to two channels) is ugly but it seems to work; find a better one
Mix_PlayChannel( 1, GData::Assets::GR_Sounds.back().mData, 0 );
Mix_PlayChannel( 2, GData::Assets::GR_Sounds.back().mData, 0 );
}
///
}
Even if I let if be -1
(to let SDL choose the channel) but call only once like this
Mix_PlayChannel( -1, GData::Assets::GR_Sounds.back().mData, 0 );
The volume drops, comes back, drops.
Any ideas?