godotengine / godot

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

Playing ogg vorbis music stream stutters #15847

Closed imekon closed 6 years ago

imekon commented 6 years ago

Godot V3.0 RC1

Windows 10

Play a simple ogg vorbis stream, it plays in left channel only and stutters. Same setup works fine on same hardware in V2.1.4 official release.

Steps to reproduce: streamPlayer.stream = musicStream streamPlayer.play()

Minimal reproduction project:

MusicPlayerRC1.zip

reduz commented 6 years ago

did you try converting it or recompressing it? I know the current decoder (stb_vorbis) has problems with some older ogg files.

On Thu, Jan 18, 2018 at 3:01 PM, Pete Goodwin notifications@github.com wrote:

Godot V3.0 RC1

Windows 10

Play a simple ogg vorbis stream, it plays in left channel only and stutters. Same setup works fine on same hardware in V2.1.4 official release.

Steps to reproduce: streamPlayer.stream = musicStream streamPlayer.play()

Minimal reproduction project:

MusicPlayerRC1.zip https://github.com/godotengine/godot/files/1643936/MusicPlayerRC1.zip

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/15847, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z2xyitjifH1mYrGHVyfHB540ptvl6ks5tL4cVgaJpZM4RjVOw .

imekon commented 6 years ago

Yes, tried reencoding. Still stutters and comes out of left channel only.

mrcdk commented 6 years ago

You are using an AudioStreamPlayer2D which is used to play 2D positional audio. Its postion is top-left so that's why it plays only in the left channel. You need to use an AudioStreamPlayer to play music.

imekon commented 6 years ago

That fixed the left channel only playing, however it still stutters. Since it's playing at a slower speed, I think it's dropping audio blocks.

mrcdk commented 6 years ago

I can't reproduce the stutters https://streamable.com/xmeyx

vnen commented 6 years ago

Doesn't stutter for me. Tried to change the sample rate of my audio interface, but in any config it still plays fine.

Is there any message in the console window/output panel?

imekon commented 6 years ago

This is all that appears in the console:

OpenGL ES 3.0 Renderer: GeForce GTX 970/PCIe/SSE2 GLES3: max ubo light: 409 GLES3: max ubo reflections: 455, ubo size: 144 ARVR: Registered interface: Native mobile OPENING: D:/samples/godot/MusicPlayerRC1 (D:::samples::godot::MusicPlayerRC1) running cmdline: "D:\tools\godot 3.0 rc\Godot_v3.0-rc1_win64.exe" "--path" "D:/samples/godot/MusicPlayerRC1" "--editor" OpenGL ES 3.0 Renderer: GeForce GTX 970/PCIe/SSE2 GLES3: max ubo light: 409 GLES3: max ubo reflections: 455, ubo size: 144 ARVR: Registered interface: Native mobile erasing C:\Users\goodwin\AppData\Roaming/Godot/projects/MusicPlayerRC1-567aab528bb594fb906e52a45e61b280/filesystem_update3 Running: D:\tools\godot 3.0 rc\Godot_v3.0-rc1_win64.exe --path D:/samples/godot/MusicPlayerRC1 --remote-debug 127.0.0.1:6007 --allow_focus_steal_pid 8064 --position 448,240 running cmdline: "D:\tools\godot 3.0 rc\Godot_v3.0-rc1_win64.exe" "--path" "D:/samples/godot/MusicPlayerRC1" "--remote-debug" "127.0.0.1:6007" "--allow_focus_steal_pid" "8064" "--position" "448,240" OpenGL ES 3.0 Renderer: GeForce GTX 970/PCIe/SSE2 GLES3: max ubo light: 409 GLES3: max ubo reflections: 455, ubo size: 144 ARVR: Registered interface: Native mobile

I'm guessing this is specific to my hardware (ugh), so I'll try this on my laptop when I next get to it (in a few days). I may try a different encoder - I'm using audacity.

leiget commented 6 years ago

Maybe try a different song. Here's some: http://www.vorbis.com/music/

imekon commented 6 years ago

I tried a couple from http://www.vorbis.com/music/, same stuttering.

marcelofg55 commented 6 years ago

I tested on Windows and Mac and I got no stuttering with that project. It plays on the left speaker only too here, but if I use a AudioStreamPlayer node instead of a AudioStreamPlayer2D node it plays on both speakers correctly.

imekon commented 6 years ago

Anyway to change output to XAudio2 or RtAudio? Project config only shows WASAPI and it's a string not a dropdown. I did try XAudio2 or RtAudio but they didn't work.

marcelofg55 commented 6 years ago

Try with the string RtAudio-DirectSound in the project config.

imekon commented 6 years ago

Woohoo! That did it, it's playing perfectly now!

marcelofg55 commented 6 years ago

That's odd, I wonder why its stuttering for you with WASAPI driver.. what audio card do you have?

imekon commented 6 years ago

I have a USB Terratec DMX 6Fire sound card.

marcelofg55 commented 6 years ago

What frequency is Windows using for your card? 192 kHz?

reduz commented 6 years ago

If it helps, from my time doing audio software, sometimes you request a buffer size and the API returns a different one, so still need to check back.

Not sure if the case in Wasapi

On Jan 19, 2018 5:46 PM, "Marcelo Fernandez" notifications@github.com wrote:

What frequency is Windows using for your card? 192 kHz?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/15847#issuecomment-359084176, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z23CJsSAV_y1i5-Cxw9uxnWAayiPbks5tMP8IgaJpZM4RjVOw .

imekon commented 6 years ago

The frequency is 176400Hz, that seems to be the default for Windows 10.

from my time doing audio software

I used to work for Sensaura, on WDM device drivers for audio, then audio at Codemasters for various racing games.

marcelofg55 commented 6 years ago

The frequency is 176400Hz, that seems to be the default for Windows 10.

Can you test with a lower frequency, 44100 Hz or 48000 Hz? thanks!

imekon commented 6 years ago

I just spent the last 10 minutes with no audio after changing frequency to anything other than 176.4kHz. It simply says for 44100 "not supported". Bit strange it shows it in the drop down list then. Once I set it back to 176.4kHz, shutdown, wait for everything to switch off, then restart, eventually I got audio back. It's an old sound card... maybe I should consider upgrading... I like it because it has so many external inputs.

leiget commented 6 years ago

41000 not supported?! It's the most supported rate out there. Weird. It sounds like some setting or driver problem somewhere.

imekon commented 6 years ago

Checked this on my laptop - no stutter with WASAPI. I think the fault is with my dodgy sound card.

hedin-hiervard commented 4 years ago

Same here. Godot 3.2 / 3.2.2, on ONE Windows machine .ogg playback with 44100 Hz samplerate is slow/sluttering. Tried changing audio driver string to RtAudio-DirectSound - nothing changes. I have this in the logs:

**WARNING**: WASAPI: Unsupported number of channels: 1
   At: drivers/wasapi/audio_driver_wasapi.cpp:330:init_render_device() - WASAPI: Unsupported number of channels: 1

UPD: the problem only manifests itself with a certain audio-device (Usb headset), on an internal Realtek audio-card the output is fine.

Calinou commented 4 years ago

Tried changing audio driver string to RtAudio-DirectSound - nothing changes.

As far as I know, RtAudio is no longer present in Godot since 3.1. There's an XAudio driver but it's not compiled in by default, and I doubt it still works in the current state of things.

UPD: the problem only manifests itself with a certain audio-device (Usb headset), on an internal Realtek audio-card the output is fine.

Try changing the device's output sample rate. USB headsets embed their own sound card, which means they're seen as additional output devices (like HDMI audio).

hedin-hiervard commented 4 years ago

Try changing the device's output sample rate. USB headsets embed their own sound card, which means they're seen as additional output devices (like HDMI audio).

The problem was narrowed to down to a device having mono-output (1 channel). So logically those headphones have 2 output devices: one is chat (mono) the second is game (stereo). Both have 48k output rate. Chat device output is buggy, the game output is fine. Chat also shows this in the logs:

**WARNING**: WASAPI: Unsupported number of channels: 1
   At: drivers/wasapi/audio_driver_wasapi.cpp:330:init_render_device() - WASAPI: Unsupported number of channels: 1

So basically Godot doesn't play well with WASAPI mono devices. I have no idea how to fix that..