godotengine / godot

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

`AudioServer.capture_set_device()`and `AudioServer.device()` do not work on Windows #46710

Open Gamemap opened 3 years ago

Gamemap commented 3 years ago

Godot version:

Godot 3.2.3 64 Bit and Godot 3.2.4 RC3

OS/device including version:

Windows 8.1

Issue description:

AudioServer.capture_set_device("Stereo Mix") don't work.

print(AudioServer.capture_get_device_list()) Has as output: [Default, Stereo Mix (Realtek High Definition Audio), Microphone (Realtek High Definition Audio)] But AudioServer.capture_set_device("Stereo Mix") (or AudioServer.capture_set_device("Stereo Mix (Realtek High Definition Audio)")) has with print(AudioServer.capture_get_device()) only Default as output. (It also won't work with Microphone.)

Maybe the documentation should be improved, if I have understood something wrong. I haven't tested the AudioServer.device .

Steps to reproduce:

  1. AudioServer.capture_set_device("Stereo Mix")
  2. print(AudioServer.capture_get_device())

Minimal reproduction project:

AudioServer.zip (Enable Stereo Mix in Windows AudioSettings.)

Calinou commented 3 years ago

@Gamemap Please upload a minimal reproduction project to make this easier to troubleshoot.

Gamemap commented 3 years ago

I have uploaded it. You have to enable Stereo Mix on Windows or you can change the line 12 to `AudioServer.capture_set_device("Micophone"). (If you have an Microphon on your PC)

snougo commented 3 years ago

I can't be sure AudioServer.capture_set_device() works or not, because the minimal project is too simple, so I just uplaod the screenshot

Screen Shot 2021-03-07 at 16 38 04

Screen Shot 2021-03-07 at 16 38 11

Gamemap commented 3 years ago

When I run the exact same script, my output is this: Audio

Maybe it is somhow only one Realtekdevice?

snougo commented 3 years ago

When I run the exact same script, my output is this: Audio

Maybe it is somhow only one Realtekdevice?

I use Mac, so not sure about that

Gamemap commented 3 years ago

It is probably a Windows problem. (I use Windows 8.1)

Gamemap commented 3 years ago

AudioServer.device =AudioServer.get_device_list()[1] does not work either. ( Speaker (Realtek High Definition Audio) )

Gamemap commented 3 years ago

If I run this script and use a AudioStreamPlayer with a AudioStreamMicrophone the Output prints Default but the Microphone (also Stereo Mix) don't work. Without this code the microphone works.

AudioServer.capture_set_device("Stereo Mix (Realtek High Definition Audio)")
  print(AudioServer.capture_get_device())

Edit: There is also this error:

E 0:00:02.473 audiodeviceinit: WASAPI: Initialize failed with error 0xffffffff8889000a.
<C++-Fehler> Condition "hr != ((HRESULT)0x00000000)" is true. Returned: ERRCANTOPEN
<C++-Quellcode>drivers/wasapi/audiodriverwasapi.cpp:299 @ audiodeviceinit()
infohub-gather commented 3 years ago

I am on Windows 10 and setting the device as above does indeed not work. Godot 3.3.2 Stable.

AudioServer.capture_set_device(AudioServer.capture_get_device_list()[2])

Gamemap commented 2 years ago

Dosn't work on Windows 11 with Godot v4.0.alpha2.official [79077e6c1]. AudioServer.capture_set_device(AudioServer.capture_get_device_list()[1])

Gamemap commented 2 years ago

Not working with Godot v4.0.alpha10.official [4bbe7f0b9]

panmaro commented 2 years ago

Tested on Windows 7 SP1, Godot_v3.5.1-stable_win64, Godot_v3.5-stable_win64, Godot_v3.4.4-stable_win64. Not working. I tried to set device from capture_get_device_list (I have 3 devices). The result of AudioServer.capture_get_device() is always "Default".

Gamemap commented 2 years ago

Also not working with Godot 4.0 Beta 1. Edit: ... and with Beta 3 neither.

souplamp commented 1 year ago

With #69120, here is a new project to test this: beta17.zip

Update: It seems that the output device does actually update, but it won't print the new device name immediately after. Selecting a new output device and playing a sound (see project) shows that it is still being updated. No luck with the input device, still.

Calinou commented 1 year ago

Do you have microphone access enabled in the Windows settings? This setting affects both Win32 and UWP applications.

image

Also make sure Let desktop apps access your microphone is enabled on that page.

souplamp commented 1 year ago

I have the equivalent Windows 10 setting enabled, but Godot 4 does not come up on the list of apps, so that might be related.

Edit: Nevermind, giving Godot and a running project the input devices through audio settings does not work either. The console is printing the current input device using AudioServer.get_input_device(). access

souplamp commented 1 year ago

Microphone input does not work on Godot 4 Beta 17 & RC1 due to #72892. I'll build from master on Windows 11 and see if that makes a difference.

souplamp commented 1 year ago

Time flies. Turns out (at least my hunch is) Godot isn't initializing the microphone (even after enabling audio input in Project Settings). Checking the Windows microphone settings, the last time Godot asked for microphone use was in Godot 3 about a year ago on my machine. So for some reason, WASAPI might not be initializing now in Godot 4.0.

infohub-gather commented 1 year ago

Time flies. Turns out (at least my hunch is) Godot isn't initializing the microphone (even after enabling audio input in Project Settings). Checking the Windows microphone settings, the last time Godot asked for microphone use was in Godot 3 about a year ago on my machine. So for some reason, WASAPI might not be initializing now in Godot 4.0.

Same problem here, did all of the above but WASAPI is not initializing. I got it to work in a Beta, but somehow the problem returned.

If I run Godot 4 first, no error, but as soon as I turn on another audio program (to get the input in) its starts spitting the errors: W 0:00:28:0839 thread_func: WASAPI: Current output_device invalidated, closing output_device <C++ Source> drivers/wasapi/audio_driver_wasapi.cpp:794 @ thread_func()

benchpres commented 11 months ago

Started working for me after disabling all other microphones and turning off "Exclusive Mode" on my default microphone.

exclusive

Since this is not a necessary step to do in other games, I think it is still fair to consider this a bug.