godot icon indicating copy to clipboard operation
godot copied to clipboard

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

Open havi05 opened this issue 4 years ago • 18 comments

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.)

havi05 avatar Mar 05 '21 21:03 havi05

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

Calinou avatar Mar 05 '21 22:03 Calinou

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)

havi05 avatar Mar 05 '21 22:03 havi05

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

snougo avatar Mar 07 '21 08:03 snougo

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

Maybe it is somhow only one Realtekdevice?

havi05 avatar Mar 07 '21 09:03 havi05

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

snougo avatar Mar 07 '21 11:03 snougo

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

havi05 avatar Mar 07 '21 11:03 havi05

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

havi05 avatar Mar 07 '21 12:03 havi05

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()

havi05 avatar Mar 11 '21 20:03 havi05

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])

infohub-gather avatar Sep 16 '21 19:09 infohub-gather

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

havi05 avatar Mar 06 '22 09:03 havi05

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

havi05 avatar Jun 15 '22 19:06 havi05

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".

panmaro avatar Oct 11 '22 21:10 panmaro

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

havi05 avatar Oct 12 '22 06:10 havi05

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.

souplamp avatar Feb 03 '23 16:02 souplamp

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.

Calinou avatar Feb 03 '23 16:02 Calinou

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 avatar Feb 03 '23 16:02 souplamp

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 avatar Feb 09 '23 20:02 souplamp

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.

souplamp avatar Mar 08 '23 17:03 souplamp

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()

infohub-gather avatar Mar 24 '23 23:03 infohub-gather

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.

benchpres avatar Nov 26 '23 00:11 benchpres