Csound
a less irritating audio programming language
March 6, 2017 — March 7, 2019
Source: Cabbage audio.
Csound
is an audio coding language. It is Supercollider’s uncle by marriage. Actively developed. Eccentric. Permissive licensing. Smallish. Clean API. Thus, it works beautifully with other languages, which is unusual.
1 Learning resources
- Intro and background via Motherboard.
- csound showcase has lots of examples of actual real documented artworks using csound.
- Michael Gogins’s version of the manual allows you to execute example code from the browser.
- the Csound FLOSSmanual is pretty good
There are various books:
- Famous, but somewhat dated, The Csound book
- Csound: A Sound and Music Computing System is the 2016 updated book
2 Interoperation
2.1 c
Check out this minimal invocation of the csound api.
#include "csound.h"
int main(int argc, char **argv)
{
// Create Csound.
void *csound = csoundCreate(0);
// One complete compile/perform cycle.
int result = csoundCompile(csound, argc, argv);
if(!result) {
while(csoundPerformKsmps(csound) == 0){}
csoundCleanup(csound);
}
// Destroy Csound.
csoundDestroy(csound);
return result;
}
You’ll need this API capability, because its interactive capabilities are, AFAICT, minimalist; a decent external sequencer is necessary for live work.
Csound committer Michael Gogins has put it to me that javascript is natural for this niche, and indeed, he has written a lot of code to this end.
Examples of various Foreign Function Interface invocations (lua, python, go) are in the manual. There is a repository of such examples, in fact.
2.2 python
There are a few confusing options and you have to track the release notes to grok the difference.
I recommend you ignore most of them.
2.2.1 ctcsound
Use ctcsound
, which is newer, based on ctypes
, and runs in python 3. It is clean and easy. Note you may need to compile the latest version of csound to use it. It includes a port of icsound
, which makes things easy.
2.2.2 csnd
The older interfaces are placed by the csound installer in an idiosyncratic fashion into the system python 2 packages folder, which is asking for trouble and I don’t recommend that.
csnd6
, is one such older API, based on SWIG. There is a detailed example in the csound journal.
icsound
seems to be a higher-level wrapper of csnd6, removing much boring boilerplate such as explicit thread management.
2.2.3 CsoundAC
CsoundAC
embeds csound in python, with much extra C++ wrapper code.
import CsoundAC
csound.load("c:/projects/csound5/examples/trapped.csd")
csound.exportForPerformance()
csound.perform()
It’s not clear to me yet how good this is for live control.
2.2.4 Inceptpython
Moreover, python is, in turn, embedded in csound. Fractal infinite recursion left as an exercise.
2.3 Incoming
- embeds lua as opcodes
- embeds faust as opcodes in csound.
- embeds fluidsynth for soundfont playback
- Csound-as-VST is a thing, but VST honchos Steinberg hate fun, so it’s a pain in the arse.
- csound has a C-compiled Chrome browser version via PNaCl or webassembly or whatever Google have switched us all to this week.
- or you can link it to other things using its own perfectly good native API; See the examples.
3 Csound products
3.1 VST audio plugins
3.2 IDEs and front ends
There are many front ends.
Includes a VST constructor and IDE, cabbage:
Cabbage is a Csound frontend that provides users with the means to develop audio plugins and standalone software across the three major operating systems. While Cabbage makes use of underlying plugin technologies such as Steinberg’s VST SDK, ASIO, etc, Csound is used to process all incoming and outgoing audio. Cabbage also provides a growing collection of GUI widgets ranging from simple sliders to automatable XY-pads. All GUI widgets in a Cabbage plugin can be controlled via host automation in a plugin host, thereby providing a quick and effective means of automating Csound instrument parameters in both commercial and non-commercial DAWs.
blue is a DAW for Csound:
A cross-platform composition-oriented front end written by Steven Yi in Java. The user interface provides a timeline structured somewhat like a digital multitrack, but differs in that timelines can be embedded within timelines (polyObjects). This allows for a compositional organization in time that many users will find intuitive, informative, and flexible. Each instrument and score section in a blue project has its own editing window, which makes organizing large projects easier. Blue can be downloaded at Blue Home Page.
runloopsound is the iOS Csound and reputedly includes an editor/IDE? I should check. I thought that violated the App Store guidelines. Maybe I am out of date.
csoundqt is the default IDE:
CsoundQt is a versatile, cross-platform GUI (graphical user interface) which is bundled with the standard Csound distribution. Created and maintained by Andres Cabrera, QuteCsound provides a multi-tabbed editor, graphic widgets for real-time sound control, and an opcode help system that links to this manual.
4 Linkdump
Things I am currently reading:
Basic: Cabbage’s FM synth example
The Csound FLOSS MANUAL on