All Projects → crucialfelix → Supercolliderjs

crucialfelix / Supercolliderjs

Licence: mit
The JavaScript client library for SuperCollider

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Supercolliderjs

Supercollider
An audio server, programming language, and IDE for sound synthesis and algorithmic composition.
Stars: ✭ 4,036 (+959.32%)
Mutual labels:  audio, music, sound, supercollider, livecoding
Dx7 Supercollider
My accurate Yamaha DX-7 clone. Programmed in Supercollider.
Stars: ✭ 395 (+3.67%)
Mutual labels:  audio, music, sound, supercollider
Sc3 Plugins
Community plugins for SC3. Hey! Don't click the "download" button here, go to https://supercollider.github.io/sc3-plugins/ instead!
Stars: ✭ 307 (-19.42%)
Mutual labels:  audio, sound, supercollider
Torch Audiomentations
Fast audio data augmentation in PyTorch. Inspired by audiomentations. Useful for deep learning.
Stars: ✭ 164 (-56.96%)
Mutual labels:  audio, music, sound
Fradioplayer
A simple radio player framework for iOS, macOS, tvOS.
Stars: ✭ 183 (-51.97%)
Mutual labels:  audio, music, audio-library
Lissajous
🎵 A tool for programmatic audio performance in the browser using Javascript.
Stars: ✭ 367 (-3.67%)
Mutual labels:  audio, music, livecoding
Simple Sdl2 Audio
A simple SDL2 audio library without SDL_Mixer for playing music and multiple sounds natively in SDL2
Stars: ✭ 111 (-70.87%)
Mutual labels:  audio, music, sound
Aubio
a library for audio and music analysis
Stars: ✭ 2,601 (+582.68%)
Mutual labels:  audio, music, sound
Minibae
The platform-neutral Beatnik Audio Engine, Mini Edition (miniBAE) is an exceptionally mature, well-rounded, and reliable computer music and sound system specially customized for small-footprint and embedded applications.
Stars: ✭ 82 (-78.48%)
Mutual labels:  audio, music, sound
Gwion
🎵 strongly-timed musical programming language
Stars: ✭ 235 (-38.32%)
Mutual labels:  audio, music, sound
Mimium
mimium (MInimal Musical medIUM) a programming language as an infrastructure for sound and music.
Stars: ✭ 212 (-44.36%)
Mutual labels:  audio, music, sound
Swift Radio Pro
Professional Radio Station App for iOS!
Stars: ✭ 2,644 (+593.96%)
Mutual labels:  audio, music, sound
Daisysp
A Powerful, Open Source DSP Library in C++
Stars: ✭ 291 (-23.62%)
Mutual labels:  audio, music, sound
Webmidikit
Simplest MIDI Swift library
Stars: ✭ 100 (-73.75%)
Mutual labels:  audio, music, sound
Ni Media
NI Media is a C++ library for reading and writing audio streams.
Stars: ✭ 158 (-58.53%)
Mutual labels:  audio, music, sound
Audiokitsynthone
AudioKit Synth One: Open-Source iOS Synthesizer App
Stars: ✭ 1,258 (+230.18%)
Mutual labels:  audio, music, sound
Supriya
A Python API for SuperCollider
Stars: ✭ 167 (-56.17%)
Mutual labels:  audio, music, supercollider
Pandoraplayer
🅿️ PandoraPlayer is a lightweight music player for iOS, based on AudioKit and completely written in Swift.
Stars: ✭ 1,037 (+172.18%)
Mutual labels:  audio, music, sound
Sonic Pi
Code. Music. Live.
Stars: ✭ 8,736 (+2192.91%)
Mutual labels:  audio, music, livecoding
Ableton Live Tools
A collection of useful additions to @Ableton Live, including better @Git integration.
Stars: ✭ 198 (-48.03%)
Mutual labels:  audio, music, sound

supercolliderjs

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

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. supercollider.github.io

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.

Install

  1. Install SuperCollider: https://supercollider.github.io/

  2. Install supercolliderjs:

npm install supercolliderjs

Examples

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(
    "formant",
    `{ |out=0, fundfreq=440, formantfreq=440, bwfreq=100, timeScale=1, pan=0|
        var saw, envd, panned;

        saw = Formant.ar(fundfreq, formantfreq, bwfreq);

        envd = saw * EnvGen.kr(Env.sine(0.1, 0.2), timeScale: timeScale, doneAction: 2);
        panned = Pan2.ar(envd * AmpCompA.kr(fundfreq, 0.2, 0.7), pan);

        OffsetOut.ar(out, panned);
      }`,
  );

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

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

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

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

    const next = Math.random() * 0.25;

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

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

source

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(
    "pulse",
    `{ arg out = 0, freq=200;
    Out.ar(out, Pulse.ar(200, Line.kr(0.01,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 = LFClipNoise.ar(MouseX.kr(200, 10000, 1), 0.125);
        Out.ar(out, clip);
      }`,
    },
    lpf: {
      source: `{ arg in = 0, out = 0;
        var input = In.ar(in);
        var lpf = RLPF.ar(input, MouseY.kr(1e2, 2e4, 1), 0.2, 0.2);
        ReplaceOut.ar(out, 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/"));
});

source

const sc = require("supercolliderjs");

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

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

source

Server Plus Server

lang

  • 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");
  console.log(pyr8);

  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);
  console.log(pyrs);

  // 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();
});

source

Documentation

Documentation

Compatibility

Works on Node 10+

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

Contribute

License

MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].