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

Remove AnimationTree implicit volume overwrite AudioStreamPlayer #69758

Closed

Conversation

TokageItLab
Copy link
Member

@TokageItLab TokageItLab commented Dec 8, 2022

Fixes #69746, #65750.

Since AnimationTree AudioTrack overwrite the volume of AudioStreamPlayer implicitly when blending, there is no way to work around this, and it is very inconvenient.

I have approached to solve this issue many times #65750 #49099 in the past, but all have been rejected because @reduz decides that it needs to be fixed at a much lower layer.

For now, I simply remove this "implicit overwrite" to make AudioTrack usable.

If the same functionality is needed, it can be reproduced by setting the linear_to_db() interface as a exported property in extended AudioStreamPlayer and setting the value in ValueTrack on the user side.

So, I believe removing this feature should not be a problem to make AudioTrack usable. And the fundamental improvements mentioned by reduz should be able to be added later.

Bugsquad edit: Fix #65750

@TokageItLab TokageItLab added this to the 4.0 milestone Dec 8, 2022
@TokageItLab TokageItLab requested a review from a team as a code owner December 8, 2022 11:48
@TokageItLab TokageItLab requested a review from a team December 8, 2022 12:25
reduz added a commit to reduz/godot that referenced this pull request Jan 22, 2023
…from code

* This new audio stream allows to play multiple sounds and control them over time from code.
* It greatly simplifies tasks such as generative music (music generated from code) or audio.

This new type of stream was added with the goal of fixing audio blending in AnimationPlayer and AnimationTree, but can be used by others for their regular audio needs.

Does not fix anything currently, but should help implement godotengine#69758 properly.

Some demo code of how to use this:

```GDScript

var player = $SomeNode as AudioStreamPlayer
player.stream = AudioStreamPolyphonic.new()
var playback = player.get_stream_playback() as AudioStreamPlaybackPolyphonic
var id = playback.play_stream(preload("res://Clip1.ogg"))
await get_tree().create_timer(1).timeout
playback.set_stream_volume(id,-12) # Set volume to half after one second
await get_tree().create_timer(2).timeout
var id2 = playback.play_stream(preload("res://Clip2.ogg")) # 2 seconds later, start another clip
await get_tree().create_timer(1).timeout
playback.stop_stream(id) # 1 second later, kill the first clip
playback.set_stream_pitch_scale(id2,1.5) # Make the second clip go 50% faster

```
@akien-mga akien-mga changed the title Remove AnimationTree implicitly volume overwrite AudioStreamPlayer Remove AnimationTree implicit volume overwrite AudioStreamPlayer Jan 24, 2023
@akien-mga
Copy link
Member

I believe this compat breaking change would no longer be needed, and a different solution will be built on top of #71855?

@TokageItLab
Copy link
Member Author

Yes, will be superseded.

@akien-mga akien-mga closed this Jan 24, 2023
Streq pushed a commit to Streq/godot that referenced this pull request Feb 9, 2023
…from code

* This new audio stream allows to play multiple sounds and control them over time from code.
* It greatly simplifies tasks such as generative music (music generated from code) or audio.

This new type of stream was added with the goal of fixing audio blending in AnimationPlayer and AnimationTree, but can be used by others for their regular audio needs.

Does not fix anything currently, but should help implement godotengine#69758 properly.

Some demo code of how to use this:

```GDScript

var player = $SomeNode as AudioStreamPlayer
player.stream = AudioStreamPolyphonic.new()
var playback = player.get_stream_playback() as AudioStreamPlaybackPolyphonic
var id = playback.play_stream(preload("res://Clip1.ogg"))
await get_tree().create_timer(1).timeout
playback.set_stream_volume(id,-12) # Set volume to half after one second
await get_tree().create_timer(2).timeout
var id2 = playback.play_stream(preload("res://Clip2.ogg")) # 2 seconds later, start another clip
await get_tree().create_timer(1).timeout
playback.stop_stream(id) # 1 second later, kill the first clip
playback.set_stream_pitch_scale(id2,1.5) # Make the second clip go 50% faster

```
@TokageItLab TokageItLab deleted the remove-volume-overwrite branch February 14, 2024 05:39
@AThousandShips AThousandShips removed this from the 4.0 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment