Project: p5_sc: SuperCollider for Processing

Processing.org classes for interfacing with the SuperCollider synthesis engine.

version: 0.2.4
title: ProcessCollider
platform: Processing
license: GPLv2
created: 2007/10
modified: 2009/04

Download (zip, 24KB)

This library is an implementation of many of the core elements of SuperCollider's client-side language. It provides analogous objects to encapsulate common functions (creating and manipulating Synth, Buffer and Bus objects, for example), and simplifies the task of interfacing with SuperCollider's powerful synthesis engine.

Examples

Development of this library was driven by AtomSwarm, a generative, interactive audio/video work which makes heavy use of both SuperCollider and Processing. Watch a video here (Vimeo).

Installation

  • Install the oscP5 library
  • Download and unzip p5_sc, and copy the 'supercollider' directory into the libraries folder of your Processing sketchbook (details)

Now open a new sketch, and the Import Library menu should include an entry for 'supercollider'. To get started, run the sample code below, or browse the class documentation.

Helper functions

A series of helper functions are also available which provide frequently used client-side operations (mapping between parameters, clipping values, MIDI/frequency conversion, non-uniform random number generation).

Usage (SuperCollider)

SynthDef(\sine, { |amp = 0.5, freq = 440|
	var data = SinOsc.ar(freq, 0, amp);
	Out.ar(0, data ! 2);
}).store;

Usage (Processing)

import supercollider.*;

Synth synth;

void setup ()
{
    size(800, 200);

    // uses default sc server at 127.0.0.1:57110    
    // does NOT create synth!
    synth = new Synth("sine");
    
    // set initial arguments
    synth.set("amp", 0.5);
    synth.set("freq", 80);
    
    // create synth
    synth.create();
}

void draw ()
{
    background(0);
    stroke(255);
    line(mouseX, 0, mouseX, height);
}

void mouseMoved ()
{
    synth.set("freq", 40 + (mouseX * 3)); 
}

void stop ()
{
    synth.free();
}

Changes

  • v0.1 2 November 2007
    Initial release.
  • v0.2 4 November 2007
    Support added for asynchronous commands and object/target handlers.
  • v0.2.1 5 November 2007
    New methods added to Buffer: set(), setn(), get(), getn().
  • v0.2.2 6 November 2007
    New methods added to Buffer: zero(), fill().
    New example code.
    Server.init() added to prevent run-time delay when class is first loaded
    (thanks to Manfred Brockhaus)
  • v0.2.3 10 November 2007
    Synth.set() expanded to support multiple parameters in a single bundle.
    Support added for server.latency.
  • sc_utils.java 13 February 2008
    sc_utils helper functions added.
Creative Commons License

Valid XHTML 1.0 Strict Valid CSS 2