godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.13k stars 21.19k forks source link

Slight delay when looping .ogg file #26931

Open Yomic opened 5 years ago

Yomic commented 5 years ago

Godot version: 3.1 RC2 (Also happening on 3.0.6)

OS/device including version: Windows 8.1 Pro 64-bit and Windows 7 Pro 64-bit

Issue description: When an ogg file loops, there is a slight delay before looping the sample back to the beginning.

Steps to reproduce: Create a project with an empty node. Add an AudioStreamPlayer to the node and load an ogg file. Check auto-play and run the project. This is more apparent with music that has a perfect loop from the end to beginning.

Minimal reproduction project: In the provided project, the ogg sample should automatically play. The ogg sample is 9 seconds long. OggMusicTest.zip

Yomic commented 5 years ago

As a side note, looping a wav file does not have this slight delay, but the file sizes are unacceptable for normal use if you have a lot of music.

Sslaxx commented 5 years ago

Not noticed this with 3.0.6 or 3.1 using Linux (up to 3.1 beta 7 or thereabouts anyway).

tom-jk commented 4 years ago

The music in the supplied project file is somewhat misleading because there is a slight delay at the loop point in the music itself. I've modified the project to add a ~2sec cut of the music that loops perfectly (not musically, but as in there's no silence or pop), plus a noise clip (to check for audible skips) and a 120bpm click track (to check the timing isn't drifting). There is an animation sync'd to the click track and there is a deliberate one-second pause to ensure they start together. You can swap in the other ogg files to test them.

26931_edit.zip

I don't observe any delay with looping ogg files in godot 3.2.2.stable on linux mint 18.3, kernel 4.15.0-55-generic.

@Yomic do you still experience this issue?

taellinglin commented 2 years ago

I think sometimes the header info for ogg files causes a click...try stripping the ogg header files and making sure the encoder isn't adding any silence at the beginning or end...Wav files generally don't have headers, mainly just audio data, and thus can basically be loaded right into memory. For perfect looping you need to do what the person above did with the tempo and buffers lining up. Ticks are important when rendering or playing back audio.

taellinglin commented 2 years ago

You may also want to look up to see if the audio is looping at a "Zero crossing" of the wav data....

akien-mga commented 1 year ago

Is this still reproducible in 4.0 RC 3 or later?