开发者

OpenAL: How to use linear attenuation?

I want to control the way how the sound source volume fades out by distance, how can i do this?

Edit: I would also like to know how to scale the sound coordinate system accordingly: i dont want to hear some sound VERY far away from the so开发者_如何学JAVAurce: now i would have to change my rendering code to scale coordinates to make it work as i want.

Edit2: Although, one solution could be to multiply my coordinates before i send them... but are there more elegant ways?


That'll be alDistanceModel(AL_LINEAR_DISTANCE) or better alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED), which will turn distant sources off entirely.

Read chapters 3.4.3 and 3.4.4 here. You also have to set the parameters in the formulas listed there (AL_MAX_DISTANCE and AL_REFERENCE_DISTANCE) for each source (alSourcef).

If the parameters don't make sense, attenuation is turned off. If the sound is stereo, likewise (stereo is just that... stereo -- only mono sounds are 3D).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜