Skip to content

khilnani/supercollider.web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents generated with DocToc

supercollider.web Build Status

Node.js based web application to create audio files for SuperCollider, with SoundCloud integration.

Thanks to the following people for feedback, suggestions, technical insight and sanity checks. In alphabetical order -

Instructions

Requirements

  • Node.js
  • SuperCollider
  • Node.js Modules
    • dysf.utils
    • soundclouder.js
    • express
      • If you see errors after installing express globally, use export NODE_PATH=/usr/local/lib/node_modules
    • forever

Installation

  • Ensure /tmp/ is available as Read/Write
  • Update src/config.js
  • Once the code has been pulled, change your working directory to 'src'
  • run: USAGE node supercollider.js [CONFIG FILE] [PORT]
    • Example node supercollider.js config.js 8080
  • If you want to run the process in the background, you can
    • Install the forever module - npm install forever
    • Run forever start supercollider.js [CONFIG FILE] [PORT].
      • Example forever start supercollider.js config.js 8080

Features

NOTE - The code is very early in development and is not safe to run on any public web server as it could expose your server to security/hacks.

Current Development State

  • Web based entry, validation and execution of SuperCollider code
  • Streaming of generated audio
  • Generation of Audio based on command line execution of 'sclang'
  • Supports Basic Auth security
  • State saving in the Browser using LocalStorage
  • SCCode.org Docs integration

Planned Features

  • Post code to Twitter.
  • SoundCloud integration to upload/store resulting audio. Post resulting track url to Twitter.
  • Realtime interaction with the SuperCollider application via web sockets to facilitate live coding.

Usage

  • The application wraps SuperCollider code submitted into a Task.
  • If the SuperCollider code uses Tasks or Routines, it would need to compatible with being run within a Task.
  • Else, you will get an error message that is not very informative, specifically ERROR: syntax error, unexpected '(', expecting '}'
  • Examples
    • The following code will give the error: ERROR: syntax error, unexpected '(', expecting '}'
     (
     	{
     		SynthDef(\test, {
     			var st = SinOsc.ar();
     			Out.ar(0,st!2);
     		}).add;
     		s.sync;
     		Synth(\test);
     	}.fork
     )
    
    • Thats because its missing a ; at the end. The code below works:
     (
     	{
     		SynthDef(\test, {
     			var st = SinOsc.ar();
     			Out.ar(0,st!2);
     		}).add;
     		s.sync;
     		Synth(\test);
     	}.fork
     );
    
    
  • As a reference, the resulting code the application sends to SCLang (SuperCollider) is more or less
s.waitForBoot({
	Task.new ({

		s.sync; 
		s.record(~path);

		//---- START - inserted by server ----

		SynthDef(\test, {
			var st = SinOsc.ar();
			Out.ar(0,st!2);
		}).add;
		s.sync;
		Synth(\test);

		//---- END - inserted by server ----

		(~length).wait;
		s.stopRecording;
		2.wait;
		s.quit;
		0.exit;

	}).play;
});

Screenshots

Technical Notes

Overview

  • The application allows a user to submit SuperCollider code via a form.
  • The submitted code is then inserted into a template that facilitates command line execution of SuperCollider (sclang) to generate audio.
  • Audio is generated in 16bit 44.1kHz AIFF format.
  • Via a post-redirect-get pattern, audio is streamed to the browser.

Codebase

  • src
    • supercollider.web.js: The main js file of the application
    • config
      • config.js: Template config file that should contain SoundCloud client keys, Log levels etc.
      • config.illegals.js: Illegal keywords
    • html: Publish html/js/css files accessible at http://server:port/
    • modules: Custom modules for the application that handle request routing, utils, SoundCloud API etc.
    • templates: Template SCD files used to generate SuperCollider code send to sclang
  • tests: Vow and PhantomJS tests
  • docs: misc stuff
    • examples: Sample SuperCollider code that is created, along with the resulting audio.
    • leftovers: Experiments, abandoned ideas etc. that may be of interest.
    • misc: Reference SuperCollider code that is used for standalone testing of SC integration.