Re: Wav loop point support
Chris Robinson <[email protected]>
| Newsgroups | gmane.comp.lib.openal |
|---|---|
| Message-ID | <[email protected]> |
On Thursday 06 May 2010 3:54:09 am [email protected] wrote: > I put this into the discussion a while ago already, but somehow it got > lost. The last answer I got was that it shouldn't be to difficult to > implement it. But at the moment I have no idea where to start. Maybe > someone can give me a hint, so I could try it myself, since this would be > quite useful for me. We'd first need to decide on an API to specify the loop points, and define the behavior. Something like: alSourcei(sID, AL_LOOP_START, startpoint); alSourcei(sID, AL_LOOP_END, endpoint); // or ALint points[2] = { startpoint, endpoint }; alSourceiv(sID, AL_LOOP_POINTS, points); where the points are specified in (compressed) byte offsets; in other words, in relation to the size given to alBufferData. I considered sample offsets, but that may be difficult given that OpenAL can resample audio when loading it. If looping is off, or if the end point is effectively <= the start point, the points are ignored (doesn't loop or loops over the whole queue, respectively). Otherwise, when playback of the source reaches the end point, it loops back to the start point. If the current byte offset is before the start point, it will continue to play from its current position (it's not forced forward into the loop range). If the source offset is set to the end point or beyond, however, it would effectively become: newoffset = ((offset-startpoint)%(endpoint-startpoint)) + startpoint This would allow a looping source to have a lead-in before getting into the loop. Turning off looping while the source is playing would let it finish its current iteration before playing through a lead-out and stopping. The loop points are also implicitly clamped to 0 and the total size of the buffer queue. For instance, setting the loop start to MIN_INT and loop end to MAX_INT would make the source loop normally over all the buffers.. although querying the points would still give you back MIN_INT and MAX_INT. Additionally for buffer queues, if the start point is past the end of one or more buffers, those buffers will NOT be marked processed when they finish playing. Any thoughts or comments? _______________________________________________ Openal mailing list [email protected] http://opensource.creative.com/mailman/listinfo/openal