views:

76

answers:

1

Hello,

I've recently been trying to incorporate an intensive sound management class, where sound playback precision is a must. What I'm looking for is the option to load a sound, set the playback starting position (or playhead), play for a certain time, pause the sound, set the 'playhead' position to a new interval and resume playback again. (with dynamic intervals). I've tried using AVAudioPlayer for that matter - but it seems it's just too slow. The performance is just not what you expect, it lags when calling pause and setCurrentTime:.

It's the easiest library to use and the only one with stated setCurrentTime: function.

I come here asking for your help, a recommendation for a decent open-source SoundEngine that can handle interval setting (playhead movement) with low latency, or reference to where it is stated that OpenAL or AudioUnit tools can handle playback position setting.

Thank you in advance,
~ Natanavra.

+1  A: 

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:

Under source: 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;

OpenAL definitely has the capabilities to playback sound pause whatever you like. remember OpenAL is often used in games as it delivers sound playback with low latency and on demand playback. You have a lot of control over the sound. compared to the AVAudioPlayer class. Hope this helps Do reply

Pk

Pavan
Thank you very much. I'll be sure to try this out sometime. Meanwhile, I managed to make the AVAudioPlayer class somewhat more effective and lower the latency by subclassing it and adding all kinds of methods to it.
natanavra
Thats great to hear. I'm glad that you've been able to reduce the latency as that is very important when it comes to playing sound.As for your question where you asked for a reference to where it is stated that OpenAL or AudioUnit tools can handle playback position setting; I've provided you with that so do try this so this question can be closed. Thank you.
Pavan