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

Started by
0 comments, last by Slather 15 years, 4 months ago
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
Check out my open source code projects/libraries! My Homepage You may learn something.
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;

This topic is closed to new replies.

Advertisement