dimanche 28 mars 2021

How to Configure a Web Audio PannerNode to be Larger than One Point?

How do I configure a PannerNode to be larger than one point?

I have an object that is a right triangle shape, with a bounding box that is 10 by 10. How do I make it so that:

  1. While the listener is approaching any point on the flat side, the sound will be strait from the listener along any point of that side
  2. When the user enters the object the sound will play equally in both speakers while the user is in the object
  3. When the user is outside of the object at the center of the hypotenuse, the sound is coming from multiple directions at once, like forward and right?

I have been looking at the cone attributes (PannerNode.coneInnerAngle, PannerNode.coneOuterAngle, and PannerNode.coneOuterGain), but they look like they only deal with the 1 point size of the sound object and change what direction the sound is facing (like in the Boombox example).

I'm probably misunderstanding how the attributes work, but it doesn't seem as if the Web Audio API allows for multiple sized sound objects.

The only solution I have found, is to calculate the nearest point to the listener, and change the object's position to be that nearest point every time the listener moves. When the listener is inside the object, the sound is positioned at the same location as the user. There are two major problems with this approach:

  1. It is extremely slow updating the nearest point of multiple complex objects.
  2. This approach does not handle sounds coming from multiple sides of the user.

Please let me know what I can do to make sounds larger than one point.

Thank you,




Aucun commentaire:

Enregistrer un commentaire