OpenAL: How to use linear attenuation?
Asked Answered
A

1

7

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 source: 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?

Arapaho answered 25/4, 2011 at 16:17 Comment(0)
K
4

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).

Kakaaba answered 25/4, 2011 at 19:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.