Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenAL: How to use linear attenuation?

Tags:

c++

openal

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?

like image 727
Rookie Avatar asked Apr 25 '11 16:04

Rookie


1 Answers

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

like image 169
Damon Avatar answered Oct 07 '22 04:10

Damon