开发者

OpenAL - how to play unattenuated sound effects?

开发者 https://www.devze.com 2023-02-14 17:51 出处:网络
I\'m using OpenAL in my iPhone project to create sounds that attenuate when farther away from the listener.

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 attenuate开发者_JAVA技巧d 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?


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.


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.


Just use

alSourcei(id, AL_DIRECT_CHANNELS_SOFT, 1)

AL_DIRECT_CHANNELS_SOFT macro is defined in <AL/alext.h>

0

精彩评论

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