开发者

openAL get/set offset in seconds

开发者 https://www.devze.com 2023-03-19 02:13 出处:网络
I use OpenAL to play background music. At one point, I need to get the exact current position on the track. I tried using alGetSourcef(_source, AL_SEC_OFFSET, &offset); and it works perfectly on i

I use OpenAL to play background music. At one point, I need to get the exact current position on the track. I tried using alGetSourcef(_source, AL_SEC_OFFSET, &offset); and it works perfectly on iOS 4, but on iOS 3 it returns an int (no decimal places). This is not accurate enough, as I need accuracy to at least 3 decimal places (I then use this offset info to jump to another point on the track, and a rounded down value means it ends up jumping to an inaccurate position).

Would it be possible to get the AL_SAMPLE_OFFSET or AL_BYTE_OFFSET and then convert that value to 开发者_Python百科seconds?

Sound file: 16bit PCM WAV with sample rate of 22050.


With a sample rate of 22050 samples per second, all you need to do is divide the sample offset by 22050 to get the time.

0

精彩评论

暂无评论...
验证码 换一张
取 消