Brian Sorahan

Introducing the sc package

22 June 2015 – Austin, TX

I started working on a SuperCollider client package for Google Go in late March of this year. I’m doing this for fun, but also because I love the power of scsynth, loathe programming with sclang, and love programming with Go. In this post I’ll talk about where the project is right now and where I’d like it to go. I’m going to assume a fair amount of knowledge about how SuperCollider works, I recommend reading these two pages:
* Client vs. Server
* Unit Generators and Synths

Why Go?

Go is

  1. Easy to learn
  2. Relatively fast

What is a SynthDef?

Every sound that you create with SuperCollider is defined with a synthdef. Here is a synthdef (expressed in sclang) that generates a 440Hz sine tone:

SynthDef('simple', {
    Out.ar(0, SinOsc.ar(440));
});

To tell scsynth about this synthdef you need to send an OSC message that contains a blob of binary data which describes the structure of the synthdef. This is done by calling a method on the SynthDef object:

SynthDef('simple', {
    Out.ar(0, SinOsc.ar(440));
}).add;

You can then tell scsynth to create a synth node based on the synthdef:

x = Synth.new('simple');

When I first started writing the sc package I wanted synthdefs to look very familiar, which looked like this:

def := NewSynthDef("simple", func(p *Params) {
    return Out.Ar(0, SinOsc.Ar(440));
})