At the Sounding Edge: OpenMusic and SuperCollider3

by Dave Phillips

Even a casual glance at the contents of the linux-sound.org pages shows that Linux enjoys a broad range of interesting sound and music applications. Players, recorders and editors abound, and I plan to profile some of that software in this column. This month I present two applications that are rather close to the edge of Linux audio software development: IRCAM's OpenMusic and James McCartney's SuperCollider3.

OpenMusic

OpenMusic (OM) for Linux is a porting project working to bring an outstanding music composition environment from Macintosh to Linux. As you might expect from a Mac music application, OM is an intensely graphic environment, and the developers at IRCAM (aka the Institut de Recherche et Coordination Acoustique/Musique in Paris) have done impressive work with the Linux version (Figure 1).

Figure 1. OpenMusic

Its Web site tells us that OM is a visual programming language based on CommonLisp/CLOS, that it is icon-oriented with a drag-and-drop GUI and that it has visual control structures for interfacing with the environment's Lisp structures. OM has been designed as a general-purpose programming language, but its unique classes and function libraries clearly are oriented towards the domain of music composition.

Non-musicians might wonder exactly what OM does for a composer. OM is not a software synthesizer, nor is it a soundfile editor or MIDI sequencer. OM's classes and functions supply the means for exploring the musical possibilities as the manipulation and permutation of sets for pitch, rhythm and dynamics, series and tone-row variation, random and aleatoric generative processes and many other techniques best carried out by a machine. In some respects OM is similar to Rick Taube's outstanding Common Music, another Lisp-based environment for music composition, but OM's rich GUI provides a very different experience.

Basic OM

This article is not intended to be an OM tutorial. I'm merely going to describe its basic operation and show off some of its interface amenities. I must stress that although OM itself is not a new program (the Linux port is for version 4.7.1), it is new to Linux and should be considered as beta-stage software. Not every aspect of the original has been imported faithfully, but I'm happy to say that most of the features found in the Mac versions have made it to the Linux port.

You can acquire OM from the IRCAM URL, but I seriously advise using the Planet CCRMA packages instead. OM requires some extra pieces you may not have on your system, including:

  • CMUCL, Carnegie-Mellon's version of Common Lisp

  • libgtk-canvas, a canvas object for GTK 1.2

  • CLG, the Common Lisp/GTK bindings

  • MIDIShare, a MIDI toolkit from the GRAME team

  • fluidsynth, a soundfont-based synthesizer

Specific versions of these dependencies may be required, so check with the OM Web site for a list of the most current requirements. The Web site also includes detailed installation and configuration instructions from IRCAM developer Francois Dechelle. I repeat, however, that you're probably better off with the Planet CCRMA packages. DEB packages for the AGNULA Linux audio distribution should be available soon.

Once everything has been installed and correctly configured, you can launch an OM session with the following series of commands:


	fluidsynth -a alsa -m midishare soundfonts/8mbgmsfx.sf2
	msconnect
	omlinux

I suggest opening each program from its own xterm. Doing so makes it easier to keep track of any reports or error messages coming from the specific app.

On my 800MHz machine, OM takes a little time to open. Lisp is an interpreted language, so it takes a while for everything to prepare. When the system is ready for use the GTK canvas object appears, and you're ready to start using OM.

OM is similar to its IRCAM synthesis sibling jMax in its use of icons to represent its various classes and libraries. These icons are placed on the canvas and wired together to create a patch. An OM patch may be a note generator, a MIDI event processor or even a simple playback device. OM's icons include classes and functions for arithmetic, list manipulation, random number generation, various MIDI actions, program control and many others. Abstraction (that is, a patch within a patch) is supported, and patches may be saved for reuse within other projects.

Figure 1 shows off a relatively complex OM patch from Karim Haddad's series of helpful tutorials. In this patch (Tutorial 14) we can see many of OM's main features at work. Various icons have been connected to form a MIDI note generator that directs its output to a pair of General MIDI programs played on two MIDI channels by way of the fluidsynth synthesizer. The big blue-green object at the bottom of the patch is an instance of a music/score class called a CHORD-SEQ. In true Lisp fashion, once the patch has been built, it must be evaluated before playing by selecting it and then typing v on the QWERTY keyboard. Type p to hear the results and s to stop the playback. Reevaluating the object produces a new note series.

The example also demonstrates OM's abstraction at work. Both the omloop and note generator icons are subpatches, and I have opened them up for inspection in Figure 1. Again I'll skip the details of subpatch construction, but I should note that subpatches are built in the same way as the way I have described for patches.

Higher Level OM

Building patches is fun, but OM includes a higher level of organization called a maquette (French for a model or sketch). At its simplest a maquette is a grid for laying out a sequence of patches. The maquette then is evaluated and played as though it were a single patch. However, the maquette is capable of making its own connections between patches, providing yet another layer of processing between individual patches. Figure 2 illustrates a basic example of an OM maquette. Although four blocks are shown, only two patches are used, each copied and pasted for repetition. Double-clicking on a block opens its structure for further investigation and editing.

Figure 2. The OM Maquette

OM's Future

Notable incomplete aspects of OM for Linux include the music notation, the maquette graphics and the Linux-specific documentation. Nevertheless, the port is quite usable, and I've been enjoying my trek through the tutorials. The OM developers have been responsive and helpful, and I look forward to more experimentation with this most unique system.

SuperCollider3

James McCartney's SuperCollider3 (SC3) is a popular sound synthesis and music composition environment formerly available only for Macintosh but now available in a Linux port. Once again the original program makes heavy use of the Mac's graphics-rich interface, but the actual SC3 engine can be decoupled from its GUI and ported by itself. That is the current condition of the Linux port of SC3: its synthesis engine and its language interface have been successfully ported to Linux, but its GUI components await the transfer from Mac to Linux.

SC3 currently is the only officially maintained version of SuperCollider, and this profile is merely a look at the environment in a preliminary stage. However, SC3 is interesting and useful even in its purely text-mode interface.

Collision Configuration

SC3 is now a SourceForge project, so you need to acquire the sources from its SF site, follow the directions found there and retrieve the latest CVS sources. SC3 truly is under development, so I advise building and using the latest CVS sources to stay current with the latest features.

Compilation and installation instructions are found in the SuperCollider3/linux directory, where a README file explains how to compile SC3 for Linux. It's easy, but be sure to follow the instructions exactly. You must have a number of dependencies met before you can compile SC3, including ALSA, JACK, libsndfile and others. Check that README for the latest news regarding required packages.

Configuring SC3

SC3 for Linux is divided into two parts. The scsynth binary is the synthesis engine and server, while the sclang program is the language interface for composing, editing and executing your SC3 code.

Before doing anything else with SC3, you should do a little extra setup for the sclang interface. First, copy the sclang.cfg and sclang.sc files from the linux/examples directory to your home directory. Rename them to .sclang.cfg and .sclang.sc and then edit each one in your text editor. They should be usable without any editing, but open and study them anyway--it's good to know their functions in the environment. See the SC3 documentation for further details about setup and configuration. I also advise the interested reader to visit Stefan Kersten's SC3 site for further details regarding Linux-specific features.

Configuring SC3 requires a few unusual steps, including making additions to your ~/.bashrc file, preparing Emacs for a sclang mode and writing a shell script to launch the synthesis server easily. These steps all are detailed in either the program docs or on Stefan's site.

Basic Collision

To begin using SC3, make sure the JACK audio server is running and then start the scsynth server.

Run the sc3start.sh shell script from your home directory. You should see something similar to these messages:


	[dlphilp@localhost dlphilp]$ ./sc3start.sh 
	rm: cannot remove `synthdefs': Is a directory
	SC_JackDriver: jack name is SuperCollider
	SC_JackDriver: connected  alsa_pcm:capture_1 to SuperCollider:in_1
	SC_JackDriver: connected  alsa_pcm:capture_2 to SuperCollider:in_2
	SC_JackDriver: connected  SuperCollider:out_1 to alsa_pcm:playback_1
	SC_JackDriver: connected  SuperCollider:out_2 to alsa_pcm:playback_2
	SuperCollider 3 server ready..

Now we'll test some SC3 code in the Emacs text editor. Start the editor with emacs -sclang, and Emacs opens as usual. But, when you write or load SC3 code into one of its buffers, a new menu appears with various sclang items. It is possible to use SC3 without Emacs, but I regard that as an exercise in frustration. As an ardent vi user, I was less than enthusiastic about learning how to use Emacs, but I'm definitely a convert when it comes to using SC3. As with OM, you write your SC3 code in Emacs and then select and evaluate it. If the evaluation is good, you can play your code block directly from Emacs. Thus, Emacs can be used as a rather complete working environment for SC3 (sans cool Mac graphics, of course).

The following code is the audio software equivalent of "Hello world!", creating and playing a simple sine wave at 300Hz :


	s = Server.local;
	s.freeAll;
	SynthDef("sine-out", {
		Out.ar(0, SinOsc.ar(300,0,0.1))
	}).play(s);

When this file is saved you should notice two new aspects to your Emacs session. The SC3 code now is highlighted in color and a new SCLang menu has appeared in the top menu bar (Figure 3).

Figure 3. Emacs in SuperCollider (SClang) Mode

Now place the cursor on this line


	s = Server.local

and then open the SCLang menu and select Evaluate Line. This opens and verifies the connection between sclang and the scsynth server. You should see the Emacs buffer for SCLang respond with this brief report:


	a Server

Now, highlight everything in the code from SynthDef through play(s);. Open the SCLang menu again and select Evaluate Region. The SCLang buffer again issues a brief report:


	Synth("sine-out" : 1004)

You now should hear a sine wave playing with a frequency of 300Hz. Place the cursor on this line:


	s.freeAll

Evaluate it to stop the audio. By the way, memorizing a few Emacs keyboard accelerators, such as C-c C-c for evaluating a line or region, replaces a lot of mouse movement.

A Bigger Collision

Let's see how we can make something a little more musical. This time I am going to loop my simple sine instrument, increasing its frequency with each iteration of the loop. I start by surrounding the instrument with a loop structure and add a duration value to each note sounded. This code illustrates these procedures wrapped in what SC3 calls a Task:


	s = Server.local;

	Task({ 
		var freqArray, dur; 
		freqArray = [262, 262, 294, 311, 392, 392, 370, 392];
		dur = 0.1;
		4.do {
		8.do { arg i;
			{SinOsc.ar( freqArray[i], 0, 0.2) * Line.kr(1, 0, dur, doneAction: 2)}.play;
			dur.wait;
		}}
	}).play 

This Task also demonstrates nested looping. The inner loop sequentially reads the eight notes in freqArray, incrementing the array pointer (i) by one on each repeat. This inner loop itself then is played four times by the outer loop. As in the previous example, I evaluate the server and then the Task block to hear my simple repeated pattern. Termination of the do loop signals the end of the task, so an explicit call to free the server is not necessary.

SC3's Help system can be accessed from Emacs. Highlight the item you need help with and then select Find Help from the SCLang menu. The emacs minibuffer asks for the help topic. The default topic is your selection, so press Enter, and a new Emacs window appears containing the help file for your selected item. The SC3 Help files include useful example code, so learn the system and use it.

Figure 4. SC3 Help in Emacs

SC3 does MIDI too. It identifies itself as an ALSA sequencer client, thus giving it flexible routing capabilities. The following code takes a slightly more complex version of my simple sine instrument and turns it over to MIDI control:


	MIDIIn.connect;
	s = Server.local;
	s.boot;	
	s.latency = 0;

	SynthDef("midi-sine", { arg freq=440;
		var x;
		x = SinOsc.ar(freq,0,0.1, SinOsc.ar(freq+1, 0, 0.1));
		Out.ar(0,x); 
	}).send(s);

	x = Synth("midi-sine");
	MIDIIn.noteOn = {arg src, chan, num, vel;
			x.set(\freq, num.midicps);
			};

	s.freeAll;

After evaluating this code block by block, I can play the synthesizer using my external MIDI keyboard. Because the input is MIDI note-on messages, there can be no value for event duration. I therefore must evaluate the final line (s.freeAll;) to turn off the last sounding note.

Leaving SC3

SC3 for Linux is still in its early stages, but it already is in a usable condition for creative work. An active development and users community promotes the progress of the language, technically and musically. SC3 is definitely worth learning, and I even risk predicting that it will grow to become one of the best reasons to enter the world of Linux software sound synthesis.

Final Notes

OpenMusic and SuperCollider3 are only two of the many exciting Linux audio projects under development. Alas, these profiles offer little more than a peek at their systems' capabilities, and I hope I've encouraged a few of my readers towards further investigations. With such applications as OM and SC3 already available, I'm even more confident that the future of Linux audio software is indeed looking and sounding good indeed.

Dave Phillips (dlphilp@bright.net is a musician, teacher and writer living in Findlay, Ohio. He has been an active member of the Linux audio community since his first contact with Linux in 1995. He is the author of The Book of Linux Music & Sound, as well as numerous articles in Linux Journal.

Load Disqus comments

Firstwave Cloud