Jump to content
  • Advertisement
Sign in to follow this  
ajm113

Get position of a sound being played? (C++/OpenAL)

This topic is 3608 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to know if I can get the position of a song being played in OpenAL in a float form, like 1.0 would mean one minute or etc that I can retrieve off a song? I am fallowing this tutorial series accurately. Open AL Lesson 1

Share this post


Link to post
Share on other sites
Advertisement
It would be worth your time to check out the openAL programmer's guide that comes with the SDK. Its got all sorts of goodies!
From that:
Quote:

Under: Source Properties
Each source generated by alGenSources has properties which can be set or retrieved.
The alSource[f, 3f, fv, i] and alGetSource[f, 3f, fv, i] families of functions can be used to set or retrieve the following source properties:
...
AL_SEC_OFFSET f, fv, i, iv the playback position, expressed in seconds
AL_SAMPLE_OFFSET f, fv, i, iv the playback position, expressed in samples
AL_BYTE_OFFSET f, fv, i, iv the playback position, expressed in bytes
...


So you can get the playback position in seconds and divide by 60 to get your normalized time.

float pos = 0;
alGetSourcef( sourceID, AL_SEC_OFFSET, &pos );
float normalizedPos = pos / 60.0f;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!