an open-source digital signal processing and sound synthesis language
about · links · contact

Standalone RTcmix

RTcmix is availble to run as a standalone app on Mac OS X and Windows and in the command line environments of most Unix-like systems, including Mac OS X and various flavors of Linux, IRIX, and FreeBSD. RTcmix is also available to run in Max and Pd via the rtcmix~ object and the iRTcmix library is available to use in iOS apps (iPhone, iPad, iPod Touch).

RTcmix Standalone Apps

John Gibson has created two apps that will let you run RTcmix scores without having to learn Unix shell commands. They are available to download for Mac and PC.

RTcmix on the Command Line - macOS

The RTcmix source code lives on GitHub. There are two ways to download it.
  1. Go to the RTcmix Releases page, and download the most recent (or other) release, using the "Source code (zip)" or "Source code (tar.gz)" buttons. Unpack this archive, if necessary, by double-clicking its icon. This should produce a folder called "RTcmix-4.3.1" (or a similar version number). Then move this folder into the place where you keep RTcmix source code. The usual place for such things is /usr/local/src, but it can be anywhere.

    -OR-

  2. Assuming you are conversant with git, navigate to a directory where you would like the source code to live, and give this command in the shell:
    git clone https://github.com/RTcmix/RTcmix

Compiling RTcmix on macOS

In the RTcmix source code directory ("RTcmix/"), type the shell command:
	./configure
There are options you may wish to use with the configure command for your installation -- Perl, Python, X-Windows, fftw-lib, etc. See the INSTALL file in the "RTcmix/" directory for a discussion of these.

After running the configure command (with any appropriate options), then type (in that same "RTcmix/" directory):

	make && make install
RTcmix should compile, install, and off you go!

A Note on the macOS command path

All RTcmix executable commands, including the CMIX command, are placed in the "RTcmix/bin" directory. To access these commands, you can copy/move them to a directory like "/usr/local/bin" or "/usr/bin". These directories are probably already on your command search path. To see your command search path, type the command:
	echo $path
or
	echo $PATH
and you should see a listing of all directories that are searched for executable commands.

You can also simply add the "RTcmix/bin" directory to your command search path. You will probably need to edit or create a ".tcshrc: or ".cshrc" or equivalent shell initialization file to do this. An example of a line in a ".tcshrc" that accomplishes this is:

	set path=(~/bin $path /usr/local/bin /usr/local/src/RTcmix/bin ".")
Once you do this, you will need to start a new Terminal or Shell window (or use the unix source command) to reflect the change you have made. See the documentation for "tcsh" or "csh" or "bash" for more information.

If all else fails, you can type the whole pathname as a prefix to the RTcmix executable command you want:

	/usr/local/src/RTcmix/bin/CMIX
	/usr/local/src/RTcmix/bin/sfprint somefile.aiff
	/usr/local/src/RTcmix/bin/cpspch 8.07 

RTcmix on the Command Line - Windows

Windows 10 offers a capability that is useful for those of us employing RTcmix for our music and audio work. The Windows Subsystem for Linux feature runs a full Linux distribution within the context of Windows itself; no partitioning, rebooting or other 'traditional' Linux/Windows actions areare necessary. RTcmix standalone runs well in the WSL2 environment.

The setup for doing this is a little complicated, because three different setup operations have to take place:

  • The Windows Subsystem for Linux feature needs to be installed and configured with an appropriate Linux distribution. WSL2 should be used -- it's apparently a big improvement over the original WSL. I don't know if these instructions will work for the earlier WSL.

  • The RTcmix standalone needs to be configured and compiled. A number of packages for Linux will have to be installed to allow this.

  • An audio server needs to be established in Windows and then addressed from Linux to enable real-time audio 'in' the WSL2 environment.

Enable WSL2 and install a Linux distro

First of all, verify that you are running Windows 10, v 2004 (build 19041 or higher). To verify this, type "winver" into the start/search box and run the command. You can also run this command by typing the Windows logo key + R and typing "winver" into the "open" text box and hitting "OK". If you don't have this version of Windows installed, use Windows Update to get it.

Follow the directions in this page to install the WSL2 package:

	https://docs.microsoft.com/en-us/windows/wsl/install-win10
I 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: You will probably need to install the Linux kernel extension from the https://aka.ms/wsl2kernel page as discussed in the web page above]

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


Build and install RTcmix

The first step is to make sure the Ubuntu package system is updated. Start a Linux terminal window, and type:
	sudo apt update
[note: On my newer Windows machine, the 'malwarebytes' virus and firewall software presented no problems. The Synantec virus/firewall software on my older machine prevented the package manager from communicating with the Ubuntu servers. I had to disable the Symantec firewall and I used the Windows Defender firewall instead]

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 tcsh
So I did that, and then I could say:
	chsh -s /usr/bin/tcsh brad
and 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-dev
Download 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-alsa
At this point, if you aren't using my Windows RTcmix package (same link as above), you will need to make three minor code changes:

    1. Go into the RTcmix/src/control directory and edit the Makefile. Line 4 should say:
    	DIRS = common midi mouse display datafile pfbus
    
    Change it to:
    	DIRS = common midi pfbus
    

    2. Go into the RTcmix/src/audio drectory and edit the file "ALSAaudiodevice.cpp". The function ALSAAudioDevice::run() (around line 418) has this code:
    	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;
    	   }
    	}
    

    3. In that same file, the function "ALSAAudioDevice::recognize(const char *desc)" (around line 444) should say:
    	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;
    	}
    

After making these changes, navigate back to the top-level RTcmix directory and type:
	make
	make install
The "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.

[note: you might want to set up the RTcmix/bin directory on your command path so you can access the RTcmix executable commands from any directory where you are working in a Linux terminal window]

Setting up real-time playback with alsa/pulseaudio

[note: these instructions are based on this web page about setting up the WSL environment]

1. Go to:
	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.


2. Go into the "pulseaudio-1.1/etc/pulse" directory and edit the file "default.pa". Change the line (should be about line 60) that says:
	#load-module module-native-protocol-tcp
to
	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 = 20
to
	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.

[note: At some point you may need to change your firewall settings. I think they don't become an issue until you try to connect to this pulseaudio server from the Linux side; but you might want to put in an exception for "pulseaudio.exe" in your firewall rules now. Or turn off your anti-virus/firewall software temporarily and see what needs to be done to allow everything to connect and work]


5. In a Linux terminal, download the pulseaudio tools by saying:
	sudo apt install pulseaudio-utils

6. Next you need to set up the proper remote (Windows) server information. If you use bash as your shell, type:
	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.

[note: You may want to put those environment-setting lines in your .bashrc or .tcshrc configuration files so you don't have to enter them every time you start a Linux terminal]


6A. You can now check to see if your connection to the Windows by typing the following (bash) command:
	nc -vz $(grep nameserver /etc/resolv.conf | awk '{print $2}') 4713
or this (tcsh) command:
	nc -vz `grep nameserver /etc/resolv.conf | awk ' { print $2 } '`  4713
The nc command should immediately return "Connection to 4713 port [tcp/*] succeeded!". If it doesn't, it probably means you have a firewall issue.


7. To configure ALSA to work wth the pulseaudio server, create the file "/etc/asound.conf" and insert the following content:
	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
[note: "aplay" doesn't seem to work well with non-wav formats]

If that works, then you should be able to say (from the commends in the "RTcmix/bin" directory:
	play -D pulse somesoundfile.wav
	play -D pulse somesoundfile.aif
	CMIX -D pulse < somescorefile.sco
And that's it! Remember that you will have to restart the "pulseaudio.exe" server from Windows every time you logout or restart your machine.