godotengine / godot

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

Static while looping audio using AudioStreamPlayer3D #84524

Open sghofrany opened 1 year ago

sghofrany commented 1 year ago

Godot version

4.1.2.stable

System information

Windows 10 - 4.1.2.stable

Issue description

Using the AudioStreamPlayer3D or AudioStreamPlayer node to play audio has a noticeable static noise after some period of looping.

Here is a video from a minimal project that showcases this:

https://clipchamp.com/watch/FiPJFo5YdQ6

Steps to reproduce

1) Import a audio file and then re-import with Looping enabled. In my test case I am using .wav format 2) Create a basic 3D scene with a Node3D as the root node and a AudioStreamPlayer3D as a child. 3) Add the imported audio file as the Stream of the AudioStreamPlayer3D 4) Add a Camera3D as a child of the root Node3D 5) Start that scene

The audio file that I used will be in the Minimal reproduction below.

Minimal reproduction project

AudioTest.zip

Just add the audio file to the Stream section of the AudioStreamPlayer3D and hit start.

Calinou commented 1 year ago
sghofrany commented 1 year ago

All of the comments are related to versions 3.x, was this something that was supposedly fixed in version 4?

Calinou commented 1 year ago

All of the comments are related to versions 3.x, was this something that was supposedly fixed in version 4?

Yes, but it's possible that the specific audio file you're using or your audio setup causes issues that weren't resolved by the original PR.

If you are using an external DAC in particular, consider https://github.com/godotengine/godot/issues/75109.

sghofrany commented 1 year ago

All of the comments are related to versions 3.x, was this something that was supposedly fixed in version 4?

Yes, but it's possible that the specific audio file you're using or your audio setup causes issues that weren't resolved by the original PR.

If you are using an external DAC in particular, consider #75109.

No, I'm not using any DAC. My project setup is using the default values set by the editor and I've had the same issue with every audio file I've tested.

starry-abyss commented 1 year ago

Is sample rate set to 48000 Hz in Windows sound settings and to 44100 Hz in Godot settings by chance?

sghofrany commented 1 year ago

@starry-abyss Checking my Headsets settings, it is set to 8 channel, 16 bit, 48000 Hz for Windows and I can't figure out how to check in Godot.

EDIT: Found the Godot setting, it is also set to 44100 Hz.

starry-abyss commented 1 year ago

I suspect the absence of resampling from 44100 to 48000 can be the cause. Don't remember the exact issue pages with discussions, but Godot used to have a different audio backend on Windows (early versions of Godot 3 IIRC) which automatically resampled audio. Since Godot started to use WASAPI exclusively, no proper resampling happened. Resampling is not needed only if Godot sampling rate matches the one set in Windows.

sghofrany commented 1 year ago

I suspect the absence of resampling from 44100 to 48000 can be the cause. Don't remember the exact issue pages with discussions, but Godot used to have a different audio backend on Windows (early versions of Godot 3 IIRC) which automatically resampled audio. Since Godot started to use WASAPI exclusively, no proper resampling happened. Resampling is not needed only if Godot sampling rate matches the one set in Windows.

Could be, I'm not too familiar with the ins and outs of audio.

With that being said, I made a discovery yesterday and I believe this issue could be in part isolated with my headset. I'm not sure if my headset has its own set of drivers or not, but I've had other people test with the minimal project and it seems like they aren't having the same issue as me. I also tested it by disabling my headset and using the speakers on one of my monitors and again I heard no static. I am confused though, because it's not a hardware issue since I was able to record the static being outputted by godot. I wonder if there are specific audio drivers that can cause this.

My headset is: Corsair Void RBG Elite

starry-abyss commented 1 year ago

Does the sampling rate change automatically to 44100 in Windows audio settings when you disable the headset? Also could you try to manually set it to 44100 in Windows with the headset enabled and check if there is a difference?

sghofrany commented 1 year ago

Does the sampling rate change automatically to 44100 in Windows audio settings when you disable the headset? Also could you try to manually set it to 44100 in Windows with the headset enabled and check if there is a difference?

Sorry did see this message, I'll test it out later today and let you know

sghofrany commented 1 year ago

Disabling the headset does not update the sample rate, still at 48000. Setting the sample rate manually on my headset to 44100 also did not fix the issue.

MJacred commented 9 months ago

@sghofrany: your issue sounds eerily similar to #46595.

Just to confirm: Is it the same issue, except that setting your headset to 44.1 khz (so it aligns with the Godot settings) as seen in that issue's description does not fix it for you?

The only other difference I can see is that your headset uses 8 channels. Do you have one with 2 channels or can you change it to output only 2 channels in Windows?

sghofrany commented 9 months ago

@sghofrany: your issue sounds eerily similar to #46595.

Just to confirm: Is it the same issue, except that setting your headset to 44.1 khz (so it aligns with the Godot settings) as seen in that issue's description does not fix it for you?

The only other difference I can see is that your headset uses 8 channels. Do you have one with 2 channels or can you change it to output only 2 channels in Windows?

I don't have one with two channels, but I did end up using my monitors speakers and I couldn't hear any static. I can try setting the output to 2 channels later this week.