Hello Guest

Coding manual counted sound looping

  • 0 Replies
  • 4605 Views
Coding manual counted sound looping
« on: May 10, 2006, 09:43:09 »
Hello people !

I'm currently developping an Swing Application producing sounds using Lwjgl's openAl.
One of the thousand mighty features of this application is to loop played sounds a specified number of times.

I did not find anything in current lwjgl anything that would make things easy for me.
Here's what i'm trying to do:
Quote
public void run(){
int looped =0;
while ( this.loop && looped<this.nbLoop ){
___AL10.alSourcePlay(this.source);
___while(AL10.AL_PLAYING==AL10.alGetSourcei(this.source.get(0), AL10.AL_SOURCE_STATE))
______if ( this.stop)
_________break;
___looped++;
}
return;
}

Code has been simplified for the purpose of explanation.
Basically this runs in a thread.
loop is a boolean specifying the sound to loop or not
nbLoop is an integer specifying the number of loop the thread must run.
I make the sound play and try to detect when the sound is no more played. When sound has been played, depending on settings, it'll be played again or not.

Well this*could* be working. The big problem is that it does hang the system. And you probably guessed it, it's in the "while playing" loop.
I could not find a better way to be sure to detect the exact time when the sound is over.

Anyone has a tip to help me get through this please ?
Many thanks.

-Maxime
size=9]Current project:DjPerf[/size]