Get audio volume at another point in space

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By spymastermatt

I am trying to create a game in which one player controls multiple drones, which they can switch between, and I would like to be able to show a sound meter for each drone, showing the volume of sound that drone can hear.

I can use a SpectrumAnalyzer to get the volume at the position of the currently active listener/camera, but I can’t find any way of getting the volume as calculated at a different point to the active listener/camera.

There are only 2 drones initially for simplicity. In this example the player is controlling drone 0
As a workaround, i decided to set a timer, which runs every 1 second and does the following:

  1. Makes the listener on drone 1 active
  2. Measures the volume using the SpectrumAnalyzer
  3. Makes the listener on drone 0 active

But doing it this way means that the volume number always matches whatever your hearing, because it doesn’t switch fast enough

Doing the same thing, but switching between listeners on each _process cycle, only measuring the volume on drone 1 (the one you’re not controlling) gives the desired result, BUT, you can hear when it switches drones, so the sound you are actually hearing switches loud/quiet for a noticeable amount of time, maybe 0.5 seconds.

Does anyone know of any way to run this either fast enough that the time spent listening to the uncontrolled drone is unnoticeable, or (ideally) a way of measuring the volume at a specific listener without make it active?

Thanks in advance

or (ideally) a way of measuring the volume at a specific listener without make it active?

I don’t think there’s a way to do that, unless you just estimate it based on the distance and the attenuation model used by nearby AudioStreamPlayer3Ds.

Calinou | 2021-02-20 21:14

Yeah this is what I’m thinking I’ll have to do.
Or look into the source and see if I can add the feature I’m after, just for my own project

spymastermatt | 2021-02-21 07:35