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

Audio track key end_offset does not work when it exists outside the animation length #75197

Closed
Tracked by #76797
KnightNine opened this issue Mar 21, 2023 · 11 comments · Fixed by #80813
Closed
Tracked by #76797

Comments

@KnightNine
Copy link

KnightNine commented Mar 21, 2023

Godot version

4.0

System information

Windows 10

Issue description

The Audio Playback Track in an Animation can only stop the sound at its End Offset on the first loop, then it fails to do so for every loop after the first:

The sound begins overlapping with itself as seen in the top right:
sound looping

Steps to reproduce

  • create an AudioStreamPlayer3D and an AnimationPlayer in your scene.
  • create an animation and select the looping button.
  • add an Audio Playback Track to it that is connected to the AudioStreamPlayer3D
  • drag a sound into the track, then shorten the sound by dragging its right edge to the left (thus increasing its End Offset )
  • shorten the animation length to the length of the shortened audio file.
  • play the animation.

Minimal reproduction project

N/A

@KnightNine
Copy link
Author

Is there a workaround for this without clipping the audio file to the length of the animation? I tried setting the playing property of the AudioStreamPlayer3D to false and then true to see if I could reset the player but that just stops the audio entirely.

@KnightNine KnightNine changed the title Audio Playback Animation Track fails to stop audio at it's End Offset when animation is looping. Audio Playback Animation Track fails to stop audio at its End Offset when animation is looping. Mar 21, 2023
@TokageItLab TokageItLab self-assigned this Mar 22, 2023
@TokageItLab TokageItLab added this to the 4.1 milestone Mar 22, 2023
@TokageItLab
Copy link
Member

The audio track is basically the key that fires playback and is not trimmed by the animation length. This is the intended behavior.

The bug I can tell here is that the EndOffset outside of the animation length is ignored. This is odd, I'll send a PR to fix it later.

@TokageItLab TokageItLab changed the title Audio Playback Animation Track fails to stop audio at its End Offset when animation is looping. Audio track key end_offset does not work when it exists outside the animation length Apr 9, 2023
@YuriSizov
Copy link
Contributor

@TokageItLab A reminder that you wanted to fix this :)

@KnightNine
Copy link
Author

@TokageItLab
The issue still seems to persist on my end.
Did you test that that this was fixed?

@TokageItLab
Copy link
Member

TokageItLab commented Oct 22, 2023

See above comment

The audio track is basically the key that fires playback and is not trimmed by the animation length. This is the intended behavior.
The bug I can tell here is that the EndOffset outside of the animation length is ignored. This is odd

At least, I think ignored offset issue is solved in 4.2 beta, but still there? If so please send MRP.

@KnightNine
Copy link
Author

@TokageItLab

If the sound not stopping at the end of the animation is the intended behavior How do I prevent my looping animation audio from overlapping with itself then?
Am I forced to create an audio file that is the exact length of the looping animation?

And the audio would be cut by the animation length for looping animations in 3.X so why the design change?

@TokageItLab
Copy link
Member

TokageItLab commented Oct 22, 2023

Now the end offset is available if the fix is done correctly, so it might be sufficient you just setting the end offset for all looping animations.

For example, there is an animation contain jumping and the last frame landing with sound fx, if you loop and force trim that sound, the landing sound is not played correctly, so trimming shouldn’t be there at least as default.

However, AudioPlaybackTrack generally allows to play only 1 sound per 1 track in the same time, so I guess your issue is "previous sound is not stopped when next key is played after looping" not "AudioPlaybackTrack is not trimmed by animation length"; it is another issue from "there is no way to trim audio outside of animation length / end offset is not working correctly", so if you can reproduce it with multiple sounds/keys, please send again it(previous sound is not stopped when next key is played after looping) as new issue.

@KnightNine
Copy link
Author

KnightNine commented Oct 22, 2023

@TokageItLab

Basically it's practically impossible to set the end offset to the very end of the animation length

The end_offset value is based on the percentage of the audio length so I can't just enter the length of the animation into it.
I also can't snap the end offset to anything by dragging it in the timeline either.

I guess I'll post "previous sound is not stopped when next key is played after looping" because the AudioStreamPlayer3D shouldn't be able to play multiple sounds at the same time when max_polyphony is set to 1.

@TokageItLab
Copy link
Member

Basically it's practically impossible to set the end offset to the very end of the animation length

For about that, you can use inspector.

@KnightNine
Copy link
Author

@TokageItLab

For about that, you can use inspector.

I actually have to subtract the animation length from the sound length to get the value
I was wrong about:

The end_offset value is based on the percentage of the audio length

But even then it's finnicky and needs adjustment or else it allows audio gaps on the loop.

@TokageItLab
Copy link
Member

TokageItLab commented Oct 23, 2023

I guess the only improvement that could be made for that would be the addition of a snap. If the snap is not effective currently, so you can send another issue.

Alternatively, we could add the feature to set the offset to the current timeline position and assign shortcut to the [ ] keys, but this would require a proposal first.

In any case, these topics are off topic here since it is usability issue, not end offset behavior issue (I think it has been already fixed).

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

Successfully merging a pull request may close this issue.

4 participants