triolet.client
v1.1.0
Published
triolet.client
Downloads
5
Readme
triolet.client
DRIVER
and API
in the main thread; DSP
in the worker thread. This architecture works on the browser.
Installation
$ npm install triolet.client
Example
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({ workerPath: "/path/to/worker", api: new API(), driver: new Driver() });
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() });
API
client/Triolet
constructor()
Instance attributes
api: TrioletAPI
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
sendToDSP(data: any): void
worker/Triolet
constructor(self: DedicatedWorkerGlobalScope)
Instance attributes
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
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