Csound SoftSynth Explored - EMusician

Csound SoftSynth Explored

Csound is the latest in a long line of synthesis languages that have roots that go back to Bell Labs in the late 1950s. The language provides an almost
Author:
Publish date:

Csound is the latest in a long line of synthesis languages that have roots that go back to Bell Labs in the late 1950s. The language provides an almost unlimited number of resources for sound generation and processing. Until recently, however, using Csound involved typing often-cryptic commands into your word processor and then letting the Csound compiler turn those commands into audio signals (see “Master Class: Building Blocks” in the October 2000 issue of EM). Though many users will attest to the popularity of that approach, it certainly can't be termed a user-friendly way to make music.

During the past few months, a number of new tools have appeared that make using Csound almost as easy as using any modern, graphically based soft synth. What's more, like Csound itself, all of these tools are free. Among the most important new resources in the Csound world are CsoundMax, a graphical user interface for Csound on the Mac, written by Joo Won Park, and Gabriel Maldonado's CsoundAV, a similarly powerful tool for real-time use on the PC. In addition, Matt Ingalls recently released a Max/MSP Object called csound~. Many readers will find Michael Gogins's CsoundVST even more familiar; it allows you to use Csound as a plug-in under most Windows-based VST hosts. All of the software mentioned in this article is available from the Csound home page,www.csounds.com.

In addition to discussing these and other new developments, I'll offer a number of pointers on how to get them up and running. I'll also tell you about a special front end for Csound written by Glenn Ianaro that turns Csound into a powerful phrase sampler.

Keep in mind that Csound is co-developed by a large group of avid users who do their best to supply documentation and support for their efforts. None of them receive any commercial reward for their work, which means that you won't find 24/7 tech support if you run into a problem. However, in the many years that I've been a Csound user, the Csound community has proven an extremely helpful and dedicated bunch of people. You can count on them to give you quick and accurate advice.

FIRST STEPS

During much of its 50-year history, sound programming has been a thankless task that involved coding the design for a sound using the vocabulary and syntax that was required by a specific programming language, and then rendering the code as a sound file for playback. The entire process occurred out of real time; in fact, on a slow computer, producing the sound could take many times the length of the sound file. As part of the exponential leap Csound has taken in recent years, you can now create sounds in real time and even use a MIDI controller to input values that a particular Csound instrument requires. (See the sidebar “Scores and Orcs” for a quick review of basic Csound terminology.)

Building on the significant efforts of others, Matt Ingalls's work has made Csound on the Mac far more efficient and powerful. Ingalls created a Mac System Library called CsoundLib that is optimized to take advantage of the Mac operating system's resources. He also wrote an entirely new version of Csound called MacCsound that incorporates CsoundLib and allows users to control their instruments in real time. It lets Csound interact in new and unique ways with other applications running on the same computer. For example, you can send audio or MIDI into MacCsound or route its output to another application for additional processing.

MacCsound incorporates a text editor directly into its interface and should be fully compliant with OS X by the time you read this. It includes an array of features, such as a screen of sliders that can be assigned to any parameters in your instrument, for quickly building and performing on Csound instruments. MacCsound also makes it easy to toggle between real-time audio output and recording to disk (WAV, SDII, AIFF, and raw formats are supported). Though technically still in alpha after many months (noncommercial programs often have lengthy development times), it performed well on my G3/266 MHz, even in real time.

MAD MAX

Moving another step further, David Zicarelli, founder of Cycling '74 and a pioneer in desktop music making, encouraged Ingalls to turn CsoundLib into an external Max/MSP Object called csound~. Cycling '74's Max/MSP programming software is an open-ended environment in which creative users can design nearly any type of sound-generating or sound-processing tool. Incorporating csound~ into that environment combines an extremely capable and potent synthesis engine with a production platform that's already powerful. Using Max/MSP as a shell for your Csound creations means you can, for example, run multiple instances of Csound simultaneously, generate scores algorithmically, update wavetables in real time, or trigger external video gear in sync with a Csound loop. (For more information on Max/MSP and its Objects, see “Master Class: The Max Factor” in the June 2002 issue; also see the review of Max 4.0/MSP 2.0 in the April 2002 issue.) You can also route your Csound audio output to a VST host using Propellerhead's ReWire technology or use Csound as an effects plug-in for Steinberg Cubase audio tracks.

Dr. Richard Boulanger of the Berklee College of Music has spearheaded many of the new developments in Csound and has devoted a good portion of his life to making Csound accessible to the world. He recently premiered a new Csound composition using csound~ wherein he generated multiple channels of high-quality audio in real time merely with an Apple iBook G3/600 MHz. That may not seem earth-shattering to musicians who are accustomed to getting multichannel audio from their commercial applications. But to the Csound world, it is a major landmark and an important indication of things to come.

Csound supports as many as 64 discrete channels of audio, although it would take a CPU considerably more powerful than any current desktop model to take full advantage of that capability. Creating multichannel mixes is just one of the many new applications that are now available under the Max/MSP environment. Other developments are sure to appear on the Csound home page in the near future, so check the page periodically. For example, Sean Meagher's CsoundFX, an elegant multi-effects processor that runs alone and under Max/MSP, showed up the night before I finished this article.

MAXIMUM CSOUND

Still another offshoot of CsoundLib comes from Joo Won Park, a recent graduate of the Berklee College and former student of Boulanger's. Park has written CsoundMax, which can be used as a standalone, real-time soft synth and audio processor or as a Max/MSP Object.

The standalone version, which does not require Max/MSP, has a brightly colored interface that is neatly organized into four main sections (see Fig. 1). At the top of the screen is the Csound Performance section, where you pick the Csound files you want to work with, start and stop the real-time rendering process, set the path to the folder containing your files, and more. You can also access the text files that you're compiling if you need to edit them, and you can view a signal-flow chart (or any other graphic image) that is associated with your files. Other options include loading a preexisting sample and changing its speed, enabling and disabling looping, and adjusting the amplitude of a sample.

The second section, marked P-Field Control, contains the real-time controls you'll use to tweak your sounds. Assuming you've designed your Csound instrument with a number of controllable parameters — such as filter cutoff, grain size, or reverb amount — you'll find a knob there to govern each value. There are also controls for global volume and overall sound duration, as well as a switch to toggle automation on and off. Using the automation feature, you can capture all of the movements you make to the various controls and then play back your entire performance hands-free. There's even a nifty K Control Pad to which you can map any two parameters so that you can control them with your mouse.

Keyboard Control is at the center of the interface; there you'll find a virtual keyboard to trigger notes on your instruments. You can transpose the note range up or down, map your computer's keyboard to trigger sounds, and split the keyboard so it triggers two instruments at once.

CsoundMax's final section, Audio Performance, offers a large number of features that truly demonstrate the power of the software. For starters, you can see a real-time display of your audio using a sonogram or oscilloscope display. That has great potential for teaching situations — students could watch the sidebands evolve in a demonstration of FM synthesis, for example — and it can also be useful during mastering for locating the exact spot where a sound clips.

Beyond just looking at your sound, you can also designate a preexisting file to play back while the program is generating sound in real time, or you can turn on the Recorder to record your performance to disk. To modify the overall level of the audio, you can draw a global amplitude envelope directly on the screen that will kick in when you trigger a new note.

CsoundMax is able to play standard Csound scores and orchestras, but to get the most from the program, you'll have to modify your existing files. Fortunately, Park has written a tutorial on doing just that, and even novice users will have no trouble performing the necessary steps. You can get the tutorial at the Csound home page, along with the latest version of the software.

You won't find a more intuitive or user-friendly tool anywhere for experimenting with Csound, and I highly recommend that all Mac users download CsoundMax and see what it can do for them. In the distribution bundle are examples covering several synthesis methods, including emulations of classic analog synths, as well as various types of sample processing. If you've been reluctant to jump into the Csound world, CsoundMax will make the step an easy one.

WINDOWS WONDERS

A number of developments for Csound on the PC have recently been announced that are just as exciting as developments for the Mac. Of the many people involved with updating and enhancing Csound on the PC, no one deserves more credit than John Fitch, a British mathematician who has worked feverishly during the past few years to add new features, clean up and optimize code, and generally manage and incorporate the many contributions of users from around the world. The “canonical” (official) version of Csound is always available from Fitch's Web site, ftp.cs.bath.ac.uk/pub/dream/newest, and Fitch himself can often be found lurking on the Csound newsgroup, answering questions, explaining new features, and generally making himself available to advise and direct the work of others.

Gabriel Maldonado of Italy has also made significant contributions to the Csound world. His DirectCsound, the first version of Csound to run in real time on the PC, added a significant number of new opcodes to the Csound language and represents a major expansion of its capabilities (see Fig. 2). DirectCsound offers numerous new core sound-generating and processing features, and its support for hardware-accelerated DirectSound3D application programming interfaces and Creative Labs' Environmental Audio Extensions (EAX) 2.0 gives it 4-channel surround capabilities. With the recently announced support for ASIO, which should be available by the time you read this, additional surround capabilities will be in place. Beyond the included documentation, Maldonado's work is detailed in an excellent text by Riccardo Bianchini and Alessandro Cipriani called Virtual Sound (Contempo sas, 2000). It's the best resource you will find for getting started with Csound.

Maldonado surprised the Csound community recently by adding graphic elements such as sliders and faders to DirectCsound, and new instruments incorporating those features showed up almost immediately. Among my favorite instruments that use these new elements is Josep Comajuncosas's JCM303, a Csound clone of the famous Roland TR-303 beatbox. You'll also enjoy Luca Pavan's Classic Sound Synthesis Techniques instrument, which allows you to choose any of eight windows, each of which offers real-time control over a sound-generating method (see Fig. 3).

Pavan's instrument includes additive synthesis, FM, and ring modulation, as well as a physically modeled string method called Pluck. There's another panel for speech synthesis that uses Csound's FOF function, a complex-waveform generator called Buzz, a granular synthesizer, and a set of four filters, each of which uses a white-noise generator as its preset sound source. To run the code smoothly on my Pentium III/933 MHz, I had to scale the sampling rate down to 22,050 MHz, but at that rate, I could run multiple instruments simultaneously and easily change several parameters at once. If you're up to the challenge, you can jump into Pavan's source file — a single unified file in the CSD format — and change any aspects of the interface or the sound-generating processes that you want.

ANIMATED PERFORMANCE

Maldonado's latest effort, CsoundAV, incorporates even more new elements: for example, the ability to scan a bit-mapped graphic image and extract data that can be used by a Csound instrument. CsoundAV can also be used to render animations in real time, in sync with Csound audio. Chris O'Donnell, a student at Brown University in Rhode Island, built an interface using CsoundAV in which the same onscreen controls are used to manipulate a synthesized sound and a spinning 3-D torus image in real time. With CsoundAV, Maldonado includes working examples such as Hallocube, which generates a spinning 3-D cube upon receiving a MIDI Note On message. Though it can't yet record the generated visuals to disk, CsoundAV is a powerful resource for those interested in animation.

Keep in mind that if you want your Csound instruments to respond to real-time MIDI instructions, you'll need to use a few special commands that convert MIDI data into a form that Csound can use. For example, MIDI note numbers are converted to frequency values using the cpsmidi command, and Velocity is converted into amplitude with the ampmidi command. There are similar commands for converting or scaling controller data and special envelope generators that will add a short release to a note regardless of that note's duration. You'll find example files that use MIDI at the Csound home page, in the section maintained by Russell Pinkston. Pinkston is a professor at the University of Texas at Austin and is among the greatest Csound masters.

LOOP-THE-LOOP

It would be hard to find an application of Maldonado's DirectCsound more unusual than Glenn Ianaro's Windows-based C-Looper instrument. C-Looper is a four-way phrase looper that uses nothing more than readily available Csound resources. In fact, the two files needed to render the system total a mere 32 KB. (You'll need a copy of DirectCsound on your computer, of course.)

Each of the four phrase loopers has adjustable volume and panning, but even more important, there are controls to add ring modulation, apply a lowpass filter, or change the speed of the loop in real time (see Fig. 4). At the moment, all four loopers access the same audio file on your drive or the same incoming audio signal. Ianaro has plans to expand this capability to support as many as four discrete audio streams and has also announced other plans to turn C-Looper into a more robust composition and “improvisation environment.”

Although it hasn't overcome the latency inherent in any audio environment, Ianaro's system seems less prone to the inevitable lag time than you'd expect from a traditional soft synth. He recommends using large buffers when running the system (a setting that you specify in whatever interface or “launcher” you are running Csound under) and has indicated that a Pentium III/500 MHz is the minimum processor needed to run it at 44.1 kHz. An article Ianaro wrote about C-Looper is available in the summer 2001 issue of Csound Magazine (www.csounds.com/ezine), a quarterly online publication put together by Hans Mikelson that offers articles for beginners and advanced users. (The article refers to the software as Schnackertronics, its former name.) In the article, you'll get a thorough explanation of the instrument's genesis and capabilities.

Even without any knowledge of the program's inner workings, however, you should be able to load the SCO and ORC files and start jamming with the system. If you want to change the default WAV file that the loopers use, look for the line
strset 10, “mysound.wav”
near the top of the orchestra file and replace the file name in quotes with one of your choosing.

VERY SPECIAL TOOLS

If working with a new interface is more than you want to manage, you'll definitely feel right at home with Michael Gogins's CsoundVST plug-in. CsoundVST allows you to use your Csound instruments as VST Instruments, which means they'll show up alongside all your favorite soft synths inside the VST interface. Equally important, you can use Csound's massive processing engine as a plug-in effect for processing audio tracks.

I tested CsoundVST on a Windows 98 system and had some trouble getting it to run; when I switched to a Windows 2000 machine, however, the problems disappeared. My test application was Cubase VST/32 5.01, and I got the plug-in to work as a VST Instrument and as an effects processor. Some users running Steinberg Nuendo have reported problems using CsoundVST as a VST effect but have had good luck with the Instrument option. (Under Steinberg WaveLab, it will only run as a plug-in effect.)

CsoundVST does not have a slick graphic interface. Instead, when you click on the Edit button after loading it into any plug-in slot, you'll see a text-based screen that includes all the options the plug-in provides (see Fig. 5). CsoundVST supports standard Csound ORC and SCO files in addition to files in CSD format. Because of the resources required to run Csound and your VST host, you should expect a bit more latency than you would normally get from a highly optimized software synthesizer.

To configure the plug-in, you need to tweak a few lines in your autoexec.bat file. One way to do that is to jump to a DOS window and then type “edit c:\autoexec.bat” (don't type the quotes), enter the lines below, and then reboot. The process is well documented in Gogins's release notes.

SET PATH=%PATH%;c:\Silence\bin;
SET SILENCE_HOME = C:\Silence
SET CSOUND_HOME =C:\SILENCE\bin
SET STK_HOME=c:\SILENCE

You'll also need to set a few configuration parameters so that Csound passes audio back to the host rather than writing its output to disk. That's accomplished by adding the appropriate “flags” (-h, -n, and so on) after the CsoundVST command that appears at the top of your Csound file. You should also use the — d command to keep Csound from generating a running display of its activities as it compiles your sound. A typical command (configuration) line will look like this:

CsoundVST -h -n -d temp.orc temp.sco

Gogins has also implemented new opcodes in CsoundVST such as Jezar's freeverb, an excellent reverb based on the Schroeder/Moorer model (available as a free DirectX plug-in at www.dreampoint.co.uk); and Perry Cook's Synthesis Tool Kit, a set of high-quality physical-modeling opcodes. In addition to his VST plug-in, Gogins has created an elaborate environment for working with Csound called Silence, which is a Java application optimized for algorithmic composition.

It would be impossible to mention all the exciting developments appearing across the Csound landscape, and I can hardly imagine what Csound's original developer, Professor Barry Vercoe of MIT, must think of the enormous universe he has engendered. There are now thousands of example files online to get you started, dozens of tutorials and two major books on Csound in print (see, in particular, Boulanger's Csound Book [MIT Press, 2000]), and a multitude of creative and unique contributions that are readily available for you to test out. Moreover, it seems that nearly every day, a new user appears on the Csound newsgroup, introducing him- or herself and asking a few questions or proposing some enhancements to the language. If you haven't kept up with the latest developments in the Csound world, it's high time you had a look!

EMassociate editorDennis Millernever thought he'd end up writing music by typing text into his word processor. But Richard Boulanger enlightened him to the world of Csound, and the rest is history.

SCORES AND ORCS

Like any modern programming language, Csound has its own naming conventions for the many types of functions and files it incorporates. Here is a short primer that should help you understand some of the most basic terms in the Csound vocabulary.

Instrument: Many conventions that Csound uses are similar to those found in traditional music. For example, the sounds you design using Csound's functions are called instruments. You can have as many instruments as you want in an orchestra file (see below).

Orchestra file (ORC): Historically, Csound has required two source files. One has the extension ORC and the other uses SCO. In the ORC file, you specify what your Csound instruments will do and you tell Csound what sampling rate it should use for its audio output.

P-field (parameter field): A p-field is a column in a score where the parameters of your instrument are defined. The first three p-fields are reserved for instrument number, start time, and duration (in seconds). After that you can use p-fields for any aspect of your instrument, though it is common to use the fourth p-field (p4) for amplitude and the fifth (p5) for frequency.

Opcode: Csound has many built-in subroutines that perform a wide range of tasks. These include things such as oscillators (oscil), filters (reson, atone, and so forth), and table-generating functions (Gen01, Gen10, and so on). Functions of this type are known as opcodes. Csound now includes many user-contributed opcodes.

Score file (SCO): The SCO file is a text file where you specify how and when a Csound instrument will play. If you have built your instrument with some flexibility — for example, including a filter but not specifying the filter's cutoff frequency — then you can put that information in the score and change the value on every note.

Csound Structured Data (CSD): This unified file format, developed by Michael Gogins, is a fairly recent addition to the Csound world and contains the orchestra and score data. It also includes tags that provide information about the way you want Csound to compile your files.