1.1.0 • Published 10 years ago

triolet.worker v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

triolet.worker

NPM Version License

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

triolet.worker

Installation

$ npm install triolet.worker

Example

in the main thread

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

let audioContext = new AudioContext();

triolet.compose({ workerPath: "/path/to/worker", driver: new Driver() });
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();
  }
};

API

client/Triolet

  • constructor()

Instance attributes

  • driver: TrioletDriver
  • sampleRate: number (implicit readonly)
  • bufferLength: number (implicit readonly)
  • state: string (implicit readonly)

Instance methods

  • compose(spec: object): self
  • setup(opts: object): self
  • start(): self
  • stop(): self
  • sendToWorker(data: any): void

worker/Triolet

  • constructor(self: DedicatedWorkerGlobalScope)

Instance attributes

  • api: TrioletAPI
  • dsp: TrioletDSP
  • sampleRate: number (implicit readonly)
  • bufferLength: number (implicit readonly)
  • state: string (implicit readonly)

Instance methods

  • compose(spec: object): self
  • setup(opts: object): self
  • start(): self
  • stop(): self
  • sendToAPI(data: any): void
  • sendToDSP(data: any): void
  • recvFromClient(data: any): void

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

1.1.0

10 years ago

1.0.0

10 years ago

0.8.0

10 years ago

0.7.4

10 years ago

0.7.3

10 years ago

0.7.2

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago