The setup for doing this is a little complicated, because three different setup operations have to take place:
Follow the directions in this page to install the WSL2 package:
https://docs.microsoft.com/en-us/windows/wsl/install-win10I installed Ubuntu 18.04 as my Linux distro. The rest of these instructions assume this Linux is being used. I imagine that things are similar for other distros.
[note: On my newer (May 2020, ASUS ROG Zephyrus M) Windows machine, the 'virtualization' machine feature (hypervisor, hyper-v, etc.) was installed and running, so I had no problem downloading and running Ubuntu, On my older (May 2017, 2017 ASUS ROG G752 laptop) machine I had to turn on this feature. The error I got that signalled this problen ocurred at the end of the Ubuntu install process: "a feature is missing...". See this page for how I managed to get it running]
sudo apt update
I like tcsh as my shell, but when I typed it in my Linux terminal I got:
Command 'tcsh' not found, but can be installed with: sudo apt install tcshSo I did that, and then I could say:
chsh -s /usr/bin/tcsh bradand my Linux terminals would run tcsh. But you can stick with bash (the default shell) if you want.
Next I had to install a set of packages that would allow me to build RTcmix on Ubuntu:
sudo apt install build-essential sudo apt install flex sudo apt install bison sudo apt install pmidi sudo apt install alsa sudo apt install libasound2-devDownload and unpack RTcmix from rtcmix.org ("RTcmix on the Command Line"). If you'd prefer, here is a tar archive of the RTcmix I used on my Windows/Ubuntu machines. It has the minor changes listed below incorporated already.
Once you have unpacked the RTcmix archive, go into the top-level RTcmix folder and type:
./configure --with-alsaAt this point, if you aren't using my Windows RTcmix package (same link as above), you will need to make three minor code changes:
DIRS = common midi mouse display datafile pfbusChange it to:
DIRS = common midi pfbus
void ALSAAudioDevice::run() { PRINT0("ALSAAudioDevice::run: top of loop\n"); int ret; while ((ret = waitForDevice(isPlaying() ? 0 : 1000)) == 0) { if (runCallback() != true) { break; } }Change it to this:
void ALSAAudioDevice::run() { PRINT0("ALSAAudioDevice::run: top of loop\n"); int ret; while (1) { if (runCallback() != true) { break; } }
bool ALSAAudioDevice::recognize(const char *desc) { return desc == NULL || strncmp(desc, "hw:", 3) == 0 || strncmp(desc, "plug", 4) == 0; }Change it to this:
bool ALSAAudioDevice::recognize(const char *desc) { return desc == NULL || strncmp(desc, "hw:", 3) == 0 || strncmp(desc, "plug", 4) == 0 || strncmp(desc, "pulse", 5) == 0; }
make make installThe "CMIX" and "play/cmixplay" executable commands should now be located in the RTcmix/bin directory. Because we haven't set up real-time audio yet, "play/cmixplay" won't work, but the "CMIX" command will work if you turn off audio playback while processing. For example, running the following score:
set_option("play = 0") rsetparams(44100, 2) load("WAVETABLE") rtoutput("outputsound.aif") WAVETABLE(0, 7, 20000, 8.00, 0.5)should produce a soundfile ("outputsound.aif") that can be played -- a 7-second long middle "C" sine wave tone.
https://www.freedesktop.org/wiki/Software/PulseAudio/Ports/Windows/Support/and click on the link that says "zipfile containing.preview binaries". This will download the pulseaudio-1.1.zip archive. Unpack that archive and store the "pulseaudio-1.1" folder somewhere on your system.
#load-module module-native-protocol-tcpto
load-module module-native-protocol-tcp auth-anonymous=1
Be sure to get rid of the "#" at the beginning of the line.
3. Also in that "pulseaudio-1.1/etc/pulse" directory, edit the file
"daemon.conf" (it used to be called "daemon.pa"), and change the line
(around line 39):
; exit-idle-time = 20to
exit-idle-time = -1
Be sure to get rid of the ";" at the beginning of the line.
4. You can now start the Windows pulseaudio server. Go into the
"pulseaudio-1.1/bin" directory and (from Windows) start up the
"pulseaudio.exe" file. You should see a command-window start up (you
may have to launch the "pulseaudio.exe" file several times). This
window may say things like:
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/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. E: [(null)] daemon/main.c: Failed to load directory.but that's ok. Do not close the window (although of course you can minimize it). That's the pulseaudio server.
sudo apt install pulseaudio-utils
export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{ print $2 }')or type this:
setenv PULSE_SERVER `grep nameserver /etc/resolv.conf | awk '{ print "tcp:"$2 }'`if you are using tcsh or other csh-derived shells.
nc -vz $(grep nameserver /etc/resolv.conf | awk '{print $2}') 4713or this (tcsh) command:
nc -vz `grep nameserver /etc/resolv.conf | awk ' { print $2 } '` 4713The nc command should immediately return "Connection to 4713 port [tcp/*] succeeded!". If it doesn't, it probably means you have a firewall issue.
pcm.!default { type pulse # If defaults.namehint.showall is set to off in alsa.conf, then this is # necessary to make this pcm show up in the list returned by # snd_device_name_hint or aplay -L hint.description "Default Audio Device" } ctl.!default { type pulse }Once you have done that, you should be able to use the pulseaudio server system. ALSA comes with a test soundfile player you can try from a Linux terminal window:
aplay somesoundfile.wav
play -D pulse somesoundfile.wav play -D pulse somesoundfile.aif CMIX -D pulse < somescorefile.scoAnd that's it! Remember that you will have to restart the "pulseaudio.exe" server from Windows every time you logout or restart your machine.