[SDL] In need of audio advice

Alan Beltran alan.beltran at jcu.edu.au
Tue Dec 10 20:39:01 PST 2002


Im trying to continuesly play a set of chunks within a single channel.
eg 0 is a chunk of type A, 1 is a chunk of type B.

channel 1:      0 1 0 1 1 0         -> play continuesly    
                - - - - - -

channel 2:      1 0 1 0 0 0         -> play continuesly
                - - - - - -

Mix_PlayChannel enables me to only play 1 chunk per channel continuesly which is
a problem since i plan to to play an array of chunks continuesly.  What i
originally did was create 3 SDL threads, each corresponding to a single channel.
Each thread would then play each chunk within an array continuesly and
concurrently with other threads.

eg:
channel_1_thread()
{
        while(true) {
                for(int i=0;i<10;++i)
                   Mix_PlayChannel(1, &chunkArray1[i], 0);
        }
}
channel_2_thread()
{
         ........ {
           ............
              Mix_PlayChannel(2, &chunkArray2[i], 0);
        }
}
This did work, however as more threads where executed concurrently, latency
between chunks became significantly evident.  Is there an efficient way i can
achieve this using SDL????

Any help is dearly appreciated.
cheers
Alan 







More information about the SDL mailing list