# Sound's custom attenuation function is not provided with distance from scene.audioListenerPositionProvider position

**URL:** <https://forum.babylonjs.com/t/sounds-custom-attenuation-function-is-not-provided-with-distance-from-scene-audiolistenerpositionprovider-position/41164>\
**Category:** Bugs\
**Tags:** sound\
**Created:** [May 26, 2023, 12:11pm UTC](https://forum.babylonjs.com/t/sounds-custom-attenuation-function-is-not-provided-with-distance-from-scene-audiolistenerpositionprovider-position/41164 "2023-05-26T12:11:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![byadige\_mensinkai](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/byadige_mensinkai/32/30991_2.png) [@byadige\_mensinkai](https://forum.babylonjs.com/u/byadige_mensinkai)\
**Post date:** [May 26, 2023, 12:11pm UTC](https://forum.babylonjs.com/t/sounds-custom-attenuation-function-is-not-provided-with-distance-from-scene-audiolistenerpositionprovider-position/41164/1 "2023-05-26T12:11:51Z")

</div>

Hi!

When using the custom attenuation function of a sound attached to a mesh, it seems like the distance calculated is always from the mesh to the scene’s active camera, even when the scene.audioListenerPositionProvider is set.

I’ve created an example here - [https://playground.babylonjs.com/#G4PMF3#1](https://playground.babylonjs.com/#G4PMF3#1)

If the useCustomAttenuation property is set to false, or scene.audioListenerPositionProvider is not set, it works as expected.

I did not find any documentation that stated otherwise, so it seems to me like the distance provided to the custom attenuation function should also consider the audioListenerPositionProvider when it is set.

Please let me know what you think, thanks 🙂

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 26, 2023, 9:21pm UTC](https://forum.babylonjs.com/t/sounds-custom-attenuation-function-is-not-provided-with-distance-from-scene-audiolistenerpositionprovider-position/41164/2 "2023-05-26T21:21:19Z")

</div>

cc @docEdub

---

<div class="post-metadata">

**Author:** ![docEdub](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/docedub/32/14525_2.png) [@docEdub](https://forum.babylonjs.com/u/docEdub)\
**Post date:** [May 27, 2023, 2:52am UTC](https://forum.babylonjs.com/t/sounds-custom-attenuation-function-is-not-provided-with-distance-from-scene-audiolistenerpositionprovider-position/41164/3 "2023-05-27T02:52:09Z")

</div>

Sounds like a bug to me. Fixed in PR [https://github.com/BabylonJS/Babylon.js/pull/13910](https://github.com/BabylonJS/Babylon.js/pull/13910).

Thanks for report this!
