Re: finite number of repetitions playing an audio source

Chris Robinson <[email protected]>
Newsgroups gmane.comp.lib.openal
Message-ID <[email protected]>
On Monday, May 31, 2010 4:44:33 am [email protected] wrote:
> Hi all
> 
> How can I set a finite number of repetitions playing an audio source? Is
> there another way instead of buffer
> queuing?

Hi.

There isn't, unfortunately. It may be something that could be added in the 
future, but for now, buffer queues would be needed unless you feel like 
monitoring the source's offset closely. You could set AL_LOOPING_ to AL_TRUE, 
then every time the current offset is less than the last offset, a loop 
occurred. When the appropriate count is reached, set AL_LOOPING to AL_FALSE.

It's not too difficult to use a queue, though, and doesn't run the risk of you 
missing a loop. You can queue the same buffer any number of times, and it 
won't negatively affect memory use. So you could set:

alSourcei(source, AL_LOOPING, AL_FALSE);
for(int i = 0;i < loopcount+1;i++)
    alSourceQueueBuffers(source, 1, &buffer);
alSourcePlay(source);

and it will loop the buffer loopcount times, then stop. To get the offset 
within the buffer, take the result of sourceoffset%bufferlength.
_______________________________________________
Openal mailing list
[email protected]
http://opensource.creative.com/mailman/listinfo/openal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.