Code Monkey home page Code Monkey logo

supercolliderjs's Introduction

supercollider.js

Build Status NPM downloads MIT License Dependency Status devDependency Status

The JavaScript client library for SuperCollider.

SuperCollider is an environment and programming language for real time audio synthesis and algorithmic composition. It provides an interpreted object-oriented language which functions as a network client to a state of the art, realtime sound synthesis server.

This library provides functionality for working with:

  • scsynth (the synthesis server)
  • sclang (supercollider language interpreter)

Documentation

API Guide

Features

  • Send and receive OSC messages

  • Comprehensive support for calling all commands the server understands

  • Call async commands on the server receive results as Promises

  • Synth/Group/Bus/Buffer allocators with clean immutable state implementation

  • Server state and synth/group tracking

  • Just-in-time OSC scheduler

  • Codebase written with Flow (type checking)

  • High unit test coverage

  • Dryadic: declarative DSL for managing component trees.

Examples

See also the Examples Repository.

language

Interpret SuperCollider language code.

var sc = require('supercolliderjs');

sc.lang.boot().then(function(sclang) {

  sclang.interpret('(1..8).pyramid')
    .then(function(result) {
      // result is a native javascript array
      console.log('= ' + result);
    }, function(error) {
      // syntax or runtime errors
      // are returned as javascript objects
      console.error(error);
    });

}, function(error) {
  console.error(error)
  // sclang failed to startup:
  // - executable may be missing
  // - class library may have failed with compile errors
});

server

let sc = require('supercolliderjs');

sc.server.boot().then((server) => {

  // Compile synthDef from a file
  // Will recompile and send to server if the file changes.
  let def = server.loadSynthDef('formant', './formant.scd');

  // Create group at the root
  let group = server.group();

  let freqSpec = {
    minval: 100,
    maxval: 8000,
    warp: 'exp'
  };

  // Map 0..1 to an exponential frequency range from 100..8000
  let randFreq = () => sc.map.mapWithSpec(Math.random(), freqSpec);

  let spawn = (dur) => {
    server.synth(def, {
      fundfreq: randFreq(),
      formantfreq: randFreq(),
      bwfreq: randFreq(),
      pan: sc.map.linToLin(0, 1, -1, 1, Math.random()),
      timeScale: dur
    }, group);

    let next = Math.random() * 0.25;
    // Schedule this function again:
    setTimeout(() => spawn(next), next * 1000);
  };

  spawn(Math.random());

});

Compatibility

Works on Node 4+

Source code is written in ES2015 with Flow type annotations.

Contribute

License

MIT license

supercolliderjs's People

Contributors

crucialfelix avatar normalised avatar oatkiller avatar

Watchers

Spencer Russell avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.