0.4.0 • Published 8 years ago

triolet.browser v0.4.0

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

triolet

Build Status License

3 layered architecture for sound programming in JavaScript

Installation

triolet.bundle

NPM Version

All components in the main thread. This architecture works on the browser and the Node.js

triolet.bundle

$ npm install triolet.bundle

in the main thread

const triolet = require("triolet.bundle")();
const Driver = require("pico.driver.webaudio");
const API = require("./api");
const DSP = require("./dsp");

let audioContext = new AudioContext();

triolet.compose({ api: new API(), dsp: new DSP(), driver: new Driver() });
triolet.setup({ context: audioContext, bufferLength: 1024 });

triolet.start();

triolet.client

NPM Version

DRIVER and API in the main thread; DSP in the worker thread. This architecture works on the browser.

triolet.client

$ npm install triolet.client

in the main thread

const triolet = require("triolet.client/client")();
const Driver = require("pico.driver.webaudio");
const API = require("./api");

let audioContext = new AudioContext();

triolet.compose({ api: new API(), driver: new Driver(), workerPath: "/path/to/worker" });
triolet.setup({ context: audioContext, bufferLength: 1024 });

triolet.start();

in the worker thread

const triolet = require("triolet.client/worker")(self);
const DSP = require("./dsp");

triolet.compose({ dsp: new DSP() });

triolet.worker

NPM Version

DRIVER in the main thread; API and DSP in the worker thread. This architecture works on the browser.

triolet.worker

$ npm install triolet.worker

in the main thread

const triolet = require("triolet.worker/client")();
const Driver = require("pico.driver.webaudio");

let audioContext = new AudioContext();

triolet.compose({ driver: new Driver(), workerPath: "/path/to/worker" });
triolet.setup({ context: audioContext, bufferLength: 1024 });

triolet.sendToWorker({ type: "start" });

in the worker thread

const triolet = require("triolet.worker/worker")(self);
const API = require("./api");
const DSP = require("./dsp");

triolet.compose({ api: new API(), dsp: new DSP() });

triolet.recvFromClient = (e) => {
  if (e.type === "start") {
    triolet.start();
  }
};

Interfaces

interface TrioletAPI {
  optional setup(opts: object) => void;
  optional start() => void;
  optional stop() => void;
  process(inNumSamples: number) => void;
}
interface TrioletDSP {
  optional setup(opts: object) => void;
  optional start() => void;
  optional stop() => void;
  process(bufL: Float32Array, bufR: Float32Array) => void;
}

Audio Drivers

License

MIT