Reputation: 41
I'm using OpenAL in my iPhone project to create sounds that attenuate when farther away from the listener.
However - I also want to play some sound effects that shall not be attenuated by distance.
So far I solved that by using stereo sounds, which don't get attenuated. But now I'm adding a lot of voiceacting which takes quite some space - so I want them to be mono and now have the problem again that they get attenuated by distance.
My next solution was to set "AL_MIN_GAIN" of the source playing the voice samples to 1.0, but this seems to be working only on the simulator, not on the device.
Are there other ways to play sound effects with openAL that shall not be attenuated by distance?
Upvotes: 4
Views: 2695
Reputation: 3071
Just use
alSourcei(id, AL_DIRECT_CHANNELS_SOFT, 1)
AL_DIRECT_CHANNELS_SOFT
macro is defined in <AL/alext.h>
Upvotes: 0
Reputation: 5138
alSourcei (sourceName, AL_SOURCE_RELATIVE, AL_TRUE);
alSource3f (sourceName, AL_POSITION, 0.0f, 0.0f, 0.0f);
alSource3f (sourceName, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
And then the source should stay at the listener's position.
Upvotes: 5
Reputation: 14974
You can try opening a second context that doesn't have a distance model. I'm not sure if iOS supports multiple contexts or not though...
Alternatively, just keep your "voice" sources at the same position as the listener.
Upvotes: 1