jarikomppa / soloud

Free, easy, portable audio engine for games
http://soloud-audio.com
Other
1.74k stars 271 forks source link

3D Audio does not fade out by distance. #267

Open merpheus-dev opened 4 years ago

merpheus-dev commented 4 years ago

Hey there, I am using the latest 20200207 release. I implemented soloud into my game engine(OpenGL).

Although, having trouble with 3d audio fade out and pan. I can notice a slight change when I use set3dListenerAt while my camera rotates. But the position does not change anything. I call update3dAudio after I set my camera position and rotation in my main loop and call update audio method though.

proof88 commented 1 month ago

Hello,

the default attenuation model is "no attenuation". So if you want your 3D sound to be faded away as distance increases, you need to set a proper attenuation model. For example:

m_handleFallYell = soloud.play3d(m_sndFallYell, playerPos.getX(), playerPos.getY(), playerPos.getZ());
soloud.set3dSourceMinMaxDistance(m_handleFallYell, 9.f, 22.f);
soloud.set3dSourceAttenuation(m_handleFallYell, SoLoud::AudioSource::ATTENUATION_MODELS::LINEAR_DISTANCE, 1.f);

You can find more about Attenuation models here: https://solhsa.com/soloud/concepts3d.html