How to play a sound file using openAL command from particular time instant (Time input is double or float)
I want to know if there is a command in openAL that can be used to play a sound file from particular time instant ( seek time). Like if I am using a slider and slide it , once I release the slider, the sound file should play from that particular instant.
I have implemented it for iOS. But I have not found this openAL method that can play file from particular time instant.
alS开发者_如何学运维ourcei(sourceID, AL_BUFFER, 0);
alSourcei(sourceID, AL_BUFFER, bufferID);
// Set the pitch and gain of the source
alSourcef(sourceID, AL_PITCH, aPitch);
alSourcef(sourceID, AL_GAIN, aGain * fxVolume);
if(aLoop) {
alSourcei(sourceID, AL_LOOPING, AL_TRUE);
} else {
alSourcei(sourceID, AL_LOOPING, AL_FALSE);
}
// Set the source location
alSource3f(sourceID, AL_POSITION, aLocation.x, aLocation.y, 0.0f);
**Here we play the sound ***
alSourcePlay(sourceID);
Executing above code always play the sound track from initial position. I want to know if there i any mehthod in openAL that can seek the track from some particular time instant.
You need to implement seeking. It can be quite tricky to do depending on how accurate you want the seeking to be (ie to nearest frame or seeking between frame boundaries).
How you implement this depends upon how your sound data is represented. I've previously implemented this for streaming with ogg vorbis data on openal. For that, I used implemented ov_seek as part of ov_open_callbacks.
There's a tutorial for OpenAL streaming on devmaster which I found useful.
精彩评论