Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport panning strength parameters to 3.x #4692

Closed
elvisish opened this issue Jun 18, 2022 · 8 comments
Closed

Backport panning strength parameters to 3.x #4692

elvisish opened this issue Jun 18, 2022 · 8 comments
Milestone

Comments

@elvisish
Copy link

Describe the project you are working on

A 3D walking simulator.

Describe the problem or limitation you are having in your project

I want an ambient sound to get quieter the further I am from it, but I do not want it to pan between the left and right channels depending on my facing angle.

Presently, the distance attenuation can be disabled so the sound appears at the same volume from all distances, but not the spatial position in the stereo field. This makes no sense as both should be able to be enabled or disabled as needed.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It's been implemented in 4.0 (godotengine/godot#58841) and would be great to be backported to 3.x.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Here's the current workaround for 3.x:

extends AudioStreamPlayer

onready var playercam = get_viewport().get_camera()
export(float) var max_volume
export(float) var max_distance
var distance

func _ready():
	distancefunc()


func _physics_process(_delta):
	distancefunc()

func distancefunc():
	distance = global_transform.origin.distance_to(playercam.global_transform.origin)
	var linear_energy = max(0.0, 1.0 - (distance / max_distance))
	volume_db = linear2db(linear_energy) + max_volume

Thanks to Yagich for helping with this.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It would be AudioStreamPlayer3D/2D code.

Is there a reason why this should be core and not an add-on in the asset library?

It would be AudioStreamPlayer3D/2D code.

@elvisish
Copy link
Author

Could this be considered for 3.6 if anyones willing to backport?

@Calinou
Copy link
Member

Calinou commented Aug 15, 2022

Could this be considered for 3.6 if anyones willing to backport?

Yes, but a contributor needs to do the required work. It's not possible to cherry-pick what was done in master, as mixing is done in the AudioStreamPlayer nodes instead of the audio server in 3.x. I have no plans to do this myself.

@marcinn
Copy link

marcinn commented Aug 17, 2022

Here is a patch for 3.x:
https://gist.github.com/marcinn/71635fdf08d35aec17f889968d698068

With 3D it seems to work fine. I haven't tested 2D.

@elvisish
Copy link
Author

Here is a patch for 3.x:

https://gist.github.com/marcinn/71635fdf08d35aec17f889968d698068

With 3D it seems to work fine. I haven't tested 2D.

Thankyou! I haven't yet done any engine patching so it might take me a little while get it working, really appreciate it! Could this be incorporated in the master eventually?

@Calinou
Copy link
Member

Calinou commented Aug 17, 2022

Could this be incorporated in the master eventually?

This is already in master 🙂

@elvisish
Copy link
Author

Could this be incorporated in the master eventually?

This is already in master 🙂

Sorry I meant for 3.6! (still a bit confused by GitHub lol)

@Calinou
Copy link
Member

Calinou commented Aug 17, 2022

Sorry I meant for 3.6!

Yes, if someone opens a pull request and gets it merged before 3.6 enters feature freeze 🙂

@akien-mga
Copy link
Member

Closed by godotengine/godot#64579.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants