LWJGL
May 20, 2013, 10:29:05 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.0 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Start sound with offset  (Read 1204 times)
Estraven
Regular nerd
**
Posts: 53


« on: November 29, 2010, 08:48:36 »

Hello everyone,

I'm using OpenAL to read wav files, however, I sometimes need to start playing other than from beginning.
Let's say, I've a 3minute wav, and I want to play it from 1min35sec the end.
How can I do that using OpenAL ? I've found alSourcePlay/Stop, but now way to control where to start.

Thanks,
Estraven.
Logged
jediTofu
Prolific Timewaster
****
Posts: 280



« Reply #1 on: December 07, 2010, 22:22:09 »

You'll need to use either AL11.AL_BYTE_OFFSET, AL11.AL_SAMPLE_OFFSET, or AL11.AL_SEC_OFFSET.
You'll probably want to use AL11.AL_SEC_OFFSET, but beware that it rounds the seconds as best it can to the bytes, so bytes and samples will be more accurate.

//Code:
IntBuffer secondsOffset = BufferUtils.createIntBuffer(1).put(5); //Play at 5 seconds in
secondsOffset.rewind();
AL11.alSource(source,AL11.AL_SEC_OFFSET,secondsOffset);
AL10.alSourcePlay(source);


It's kind of dumb that they didn't add this until version 1.1; I'm not sure if this was on purpose or on accident, unless there is another way to do this in version 1.0.  This code works for me though in LWJGL.  Cool
Logged

cool story, bro
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!