Hi to all i hope you can help me out.
I use SDL for an OpenSource 2D fight engine called
OpenMugen(http://openmugen.sourceforge.net/)
Every thing works fine but i have a problem with SDL_mixer.
The problem is when i play a sample to a channel it delays about a sec
between the
call of the Mix_PlaySample and the hear of the sound.
I using Dev-C++ with Mingw/GCC 3.4.2 compiler.
here the code for playing the sample
int CSoundSystem::PlaySample(Mix_Chunk *wave_chunk,int channel,bool
bLooped,u8 leftPan,u8 rightPan)
{
channel = Mix_PlayChannel( 1 , wave_chunk ,0); //fixed channel to
1 for testing
if( channel == -1)
PrintMessage("CSoundSystem::Unable to play sound \"%s\"",Mix_GetError());
//Set the panning
Mix_SetPanning(channel,leftPan,rightPan);
return channel;
}
here the code for SDL_mixer init
bool CSoundSystem::InitSound()
{
PrintMessage("----Init SoundSytem----");
//check version
SDL_version compile_version;
MIX_VERSION(&compile_version);
PrintMessage(“compiled with SDL_mixer version: %d.%d.%d”,
compile_version.major,
compile_version.minor,
compile_version.patch);
const SDL_version *linked = Mix_Linked_Version();
PrintMessage(“inked with SDL_mixer version: %d.%d.%d”,
linked->major,
linked->minor,
linked->patch);
if( Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 4096) == -1)
throw(CError(“Unable to init SDL_mixer”));
// Mix_SetPostMix(noEffect,0);
Mix_AllocateChannels(MIXER_NUMBER_CHANNELS);
//MIXER_NUMBER_CHANNELS = 32
PrintMessage("----End of Init SoundSytem----");
return true;
}
PS.
I also tryed different sound buffer sizes from 128 to 8192;