SDL_Mixer Chunks Are Unsynchronized

Started by
0 comments, last by GenuineXP 18 years, 7 months ago
I'm adding some sound methods to some of my classes for my project but just ran into some trouble. I can load and play chunks just fine using SDL_Mixer, but they're way too delayed! I'm using a 1024 byte chunk size, and even tried setting the chunk size to zero! No matter what, I seem to get the same latency. At the moment, I have a series of blocks that drop down from the top of the screen, in a Tertis-like way. When they reach the top of another block or the bottom of the screen, they play a "thud!" chunk. The problem is, they play this "thud!" chunk at least a second after they've hit the bottom! It doesn't look or sound right at all. Is there a way to fix this? If not... then I don't see what good SDL_Mixer is except for playing music. I must be doing something wrong. :-( Any ideas? Thanks!
Advertisement
Maybe this will help. Here's my member function for playing sounds.

int obj::PlayChunk( Mix_Chunk* chnkSnd, int iLoop ){    int i;    int iNChns = Mix_AllocateChannels( -1 );    for ( i = 0; i < iNChns; i++ )    {        if ( Mix_Playing( i ) == 0 )        {            break;        }    }    if ( i == iNChns ) // ALL CHANNELS WERE IN USE    {        Mix_AllocateChannels( iNChns + 1 ); // ADD A NEW CHANNEL    }    if ( Mix_PlayChannel( i, chnkSnd, iLoop ) == -1 )    {        return -1;    }    return 0;}


I've tried just calling Mix_PlayChannel without any extra code, but that didn't help. (I thought that maybe checking for and allocating channels was slowing it down.)

So what's up? :-P Any help is appreciated.

This topic is closed to new replies.

Advertisement