3d sound muffled if player is on distance to audio source


i’m trying to built a club in Playcanvas and it would be great if the music that plays is muffled if the player is not near to the audio source.

This is the scene: PlayCanvas | HTML5 Game Engine

Does anyone knows a way or a script, to create that effect?

Hi @Luis,

right off the bat I would try:

  1. Create “muffled” music file (e.g. Audacity) with an effect
  2. Create a script that checks the distance from club to player
  3. If distance > threshold then change the sound source to muffled and seek audio to normal position
    If distance < threshold then change the sound to normal and seek audio to muffled position

There is probably an easier way but i am no SFX expert :stuck_out_tongue:

You can look at this project as a starting point:

It shows how you can use a spatial audio in your project. You can see how I read the audio buffer and position the little cubes, based on the underlying frequency. Your option is probably to increase the frequency range of the audio, the closer you get to the source.