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

AnimationTree and AudioStreamPolyphonic is not optimized for audio playback as it plays audio at zero volume #87767

Open
ZeEndy opened this issue Jan 31, 2024 · 3 comments

Comments

@ZeEndy
Copy link

ZeEndy commented Jan 31, 2024

Tested versions

  • Reproducible in v4.2.1.stable [b09f793]

System information

Godot v4.2.1.stable.mono - Windows 10.0.22631 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3070 Ti (NVIDIA; 31.0.15.4629) - 12th Gen Intel(R) Core(TM) i5-12600KF (16 Threads)

Issue description

Audio clips seem to have weird behavior when used in a blendspace2D with sync enabled. Sometimes the audio refuses to have its volume changed and has weird timing. Other times the audio does blend properly and causes audio to either pop and crackle because it reaches the max_polyphony or plays the sound completely with no volume change ,when it shouldn't be either muted or at not playing at all. After a while it also seems to kill the audio server if there are a lot of different sound effects in the animations (likely because it overflows??)

Example video of the max_polyphony being reached causing the audio to pop and crackle while technically the selected animation in the Blendspace2D has no audio

2024-01-29_00-23-08.1.mp4

What should be happening in the video is that no audio should be playing because the animation on that point has no audio clips only the neighboring points should have their audio playing at -80DB while the other points only keep track of the current position in their respective animations.

Steps to reproduce

  1. Create a AudioStreamPlayer3D, AnimationPlayer, AnimationTree
  2. In the AnimationPlayer create 2 animations 1 with an audio clip track and 1 without
  3. In the AnimationTree create a BlendTree with a BlendSpace2D connected to the output
  4. Place 4 points of the animation with sound at the top, bottom, left, right and place the animation without sound in the middle
    4.Enable sync

Minimal reproduction project (MRP)

AudioClip issue in blendspace2D.zip

@ZeEndy ZeEndy changed the title Weird beheivour with Audio clips in BlendSpace2D with Sync enabled Weird beheivour with Audio clips in BlendSpace2D while Sync is enabled Jan 31, 2024
@fire
Copy link
Member

fire commented Jan 31, 2024

@TokageItLab any ideas why the blending of audio has problems?

@TokageItLab
Copy link
Member

TokageItLab commented Jan 31, 2024

I assume it is simply too much audio being played at the same time.

AnimationTree does not support playback from the middle of audio, so currently audio must be played even at zero volume in order to take into account fading-in. Although I had originally thought of a "Cleaning" feature to not play when the volume is 0, it was a hack and is not implemented, so therefore not optimized, see #72233 (comment).

I think there is some room for optimization on AnimationTree side instead of AudioStreamPolyphonic, but we would need to add methods to AudioPlayback and AnimationPlayback that allow keys with "length" to be played from the middle of the key, separate from Discrete key retrieve mode. See also #86661.

I also remember that there was another bug related to max polyphony, but I don't know if that had anything to do with this issue.

@TokageItLab TokageItLab changed the title Weird beheivour with Audio clips in BlendSpace2D while Sync is enabled AnimationTree is not optimized for audio playback as it plays audio at zero volume Jan 31, 2024
@TokageItLab TokageItLab added this to the 4.x milestone Jan 31, 2024
@TokageItLab TokageItLab changed the title AnimationTree is not optimized for audio playback as it plays audio at zero volume AnimationTree/AudioStreamPolyphonic is not optimized for audio playback as it plays audio at zero volume Jan 31, 2024
@TokageItLab TokageItLab changed the title AnimationTree/AudioStreamPolyphonic is not optimized for audio playback as it plays audio at zero volume AnimationTree and AudioStreamPolyphonic is not optimized for audio playback as it plays audio at zero volume Jan 31, 2024
@ZeEndy
Copy link
Author

ZeEndy commented Jan 31, 2024

I assume it is simply too much audio being played at the same time.

From the little testing I did I'd say thats about right. Audio crackling and poping only happens in my bigger project and not in the MRP, mainly because in example video there are about 70 different sounds at minimum split across 5 audio clip tracks technically playing at the same time.

Although there does seem to be an issue in the MRP where upon the initial start of the tree it will ignore the blending completely while sync is on and after turning the some clips will ignore the volume almost like those sounds are leaking through and then it starts kind of working again after finessing it.

Example of it upon initial start not working and then half working after turning sync off and on

2024-01-31.07-26-47.mp4

Example of the sound "leaking"
https://github.com/godotengine/godot/assets/29980512/1e68544e-3460-41bd-af1c-e39646c82928

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

3 participants