Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wsl2 sound support #5816

Closed
w5wa opened this issue Aug 26, 2020 · 88 comments
Closed

Wsl2 sound support #5816

w5wa opened this issue Aug 26, 2020 · 88 comments

Comments

@w5wa
Copy link

w5wa commented Aug 26, 2020

Is your feature request related to a problem? Please describe.
The Pulseaudio doesn't natively supported by WSL2 and it difficult to link it to Windows speakers.

Describe the solution you'd like
Add driver support of sound as update

Describe alternatives you've considered
Codes for Pulseaudio to link Windows speaker or export sound of linux to local host ip address.

@w5wa w5wa added the feature label Aug 26, 2020
@Biswa96
Copy link

Biswa96 commented Aug 26, 2020

This article may help https://x410.dev/cookbook/wsl/enabling-sound-in-wsl-ubuntu-let-it-sing/

@therealkenc
Copy link
Collaborator

Spiritually dupe #237 which is the three-digit landing zone for sound, with ref #486 and #4205. WSL2 can have its own LZ for reasons.

@ameeno
Copy link

ameeno commented Aug 27, 2020

I found a way that is better than the x410 guide and works with the latest version of pulse on windows 10. installs pulse as a service, and is seamless.

this is the guide.

originally available from https://tomjepp.uk/2015/05/31/streaming-audio-from-linux-to-windows.html but now down:

I found a much newer set of binaries from the X2Go project: http://code.x2go.org/releases/binary-win32/3rd-party/pulse/.

To set up PulseAudio 5.0 on Windows, do the following:

Download pulseaudio-5.0-rev18.zip from http://code.x2go.org/releases/binary-win32/3rd-party/pulse/pulseaudio-5.0-rev18.zip
Extract it and copy the pulse folder to C:\pulse
Create a config.pa file in that folder with these contents:

load-module module-native-protocol-tcp auth-anonymous=1
load-module module-esound-protocol-tcp auth-anonymous=1
load-module module-waveout sink_name=output source_name=input record=0

Test this setup by running: c:\pulse\pulseaudio.exe -F config.pa
On the wsl2 side you must run:

export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}');

play some sound on wsl2 and you will get it working.
You should now be able to get Linux sound playing on your Windows PC.
For a permanent setup, we need to create a Windows service rather than running PulseAudio in a command prompt. I use NSSM to run arbitrary programs as services. Download the latest version of NSSM.

https://nssm.cc/download

Extract it and copy nssm.exe from the win32 folder to c:\pulse.
Run:

 c:\pulse\nssm.exe install PulseAudio

Fill in the following details on the Application tab:
Path: c:\pulse\pulseaudio.exe
Start-up directory: c:\pulse
Arguments: -F c:\pulse\config.pa
On the Details tab, fill in:

Display name: PulseAudio
Now click Install service.

Finally, start the newly installed service - either through Services in Administrative Tools, or by running net start PulseAudio

now you will have a permanent pulseaudio service on windows which is very low ram usage.
for permanent settings on the WSL side, you could put the following in your .bashrc file:

export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}');

That way, all pulseaudio sound will be passed to windows, seamlessly.

btw, my config above allows anonymous connections. you can restrict it to IP of the wsl2 vm if you want but it changes regularly. so there isnt really a way as far as I can tell, to have the IP restrictions in place and secured properly.

I have seen people use methods such as: sed and regex to update /modify the config.pa file to the correct IP address on WSL2 start-up, (that lives on /mnt/c/pulse/config.pa) but you must then stop and start the pulse audio NSSM service in windows. - I do not think that is so easy.

Allowing anonymous connections works fine for so far, and has the added benefit, that any WSL/Hyper-V -VM can just put sound out of my laptop over tcp.

Hope that helps!

@ghost
Copy link

ghost commented Sep 1, 2020

@ameeno Oops. That shouldn't 404! I'll put that back!

@ameeno
Copy link

ameeno commented Sep 1, 2020

@tomjepp hey Tom. Awesome thanks.
your guide was more pulse on windows for network based sound redirection.
But is the best way I have found for having a more modern pulse server permanently on windows.

I adapted it slightly for wsl use and allowed anonymous sound.
Perhaps you could incorporate wsl1/2 usage into your guide?
Pulse as a service + x410 on start-up makes Linux GUI apps almost seamless.

Thanks for the guide initially!

@ghost
Copy link

ghost commented Sep 1, 2020

@ameeno I'm afraid I don't use WSL myself so I can't really do this. Feel free to use this guide as a base, however!

@cerebrate
Copy link

Seems like the first relevant question here is what, if any, sound support is coming along with the GUI app support we already know is on the roadmap? @craigloewen-msft ?

@Panchie
Copy link

Panchie commented Sep 17, 2020

@ameeno @tomjepp Thank you both so much for this, works perfectly with Debian Buster + Mopidy on my desktop. Outstanding stuff.

@eamondo2
Copy link

eamondo2 commented Oct 9, 2020

So I had attempted to get some of the suggestions from this thread, as well as from others I'd found while doing research and wasn't able to get them working reliably.

This is mostly based on the guide from @ameeno above, but with a few extra bits to get X11 working as well.

Git Page

This is an attempt to collate what ended up working, hopefully it will be of some help.

@ameeno
Copy link

ameeno commented Oct 9, 2020

@eamondo2 Yea, that sounds good.

Only I use X410 instead of vcxsrv

also my .bashrc vars look like this:

### WSL2 Stuff

export WSL2IP=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')
export DISPLAY="$WSL2IP":0.0
export PULSE_SERVER=tcp:"$WSL2IP"

Which seems to work great

another guide I have adapted slightly is this one:
https://x410.dev/cookbook/wsl/opening-linux-terminal-directly-from-file-explorer/

Changes I have made include:

  1. ubuntu1804.exe becomes ubuntu.exe (for normal ubuntu d/l from ms store)

  2. All my Exports/functions/vars for wsl2 and .bashrc is actually inside a file called .exports in my home folder.
    my .bashrc file sources /home//.exports
    My Terminal here script sources /home//.exports

  3. also I use d:\wsl\ for the vbs script files.

In your case you would need to start the vcxsrv generated file to start your x server.
its really handy to have a true linux terminal wherever you want it!!!! :)

glad to help.

@timriker
Copy link

I’ve set in etc/pulse/default.pa this:

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;172.16.0.0/12

This will authorize all local connections for WSL1 and the RFC-1918 block 172.16.0.0/12 which is the default space for WSL2.

I would not recommend auth-anonymous=1 as this would allow any remote machine to connect. I use this inside my .bashrc:

if grep -qE "(Microsoft|WSL)" /proc/version &>/dev/null; then
  #WSL1
  export DISPLAY="${DISPLAY:-localhost:0.0}"
  export PULSE_SERVER="${PULSE_SERVER:-tcp:127.0.0.1}"
elif grep -q "microsoft" /proc/version &>/dev/null; then
  # WSL2
  export DISPLAY="$(ip route|awk '/^default/{print $3}'):0.0"
  export PULSE_SERVER="${PULSE_SERVER:-tcp:$(ip route|awk '/^default/{print $3}')}"
fi

Note: I lookup the WSL2 ip using ip route instead of /etc/resolv.conf as I bypass the WSL2 nameserver due to #5806

@adamcunnington
Copy link

@ameeno thanks for your guide. I followed it to the letter but unfortunately, on the WSL2 side, I get this:
Connection failure: Connection refused

On the windows side, here is what my running instance looks like - should I be concerned about any of the warnings/errors?

W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.
W: [(null)] pulsecore/core.c: failed to allocate shared memory pool. Falling back to a normal memory pool.
W: [(null)] pulsecore/authkey.c: Failed to open cookie file 'C:\Users\adam.cunnington\.config/pulse/cookie': No such file or directory
W: [(null)] pulsecore/authkey.c: Failed to load authorization key 'C:\Users\adam.cunnington\.config/pulse/cookie': No error
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.```

@ameeno
Copy link

ameeno commented Jan 4, 2021

Your pulse server is not accepting connections. Can you try to put pulse In c:\pulse\ directory and run pulse as administrator in CMD?

I expect if the pulse server does not come up on the windows side, then connection refused on the wsl2 side is quite normal.

Make sure you run your CMD as administrator to launch pulse first time.

Also I noticed you have a mix of back slashes and forward slashes in your logs.

@adamcunnington
Copy link

adamcunnington commented Jan 4, 2021

@ameeno I don't think it's that because here's a strange thing... sound works when I run a docker container within wsl2.

In my dockerfile, i do 2 things:

ENV PULSE_SERVER=tcp:host.docker.internal:4713

RUN apt-get install -y pulseaudio vlc

How can it be working through docker via WSL but not from WSL directly?

Full details below. make run-local runs locally whereas make run runs a docker container. How strange that the latter works and the former doesn't - what am I missing?

ac@L153W10LT:~/Projects/Home/Bible$ make run-local
. .venv/bin/activate && \
        python -ic "import bible"
>>> bible.esv["gen"][1][1].audio()
[0000000001ad3a50] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
[000000000212a1b0] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
>>> ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
[000000000212a1b0] alsa audio output error: cannot open ALSA device "default": No such file or directory
[000000000212a1b0] main audio output error: Audio output failed
[000000000212a1b0] main audio output error: The audio device "default" could not be used:
No such file or directory.
[000000000212a1b0] main audio output error: module not functional
[00007f02d804df50] main decoder error: failed to create audio output

----

ac@L153W10LT:~/Projects/Home/Bible$ make run
docker run -it --rm --env-file .env -e ESV_API_TOKEN bible:latest
. .venv/bin/activate && \
        python -ic "import bible"
>>> bible.esv["gen"][1][1].audio()
>>>

@adamcunnington
Copy link

@ameeno any thoughts? Grateful for any help, thank you

@ameeno
Copy link

ameeno commented Jan 6, 2021

definetly a linux config issue not a pulse issue.
if the pulse works on windows the pulse works on windows.

perhaps you have installed some other sound server or dummy sound configs in your wsl2 escapades? how about starting a new wsl2 install as a side project and seeing if you can get it working there following the guide?

otherwise there is too many possible variables to debug.

@adamcunnington
Copy link

I literally did a fresh install of wsl2 + 20.04 just yesterday and same issue. I have apt remove --purge pulseaudio alsa-base and reinstalled and same problem. But I agree with you - it's something in my ubuntu config that is causing problems when it's trying to connect to my windows pulse server.

@ameeno
Copy link

ameeno commented Jan 6, 2021

Yes. My guess is (and i ran into this initially when I was debugging the first time) - the default sound device in pulse is a) either DUMMY OUTPUT or B) Muted.

now to get around this you need to use a command-line mixer app to unmute the sound and select the correct sound device as default.

i think this might work.

sudo rm /etc/pulse/client.conf #or just make sure every line is commented by cat /etc/pulse/client.conf

rm -rf ~/.config/pulse/*
pax11publish -e -r

test connection (ensuring env var is correct) with

echo $PULSE_SERVER
pactl info

that should print out some information about the pulse server you are connected to.

finally, you can test sound via command line using

paplay /usr/share/sounds/freedesktop/stereo/bell.oga

and you should hear a bell assuming your pactl info command earlier yielded correct results.

all of this requires having pulseaudio-utils installed in ubuntu.

if the above does not work exit your wsl session after running the commenting/rm commands above. set the shutdown wsl2, restart, add the env var. check the env var mace sure you can get pactl info connecting to the pulse server.

if you cannot, maybe you need to debug the firewall settings etc or the pulse windows config for access list?

hope my pointers are helpful.

@adamcunnington
Copy link

adamcunnington commented Jan 6, 2021

@ameeno Thanks for the info. Here's the output of the first few:

ac@L153W10LT:~/Projects/Home/Bible$ sudo rm /etc/pulse/client.conf
[sudo] password for ac:
ac@L153W10LT:~/Projects/Home/Bible$ rm -rf ~/.config/pulse/*
ac@L153W10LT:~/Projects/Home/Bible$ pax11publish -e -r
xcb_connection_has_error() returned true
ac@L153W10LT:~/Projects/Home/Bible$ echo $PULSE_SERVER
tcp:172.31.240.1
ac@L153W10LT:~/Projects/Home/Bible$ pactl info
Connection failure: Connection refused

Presumably, it can't be a firewall issue if my docker container is able to connect via host.docker.internal? Maybe I am misunderstanding but when my docker container runs, is it connecting DIRECTLY to my windows pulse server or via my WSL ubuntu kernel?

Is there somewhere where I can see logs generated by pactl info?

@adamcunnington
Copy link

adamcunnington commented Jan 6, 2021

Or perhaps that's a foolish question - maybe the only thing my WSL kernel is doing when I run docker is routing ip connectivity - but fundamentally, it's the pulseaudio client within my docker container that is connecting to my windows pulseaudio server I guess. So, in other words, the problem is my wsl pulseaudio client config.

@ameeno
Copy link

ameeno commented Jan 6, 2021

quick google tells me you should try

basically salsa is selecting the wrong sound card.

if you install pulseaudio-alsa you should be able to use alsamixer to select the correct soundcard (your system is defaulting to a non-existent soundcard.

ps yes you are right, your docker is presumably connecting to the pulse audio server via IP routing.

your issue lies with your wsl install selecting the wrong soundcard.

you should also try

sudo apt install alsa-base pulseaudio pulseaudio-utils```

there is nothing wrong with having pulseaudio and alsa installed on your wsl, initially it will try to connect to a local soundcard inside the VM which does not exist, which is why we are overriding it with the environmental variable.

after you have done these installs, set the pulse server env var, and then launch alsamixer to select the right sound card.

@adamcunnington
Copy link

Thanks - via alsamixer or amixer, i can change the sound card but the question is, to what?

ac@L153W10LT:~/Projects/Home/Bible$ sudo aplay -l
aplay: device_list:274: no soundcards found...

@reteps
Copy link

reteps commented Jan 8, 2021

@adamcunnington You can check your audio devices like this too:

$ python3 -m pip install sounddevice && python3 -m sounddevice

  0 pulse, ALSA (32 in, 32 out)
* 1 default, ALSA (32 in, 32 out)

@ameeno Is there a way to get microphone in? I tried recording sound from the pulse sounddevice but it did not work. I can play sounds just fine however.

When I run pactl info it says:

Default Sink: output
Default Source: output.monitor

Update:

Changing record=1 enables the microphone.

Docs: https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/

@dcharlespyle
Copy link

dcharlespyle commented Jan 15, 2021

Pulseaudio 5.0 also allows the microphone to work between WSL 2 and Windows, and audio can be sampled on my machine at a rate as high as 192,000 Hz. But in WSL 2, the examples above no longer function. This is what I put in my ~/.bashrc file to get it to work right:

# Get the IP Address of the Windows 10 Host and use it in Environment.
HOST_IP=$(host YOURHOSTNAME | grep 192. | tail -1 | awk '{ print $NF }' | tr -d '\r')
export LIBGL_ALWAYS_INDIRECT=1
export DISPLAY=$HOST_IP:0.0
export NO_AT_BRIDGE=1
export PULSE_SERVER=tcp:$HOST_IP
export GTK2_RC_FILES=/usr/share/themes/Yaru-dark/gtk-2.0/gtkrc

Just substitute YOURHOSTNAME with your actual hostname, and the numbers with the first numbers in your range of IP addresses on your local network.

One can use the above as a basis for making shortcuts to Linux programs that can be run in Windows, too.

Here is an example that allows sound and X11 forwarding in the Files program (which will allow one to run videos and audio files directly out of the Files app and be able to see and hear them):

C:\Windows\System32\wsl.exe LIBGL_ALWAYS_INDIRECT=Yes IP=$(host YOURHOSTNAME | grep 192. | tail -1 | awk '{ print $NF }' | tr -d '\r') DISPLAY=$IP:0.0 PULSE_SERVER=tcp:$IP dbus-launch --exit-with-session nautilus

Some apps don't need all that. Most CLI apps can be run without X11 forwarding. Links2 requires it but Lynx does not (unless you want to run sound and watch videos from it as a novelty). This shortcut does not hide the console but that is useful for troubleshooting Linux apps. I just set them to run the console windows minimized, and if I need to see them just click them to restore them to read the output. The above command line examples work no matter what the IP addresses of WSL 2 and Windows host may be. But another oddity with pulseaudio 5.0 from x2go was that I had to organize the files according to Linux file system organization on the host machine, just to get it to work right. But it works great for stereo and for recording. Haven't figured out how to get it to work with 5.1 Windows coreaudio sound yet, but I hope that I eventually can.

image

Edited to add:
If you use your computer in a facility and your IP Address changes depending on where you are, you will want to use something that is hostname and IP address agnostic. I now use the following in place of the above:

# Get the IP Address of the Windows 10 Host and use it in Environment.
HOST_IP=$(host `hostname` | grep -oP '(\s)\d+(\.\d+){3}' | tail -1 | awk '{ print $NF }' | tr -d '\r')
export LIBGL_ALWAYS_INDIRECT=1
export DISPLAY=$HOST_IP:0.0
export NO_AT_BRIDGE=1
export PULSE_SERVER=tcp:$HOST_IP
export GTK2_RC_FILES=/usr/share/themes/Yaru-dark/gtk-2.0/gtkrc

The above will get your host's hostname and IP address, no matter what either of them might be. You don't have to know what they are using the revised scripting. It will add a second or two of time to get the information and export it, however. If you always know your hostname and first two or three numbers of your IP address, the prior scripting to the revision is faster.

@tamer1an
Copy link

Hi, dear @dcharlespyle.

Could I ask why is only version five and not from an official source?

Is later version above 5 is not compatible? like version 14 for the instance?
https://freedesktop.org/software/pulseaudio/releases/

@capoei
Copy link

capoei commented Nov 16, 2021

I found a way that is better than the x410 guide and works with the latest version of pulse on windows 10. installs pulse as a service, and is seamless.

this is the guide.

originally available from https://tomjepp.uk/2015/05/31/streaming-audio-from-linux-to-windows.html but now down:

I found a much newer set of binaries from the X2Go project: http://code.x2go.org/releases/binary-win32/3rd-party/pulse/.

To set up PulseAudio 5.0 on Windows, do the following:

Download pulseaudio-5.0-rev18.zip from http://code.x2go.org/releases/binary-win32/3rd-party/pulse/pulseaudio-5.0-rev18.zip Extract it and copy the pulse folder to C:\pulse Create a config.pa file in that folder with these contents:

load-module module-native-protocol-tcp auth-anonymous=1
load-module module-esound-protocol-tcp auth-anonymous=1
load-module module-waveout sink_name=output source_name=input record=0

Test this setup by running: c:\pulse\pulseaudio.exe -F config.pa On the wsl2 side you must run:

export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}');

play some sound on wsl2 and you will get it working. You should now be able to get Linux sound playing on your Windows PC. For a permanent setup, we need to create a Windows service rather than running PulseAudio in a command prompt. I use NSSM to run arbitrary programs as services. Download the latest version of NSSM.

https://nssm.cc/download

Extract it and copy nssm.exe from the win32 folder to c:\pulse. Run:

 c:\pulse\nssm.exe install PulseAudio

Fill in the following details on the Application tab: Path: c:\pulse\pulseaudio.exe Start-up directory: c:\pulse Arguments: -F c:\pulse\config.pa On the Details tab, fill in:

Display name: PulseAudio Now click Install service.

Finally, start the newly installed service - either through Services in Administrative Tools, or by running net start PulseAudio

now you will have a permanent pulseaudio service on windows which is very low ram usage. for permanent settings on the WSL side, you could put the following in your .bashrc file:

export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}');

That way, all pulseaudio sound will be passed to windows, seamlessly.

btw, my config above allows anonymous connections. you can restrict it to IP of the wsl2 vm if you want but it changes regularly. so there isnt really a way as far as I can tell, to have the IP restrictions in place and secured properly.

I have seen people use methods such as: sed and regex to update /modify the config.pa file to the correct IP address on WSL2 start-up, (that lives on /mnt/c/pulse/config.pa) but you must then stop and start the pulse audio NSSM service in windows. - I do not think that is so easy.

Allowing anonymous connections works fine for so far, and has the added benefit, that any WSL/Hyper-V -VM can just put sound out of my laptop over tcp.

Hope that helps!

ever tried to make it work with Jack?

@gschian0
Copy link

I try this and when I run pulse audio with the Config.pa file I get this error .. `E: [(null)] pulsecore/module.c: Failed to load module "module-native-protocol-tcp" (argument: "auth-anonymous=1"): initialization failed.
E: [(null)] daemon/main.c: Module load failed.
E: [(null)] daemon/main.c: Failed to initialize daemon.
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.

C:\pulse>c:\pulse\pulseaudio.exe -F config.pa
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.
W: [(null)] pulsecore/core.c: failed to allocate shared memory pool. Falling back to a normal memory pool.
W: [(null)] pulsecore/authkey.c: Failed to open cookie file 'C:\Users\GennaroSchiano.config/pulse/cookie': No such file or directory
W: [(null)] pulsecore/authkey.c: Failed to load authorization key 'C:\Users\GennaroSchiano.config/pulse/cookie': No error
W: [(null)] pulsecore/authkey.c: Failed to open cookie file 'C:\Users\GennaroSchiano.pulse-cookie': No such file or directory
W: [(null)] pulsecore/authkey.c: Failed to load authorization key 'C:\Users\GennaroSchiano.pulse-cookie': No error
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.
W: [(null)] pulsecore/authkey.c: Failed to open cookie file 'C:\Users\GennaroSchiano.config/pulse/cookie': No such file or directory
W: [(null)] pulsecore/authkey.c: Failed to load authorization key 'C:\Users\GennaroSchiano.config/pulse/cookie': No error
E: [(null)] pulsecore/module.c: Failed to load module "module-native-protocol-tcp" (argument: "auth-ip-acl=127.0.0.1;172.16.0.0/12"): initialization failed.
E: [(null)] daemon/main.c: Module load failed.
E: [(null)] daemon/main.c: Failed to initialize daemon.
W: [(null)] pulsecore/core-util.c: Secure directory creation not supported on Win32.
`
any help is greatly appreciated!

@dcharlespyle
Copy link

WSL 2 combined with WSLg provide built-in support for sound. No configuration is needed, nor is running pulseaudio any longer necessary on the Windows side. Delete or comment out any commands regarding redirection of audio or video you put in your .bashrc file.

Run the following to ensure that you are using the latest stable WSL 2 configuration:

wsl --update
wsl --shutdown

@gschian0
Copy link

I've tried this now... and get this when running the command
..
`C:\Windows\system32>wsl --update
Checking for updates...
The Windows Subsystem for Linux kernel can be manually updated with 'wsl --update', but automatic updates cannot occur due to your system settings.
To receive automatic kernel updates, please enable the Windows Update setting: 'Receive updates for other Microsoft products when you update Windows'.
For more information please visit https://aka.ms/wsl2kernel.

C:\Windows\system32>wsl --shutdown

C:\Windows\system32>
and when I try to open Audacity 1128 ◯ audacity

(audacity:965): dbind-WARNING **: 15:03:21.050: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-prKBEQTgsM: Connection refused
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM dmix
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ScreenToClient cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: ClientToScreen cannot work when toplevel window is not shown
15:03:36: Debug: Unrecognized accel key 'backspace', accel string ignored.
15:03:36: Debug: Unrecognized accel key 'backspace', accel string ignored.
15:03:36: Debug: Unrecognized accel key 'numpad_enter', accel string ignored.
15:03:36: Debug: Unrecognized accel key 'numpad_enter', accel string ignored.
`

@gschian0
Copy link

I get this error when I comment the display redirect in my .zshrc
`qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
`

@gschian0
Copy link

I think the issue is I’m on windows 10 is there a way to do this on windows 10?

@timriker
Copy link

If you want graphics app support, the closed source commercial app MobaXterm includes an X server and works on Windows 10. It's not open source, but there is a free version for download.
https://mobaxterm.mobatek.net/download.html
I add this to my .bashrc:

export DISPLAY="$(ip route|awk '/^default/{print $3}'):0.0"
export PULSE_SERVER="${PULSE_SERVER:-tcp:$(ip route|awk '/^default/{print $3}')}"

@dcharlespyle
Copy link

For Windows 10, you need Windows 10 Insider build 21364 or later to use WSLg. At least the last time I checked. What's your build number?

Also, if you use redirection for sound and graphics and a third party XServer and pulseaudio, you must use the IP address of your host Windows machine. Also, if you are using pulseaudio, if you are trying to use version 5.0 for Windows you must manually organize the directories properly.

@leostudiooo
Copy link

leostudiooo commented Jul 31, 2022

Same problem running stakira/OpenUtau.

ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_id returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM dmix

It seems that there isn't any sound device that can be recognized by the ALSA.

Hope Microsoft will add sound support in later versions.

@dcharlespyle
Copy link

dcharlespyle commented Jul 31, 2022

WSL2 already has built-in sound support and Wayland server support. I haven't had to use any third-party ports of Pulseaudio 1.0 or 5.0 or XServer software since WSLg and WSL in Windows 10 Pro preview versions or in Windows 11. I'm using Windows 11 Pro now. But if you did use such third-party software, you need to comment out or remove those lines that redirect sound to the host IP address. Otherwise, the built-in sound support won't work.

If you still do need the ported third-party sound device software, I have it here (both 1.0 and 5.0, ready to go; extract to C: and pick one version, and just run the executable pulseaudio.exe in the bin folder with the -d option (though you might have to tweak to work with your audio codecs and hardware):

WSLAudio.zip

But then you will have to redirect the sound in the environment variable to the host IP address. And you also will need third-party XServer software.

Oh, and one other thing. OpenUtau is looking for a hardware device. There isn't one in WSL or WSL2. WSL is using an RDP Sink, as you will see from the following screenshot.

image

On the other hand, Audacity works well with an RDP Sink, as will be seen in the following screenshot.

image

So, I think it should just be a matter of somehow telling OpenUtau to use the RDP Sink. Not sure at the moment how to do that right now. But if you manage to make it work before I can manage to get to it, please post what you did here.

@capoei
Copy link

capoei commented Jul 31, 2022

Audacity working means PortAudio works? afair Jack can use PortAudio?

@dcharlespyle
Copy link

This is what the About dialog displays:
image

@capoei
Copy link

capoei commented Aug 1, 2022

tried "jack -d portaudio" but it says driver not found.

@dcharlespyle
Copy link

dcharlespyle commented Aug 1, 2022

tried "jack -d portaudio" but it says driver not found.

That's not too surprising. You need to install the jack and portaudio backends for pulseaudio and for ALSA. But there is another issue. I tried to run jack, and I don't even get that far (I don't recall ever using it in all the time I've used Linux, either). I get a message asking me if I meant to type several other commands. That does not seem to bode well for the package in Ubuntu.

There is no jack installation candidate in 20.04. I can install jackd (which is identified as a dummy package) and run the jackd command, though, if I wanted to do so. I also tried to install portaudio but both synaptic and apt say the package is not found. I do have the libportaudio2 package installed, however. And the portaudio19-dev package still is available, but installing it seems pointless if the portaudio package itself isn't available. Why do you need to use jack in WSL2? Do you have software that is dependent upon it?

If you still want to use it, you might try enabling the backports repository. But when Ubuntu starts putting stuff in backports, it often means it is going away.

And one other thing: There is no audio hardware device in WSL. Not even emulated hardware. Not presently at any rate. All that is available is the RDP Sink device.

image
image

@capoei
Copy link

capoei commented Aug 1, 2022

Why do you need to use jack in WSL2? Do you have software that is dependent upon it?

I will look further into your post later, but as someone working with audio there is tons of great free audio plugins in Linux I would like to be able to use via WSL2, like the "Linux Studio Plugins" for example.
when you showed that Audacity works, which is using PortAudio afaiui, I wondered if we could use PortAudio as a backend to make Jack work.
If I had a free wish I would wish PipeWire support though. With Pipewire everybody would be served, and it would be future proof

@dcharlespyle
Copy link

Whatever solution is used, it must address the RDP Sink. There is no audio hardware emulation in WSL. At least, not yet.

@ckmufeng
Copy link

sometimes for connection refused, we should add --exit-idle-time=1 for pulse service on Windows.

@rbrisita
Copy link

rbrisita commented May 4, 2023

Here is one way to resolve Connection failure: Connection refused issue:

  1. Add below to ~/.bashrc:
export HOST_IP="$(ip route |awk '/^default/{print $3}')"
export PULSE_SERVER="tcp:$HOST_IP"
  1. Run source ~/.bashrc.
  2. Edit etc/pulse/default.pa and etc/pulse/daemon.conf files as stated here.
  3. From the Command Prompt run pulseaudio.exe.
  4. Open Windows Defender Firewall control panel.
  5. Go to Advanced settings.
  6. Select Inbound Rules.
  7. Double click on the pulseaudio application.
  8. Click on Allow the connection action.
  9. Click OK.

@xt0r3
Copy link

xt0r3 commented Aug 13, 2023

I wanted to add my two cents:
If you're encountering static hissing or white noise when trying to play sounds with aplay or if you experience your microphone connecting to the server but not recording any sound

  • Make sure that PulseAudio is NOT installed on the WSL instance. You can run sudo apt remove pulseaudio to make sure

(I'm not fully sure what the issue is, but this fixed it for me.)

Also, some services like sox (play), alsa-utils (aplay) and pulseaudio-utils (paplay) won't find the audio device, but mpg123 will
You can install it by running sudo apt install mpg123
Then, you can use it to play sounds by running mpg123 file.mp3

@thelamer
Copy link

thelamer commented Apr 9, 2024

Shooting comments into a necro thread because I have nothing better to do.

How in the heck can AUDIO SUPPORT be an afterthought? This is not some obscure feature set, this is AUDIO for the applications that run under WSL. You jumped though like 50 hoops to make video acceleration function but "install pulseaudio server on your Windows machine and proxy traffic to it over tcp" is the official solution citing a pile of third party blogs.

I am not sure how to emphasize this to you as I thought this was supposed to be your job, but just because some randos found a way to make it work does not mean that you should not be working to support audio out of the box.

You are already leeching off of the great work of a mountain of devs that do this stuff day in and day out for free the least you can do here is keep the issue open and put something in your backlog to officially support pipewire and pulseaudio in some fashion in WSL.

What I want to hear is "You ain't got no problem TheLamer, we're on it, everyone just chill out, we're sending the dev which should be coming directly"

@darrenhearn
Copy link

@thelamer , as someone who's done my own share of shouting into voids, I sympathize with the comment; however, if you're still digging for WSL2 sound support, note that PulseAudio should work "out of the box" these days - see wslg/README.md. It worked for me, though I had to pay attention to the WSLg Architecture Overview (and run a few experiments) to understand that the sound interface is limited to a PulseAudio "bridge" - therefore interfaces that look for sound hardware, e.g. PortAudio, probably won't work without additional effort. At least that was my take-away; I think it's also roughly the same take as @dcharlespyle's prior comment.

For what it's worth, my (limited) experience is that WSL development does an admirable job of keeping pace with customer demands. But I'd also agree that transparency about what's in the works/priorities can feel thin on the ground (case in point, it would've been nice/saved me time if there had been a follow-up pointer in the "closing this issue" comment 3 years ago).

@epdesjardins
Copy link

Can anyone provide insight into why my sound works out of the box using bash in WSL2 but if I open the same binary via zsh no audio device driver is recognized? Is there something I need to add to my zshrc?

@onomatopellan
Copy link

onomatopellan commented May 24, 2024

@epdesjardins Type env in both cases and you will see which environment variable is missing. In later WSL2 versions the export PULSE_SERVER=unix:/mnt/wslg/PulseServer is a must.

@epdesjardins
Copy link

epdesjardins commented May 24, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests