0 votes

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

Godot version 3.2.2
in Engine by (16 points)

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.

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.