DEV Community

Bradley Black
Bradley Black

Posted on

Supercollider: Putting a Synth on a Server

supercollider

Just as it is a powerful tool for communication and collaboration in all mediums, the web can be a framework for creating music. This is largely due to server architecture. Musicians have long relied on a single source of truth when composing and collaborating. Often this is simply the physical space they share, but servers and the web allow players to bridge distances and work collectively in a similar fashion.

Supercollider is a language and platform for music creation that builds on a client-server relationship. For Supercollider, any user, or input source, takes on the roll of the client. The server is the synth engine itself. This structure has several key benefits:

  • Clients can take on any number of forms (humans, algorithms, other)
  • Clients can be of any number
  • Multiple clients can simultaneously engage with a single server

osc

Supercollider uses OSC to transmit data between client and server. As a result, any client capable of producing OSC messages can join in. OSC is somewhat of a successor to MIDI. The benefit of OSC is that its 32-bit format offers much richer, detailed, performance data over Midi, which is only 8-bit. In modern music practice, one is often transpiled to the other. While MIDI still holds a place in the field, and physical MIDi ports continue to be implemented in music equipment, OSC has proven to be an incredibly versatile language that musicians without a great deal of programming knowledge can use.

sclang

One large aspect of the Supercollider experience is the coding environment. The client runs on a native language called sclang. C and C++ programmers, and even Javascript programmers like myself, will find the code simple to understand and implement. It is object-oriented in nature, and uses a library of built-in classes for the majority of its functionality.

(
play(
    {
        var f;
        f = MouseY.kr(4000, 200, 'exponential', 0.8);
        SinOsc.ar(
            freq: f+ (f*SinOsc.ar(7,0,0.02)),
            mul: MouseX.kr(0, 0.9)
        )
    }
)
)
Enter fullscreen mode Exit fullscreen mode

Here you can see the MouseY, SinOsc, and MouseX classes being invoked. They all have access to ar and kr methods, which are audio rate and control rate, respectively. The variable f is invoked to store whatever Y value is currently held by a mouse or trackpad. It is then combined with an LFO for musicality, combined with the X value of the mouse for amplitude, and these signals are combined to generate a specific pitch by a sine wave oscillator.

scsynth

Interaction with a Supercollider server is done with the command line using native scsynth language. These commands are used to dictate the behavior of audio busses, nodes, and synths:

scscynth -u 57117 >synth_log & scsynth -N score.osc _ out.aiff 48000 AIFF int24
Enter fullscreen mode Exit fullscreen mode

This chain instructs a synth what port to use (57117), where to log output info, what file to read for osc instructions, and what sample rate and bitrate to use.

quarks

Javascript uses the npm package manager to empower coders to build and download tools and libraries for their projects. Similarly, Supercollider users quarks. Quarks are hosted on github, and can be implemented with the Quarks class:

Quarks.gui //launches an interface for the entire quarks library
Quarks.install(/*quark name here*/)
    Quarks.uninstall(/*quark you no longer need*/)
Enter fullscreen mode Exit fullscreen mode

summary

The open-source and server-based approach to music making is what appeals most to be about Supercollider. Although it’s more exclusive to programmers than languages like Max/MSP or Pure Data, the ability to build instruments, controllers, and networks from the ground up opens up an endless number of paths for creative pursuits.

Top comments (0)