Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


NPM downloads MIT License

JavaScript library for the SuperCollider music language and synthesis server

supercollider.js is a full-featured, batteries included client library for the SuperCollider audio synthesis server and the SuperCollider language interpreter.

It can be used for algorithmic composition, live coding, playing sounds with MIDI, audio processing, sound file rendering, data sonification and more.

It is written in TypeScript and compiled for release as ES2018 (Node >= 10) JavaScript and can be used in Node applications for either JavaScript or TypeScript.


SuperCollider is a platform for audio synthesis and algorithmic composition, used by musicians, artists, and researchers working with sound. It is free and open source software available for Windows, Mac OS X, and Linux.

It consists of two parts:

  • scsynth: A real-time audio synthesis Server that communicates over TCP/IP using the OSC (Open Sound Control) protocol.

    • High quality accurate and efficient audio engine
    • Fully adjustable sample rate (192k+) and block size
    • 32-bit float signal chain
    • Sampling buffers use 64-bit float
    • Fast and fluid control rate modulation
    • 250 Unit generators in SuperCollider
    • Hundreds more community contributed UGens
    • Simple ANSI C plugin API
    • Supports any number of input and output channels, ideal for large multichannel setups
    • macOS, linux, windows
  • sclang: An interpreter and runtime for the SuperCollider programming language. It is similar to Smalltalk or Ruby with syntax similar to C or Javascript.


  1. Install SuperCollider:

  2. Install supercolliderjs:

npm install supercolliderjs


There are several interfaces, ranging from low-level (tedious, error-prone) control to higher level constructs.

// @supercollider/server-plus interface
const sc = require("supercolliderjs");

sc.server.boot().then(async server => {
  // Compile a SynthDef from inline SuperCollider language code and send it to the server
  const def = await server.synthDef(
    `{ |out=0, fundfreq=440, formantfreq=440, bwfreq=100, timeScale=1, pan=0|
        var saw, envd, panned;

        saw =, formantfreq, bwfreq);

        envd = saw *, 0.2), timeScale: timeScale, doneAction: 2);
        panned = *, 0.2, 0.7), pan);, panned);

  // Create group at the root
  const group =;

  const freqSpec = {
    minval: 100,
    maxval: 8000,
    warp: "exp",

  // Map 0..1 to an exponential frequency range from 100..8000
  const randFreq = () =>, freqSpec);

  // function to spawn one synth event
  const spawn = dur => {
        fundfreq: randFreq(),
        formantfreq: randFreq(),
        bwfreq: randFreq(),
        pan:, 1, -1, 1, Math.random()),
        timeScale: dur,
        // spawn each synth into the same group

    const next = Math.random() * 0.25;

    // Schedule this function again:
    setTimeout(() => spawn(next), next * 1000);

  // spawn the first event
}, console.error);


SynthDef and Synth

A SuperCollider SynthDef defines a graph of Unit generators. It wires together inputs and outputs, oscillators and filters. Once it is compiled and sent to the server, then you can create Synths that play that sound.

Currently supercollider.js uses sclang to compile synth defs. Full support for writing and compiling SynthDefs from JavaScript is planned.

const sc = require("supercolliderjs");

sc.server.boot().then(async server => {
  // Compile and send to server from inline SuperCollider code
  const pulse = await server.synthDef(
    `{ arg out = 0, freq=200;,,,0.99,8), 0.2))

  await server.synth(pulse, { freq: 300 });

  // Load and compile from a SuperCollider language file
  const klang = await server.loadSynthDef("klang", "./klang.scd");

  await server.synth(klang);

  // Compile or load many at once
  const defs = await server.synthDefs({
    clipNoise: {
      source: `{ arg out = 0;
        var clip =, 10000, 1), 0.125);, clip);
    lpf: {
      source: `{ arg in = 0, out = 0;
        var input =;
        var lpf =,, 2e4, 1), 0.2, 0.2);, lpf);

  // Some people pre-compile synth defs to a binary format.
  // Load a pre-compiled synth def from a binary file.
  const defLoadMsg = sc.server.msg.defLoad("./formant.scsyndef");
  // This object has two properties:
  // .call - the OSCMessage to send
  // .response - the expected OSCMessage that the server will reply with
  // Call and wait for the response:
  await server.callAndResponse(defLoadMsg);

  // Load an entire directory of pre-compiled synth defs
  // await server.callAndResponse(sc.server.msg.defLoadDir("./synthdefs/"));


const sc = require("supercolliderjs");

sc.server.boot().then(server => {
  const def = server.synthDef(
      SynthDef("bubbles", { arg out=0, wobble=0.4, innerWobble=8, releaseTime=4;
        var f, zout;
        f =, 0, 24,[innerWobble, innerWobble / 1.106], 0, 3, 80)).midicps;
        zout =, 0, 0.04), 0.2, 0.2, 4);  // echoing sine wave
        zout = zout * releaseTime), doneAction: 2);, zout);

  setInterval(() => {
    server.synth(def, {
      wobble: Math.random() * 10,
      innerWobble: Math.random() * 16,
      releaseTime: Math.random() * 4 + 2,
  }, 4000);


Server Plus Server


  • Spawns the language interpreter, sclang
  • Call SuperCollider code from JavaScript
const sc = require("supercolliderjs");

sc.lang.boot().then(async function(lang) {
  // This function is declared as `async`
  // so for any function calls that return a Promise we can `await` the result.

  // This is an `async` function, so we can `await` the results of Promises.
  const pyr8 = await lang.interpret("(1..8).pyramid");

  const threePromises = [16, 24, 32].map(n => {
    return lang.interpret(`(1..${n}).pyramid`);

  // `interpret` many at the same time and wait until all are fulfilled.
  // Note that `lang` is single threaded,
  // so the requests will still be processed by the interpreter one at a time.
  const pyrs = await Promise.all(threePromises);

  // Get a list of all UGen subclasses
  const allUgens = await lang.interpret("UGen.allSubclasses");

  // Post each one to STDOUT
  allUgens.forEach(ugenClass => console.log(ugenClass));

  await lang.quit();





Works on Node 10+

Source code is written in TypeScript and is usable in JavaScript es2018 or TypeScript projects.



MIT license