Csound is a digital audio synthesis and processing environment with
facilities for music and sound composition. It is a product of the world of
Unix workstations in the 1980s, with a native user interface consisting of
plain text files created in a text editor or word processor. Csound is one
of the many systems that evolved from Max Mathews's pioneering MusicN
series, which was the first set of programming languages dedicated to creating sound and music on computers. Csound is arguably the most advanced of all the systems derived from the MusicN languages.
More specifically, Csound evolved from Music5. It was written by Barry
Vercoe, but, since its inception, the system has grown from contributions
by many other developers. Csound has always been open-source
software. Originally covered by a license from MIT, Csound is now protected
by the LGPL, which makes it free and open-source software by contemporary
standards. The source package also carries free license terms for certain components not covered by GNU licenses.
The complete Csound system is made of many parts, but the two most
important are the Csound programming language and its compiler. A musical
piece for Csound is usually written as a collection of instrument
definitions and score directives, all of which are compiled to an audio
waveform by the csound binary, either offline or in realtime. The
language can describe a synthesizer, build a guitar effects processor,
perform conditional transformations on a MIDI input stream, and so forth,
while the scoring language describes events and their parameter sets to be
interpreted by the specified instruments. When the instrument definitions
and score instructions are complete, the audio engine can be invoked as a
separate process to render the sound.
When processed by the Csound compiler, the following code creates a WAV file
of a sine wave played for three seconds — an audio compiler's "Hello world!":
; process with no display, minimal messaging, no graphics
; output to WAV file named simple-sine.wav
-d -m0 -g -o simple-sine.wav
sr=48000 ; audio sample rate
ksmps=64 ; samples per k-rate (control rate) period
nchnls=2 ; number of audio output channels
instr 1 ; define a Csound instrument by number
kamp = p4 ; amplitude value in the score event's
; 4th p-field
kfreq = p5 ; frequency value in the score event's
; 5th p-field
ifn = p6 ; function table number in score event's
; 6th p-field
aosc oscil kamp,kfreq,ifn ; an oscillator with amplitude, frequency,
; and f-table values from preceding parameters
kenv linseg 0,p3*.50,1,p3*.50,0 ; a gain envelope to modulate
; the event's output volume
aout = aosc*kenv ; apply the envelope to the oscillator output
outs aout,aout ; send the modulated signal to the
; system audio stereo outs
endin ; end the instrument definition
; a stored function table
; table number, start time, number of sample points,
; GEN function, harmonic fundamental
f1 0 8192 10 1
; an event list with six p-fields
; instrument number, start time, event duration,
; direct amplitude value, frequency in cycles per second (cps),
; function table numnber
i1 0.0 3 5000 440 1
e ; end of score
This example is in Csound's unified file format, which joins the instrument
definition and score events pieces that historically were in separate files. To render it to a soundfile we need to feed the file to the Csound compiler:
If all goes well you'll have a new 3-second recording of a sine wave that swells from silence to a fairly loud volume and back again to silence. If things don't go well you'll get some hopefully informative error messages from Csound to help debug your code.
I'm sure some readers are wondering why anyone would go to such trouble to produce a sine wave, but consider the following implications from our little example :
- I can invoke as many oscillators as I want by simple cut-and-paste text manipulation.
- I can increase the number of sample points in the function table that provides the sine wave.
- The envelope can have as many stages as I wish.
- I can easily specify a more complex multichannel audio output.
- The score event values can be replaced by expressions and macros.
All of that just scratches the surface of Csound's capabilities, many of
which are found in no other sound software or hardware. It is amazingly
powerful software, but accessing its power can be difficult, especially for
new users accustomed to GUI-based music software. The plain-text interface
seems rather forbidding at first, as does the prospect of working at the
command-line. Fortunately, the language has been designed for directness and
simplicity, though its complexity varies with the particular
elements used in your instruments, of course.
Instruments and processors are built from Csound's huge collection of
opcodes, which are the synthesis and processing "black boxes" that provide the various parts — oscillators, envelopes, filters, etc. — required by your instrument designs. Each opcode has its own set of parameters and usage details, so while some may have only a few parameters to address, others may have considerably more. Values for those parameters can be set or calculated within your instrument definitions, or they may be provided by the scoring language.
In the general computing world, the dominance of the GUI might have doomed
Csound and similar systems to the dustbin of music software
history. However, Csound has proven to be flexible enough to evolve and and
remain current, thanks especially to a talented development team ably
managed by John ffitch for more than twenty years. Through those years, many fine contributing programmers have come and gone from the Csound development community, but John's deep involvement as Csound programmer and composer has ensured stability, high-performance, and compatibility. On top of this core reliability, we find many developers dedicated to easing the way into Csound by way of graphic IDEs (integrated development environments), documentation improvements, enhanced connectivity, and other developer and user-level amenities.
Thanks to the efforts of its dedicated developers, Csound has an API
(application programming interface). Thanks to that API, interesting new
applications can be devised with easy access to Csound's considerable
capabilities. This article presents a fly-by scan of the activity in some
of Csound's new directions, including its deployment on mobile devices, its
ever-improving development environments, and its integration with external
music and sound software by way of plugins or standalone programs built with the Csound API.
Work proceeds towards the deployment of Csound on Android and iOS
devices. I haven't entered the mobile world yet — I'm still deciding
on the hardware — but I can point to Steven Yi's VoiceTouch, Art
Hunkins's ChimePad, Roger Kelly's
and Rick Boulanger's CsoundTouch
to indicate the state of the art.
The Csound source tree now includes a
branch for Android development, while the developers' mailing list reveals
considerable interest and activity in this area. The hardware capabilities
of the current devices pose problems with latency, memory usage, and
screen real estate, but those will be resolved eventually. As the devices become more powerful, Csound will be ready to take advantage of their increased capabilities.
The way into instrument design and audio composition with Csound has been
made easier with environments such as Andres Cabrera's CsoundQt (shown at right),
Yi's blue, Stefano Bonetti's WinXound (at left), and Jean Piche's Cecilia. These environments
differ in many ways, but all are dedicated to providing an organized entry
WinXound and CsoundQt look similar to general
purpose IDEs such as Eclipse or Microsoft's VisualStudio, with panels for
code inspection, debugging output, manual pages, GUI elements, and so
Blue (at left) is more focused on the use of Csound's interfaces to Python
and Java, with provisions for instrument design and some powerful tools for
Cecilia takes a more graph-oriented approach to composition by
employing an X/Y coordinate system to create generative and modulation
curves (shown at right) in a unique way for Csound.
The Cabbage patcher
Developer Rory Walsh has been working on an interesting project called Cabbage. Its web site describes the project as "software for creating cross-platform Csound-based audio plugins", a laudable goal that intends to bring Csound's capabilities to any Linux audio host that supports native VST plugins.
Cabbage processes a file created in a special version of Csound's unified
file format and creates a GUI front-end for the instrument or effect (at left). A regular CSD file can be edited with Cabbage's file source editor and tweaked until ready for export as a plugin or standalone application. Currently, the Linux version of Cabbage will create standalone executables and Linux VST plugins, with support for either JACK or plain ALSA audio I/O.
I've had mixed but promising results from my tests of Cabbage. Most
well, and I've been able to export plugins recognized as valid Linux VSTs
by Qtractor and Ardour3. Rory also reports success using
Cabbage-created plugins with the Linux version of the Renoise digital audio
workstation (Renoise is built with the same JUCE framework used by Cabbage).
Documentation consists of a single HTML page in the Docs directory of the source package. The information on that page is useful, but it is not current. For more up-to-date information, you can communicate with Rory and other developers and users on the Cabbage forum and the Csound mailing lists.
The project is young but its Linux version is stable enough for public
testing. Performance needs further tuning, the plugins themselves have a
large memory footprint, and the documentation needs to be updated. Work remains to be done, but Rory is dedicated to Cabbage's success and welcomes participation from other developers and normal users.
Csound composition/performance environments
In Ye Olden Times, music and sound composition in Csound was a daunting task. The system includes a scoring language and a few utilities for massaging existing scores, but composing complete pieces directly in Csound meant laboring over every event and its unique parameters. Composers such as Richard Boulanger and James Dashow created substantial, beautiful works by hand-crafting every sound and effect, and this method is still available to anyone who wishes to work in such a manner. However, Csounders now enjoy a variety of helper applications and utilities, including some remarkable software dedicated to facilitating composition in Csound.
The modern Csound language includes opcodes — signal processing black boxes — that provide useful random number generators and stochastic cannons, but it lacks sophisticated procedures for further processing the generated data. Fortunately, the gurus of Csound development have created programming interfaces for other languages that do provide such procedures, such as C++, Java, and Python.
I've written elsewhere about athenaCL, CsoundAC, and CM/GRACE, all of which include Csound as an output target. These systems require some study — programs in CM/GRACE are written in a Lisp derivative, CsoundAC and athenaCL employ Python — and they are of interest primarily to composers working with algorithmic composition methods. CM/GRACE author Rick Taube observes that they address issues at what he calls the metalevel of music composition, a "representation of music ... concerned with representing the activity, or process, of musical composition as opposed to its artifact, the score." These packages are fascinating and powerful tools, but clearly they are not music manufacturing programs a la GarageBand.
Jean-Pierre Lemoine's AVSynthesis (at right) is
designed as an environment for interaction with OpenGL 3D graphics transformations in realtime, accompanied by audio from Csound also rendered in realtime. However, it is equally useful as a standalone non-realtime system for music and sound composition with Csound. AVSynthesis provides a set of premade instruments and signal processors, along with an analog-style sequencer, a 64-position step sequencer, a GUI for shaping Cmask tendency masks, and a piano-roll interface. Alas, there are no facilities for adding new instruments or effects, but Jean-Pierre's instruments and processing modules are excellent. I've worked intensively with AVSynthesis for a few years, and I'm far from exhausting the possibilities of its included sound-design modules.
Stephane Rollandin's Surmulot is
also dedicated to composition with Csound. The Surmulot home page describes
the software as "a complex environment for music composition",
which is an accurate description. Surmulot is a collection of three systems
— the Csound-x code for using Emacs as a front-end for Csound, the
muO Smalltalk objects created for use in the Squeak environment, and the
GeoMaestro system based on the powerful Keykit program for experimental MIDI
composition. Its author advises that Surmulot is not for everyone, but it
is a rich environment for composers who want to work in an experimental
environment and are not intimidated by emacs.
Incidentally, if you want to compose your Csound works in good old Western standard music notation you'll be pleased to learn that the Rosegarden sequencer can export scores created in that program to scores in the Csound format. Rosegarden's notation capabilities are extensive, and as far as I know it is the only sequencer/notation package that includes Csound as an export target.
Documenting the scene
When I began using Csound in 1989 the system was relatively small. Most of its documentation was in the official manual, a useful and informative tome despite a rather terse presentation and the lack of examples for many opcodes. A few pieces were available for inspection, but the learning process was largely by trial and error.
The current system is considerably larger, with many new opcodes,
utilities, and third-party extensions. Likewise, Csound's documentation has
expanded. The official manual is
the focus of much labor from the community, with updated entries for the
whole system and useful examples for all opcodes. The FLOSS on-line manual is more modest in scope but is especially valuable for beginners. Dozens of Vimeo and YouTube videos offer instruction and demonstrations of Csound in action, and if I'm in the off-line state I can read and study one of the five hardcopy books dedicated to Csound. It is fair to claim that the learning process has become considerably easier — perhaps I should say "much less difficult" — thanks to this profusion of resources.
But wait, there's more. In 1999, Hans Mikelson published the first issue of the Csound Magazine, an on-line collection of articles from and for the Csound community. All levels of participation were encouraged, and the magazine was a first-rate resource for new and experienced users. Alas, in 2002 Hans gave up management of its publication. However, in 2005 Steven Yi and James Hearon began publishing the Csound Journal. Like the Csound Magazine, the Journal accepts and publishes work regarding all aspects of Csound at all levels. Don't take my word for it though, just take a look at the Csound Journal/Csound Magazine article index for a quick survey of the various topics of interest to Csounders.
Google finds thousands of sites associated with a search for "Csound", including the predictable thousands of bogus or irrelevant sites. I suggest that you cut through the confusion and head straight to Dr. Richard Boulanger's cSounds.com. It's the best resource for exploring the world of Csound with news, announcements, links, podcasts, user pages, and more. If you want to know what's going on with Csound you need to check out cSounds.com.
I've mentioned the Csound mailing lists. Separate lists are available for developer and user-level discussions, though anyone is invited to participate on either list. For many years the lists have been the principal channel for Csound-relevant communications, and they remain so today. The level of discussion can be formidable, especially on the developers list, but exchange is typically civil and helpful. If you don't understand something, just ask, and you're likely to get a prompt response from one of the many Csound wizards populating the lists.
The more musical notes
Csound is the system of choice for many diverse composers. Check out the Csound group on SoundCloud,
as it's quite a varied playlist. Csound is normally associated with
academic and experimental computer music, but the collection at SoundCloud
includes both popular and more esoteric styles. The Csound users mailing list frequently receives announcements for new works, and the occasional Csound-based piece shows up in KVR's Music Cafe. If you're composing with Csound, feel free to leave a link to your work in the comments on this article.
Csound is deep and complex software with powerful capabilities for
audio/MIDI composition and processing. The Csound community is committed to
improving every aspect of the system, including its documentation at user
and developer levels. Projects such as Cabbage and CsoundForLive extend Csound into
the larger world of the modern digital audio workstation, exposing its
powers without demanding special knowledge from a normal user. Greater
awareness of Csound help generate more interest in the system, expanding its development and user base, thus ensuring its continued relevance.
to post comments)