duolet.audioworker
v0.1.0
Published
duolet.audioworker
Downloads
2
Readme
duolet.audioworker
This is an experimental module. AudioWorker haven't been implemented in any browsers yet. *
DRIVER
and DSP
in the worker thread. This architecture works on the browser.
Installation
$ npm install duolet.audioworker
Example
in the main thread
const duolet = require("duolet.audioworker/client")();
const Driver = require("pico.driver.audioworker/client");
let audioContext = new AudioContext();
duolet.compose({ workerPath: "/path/to/worker", driver: new Driver() });
duolet.setup({ context: audioContext, bufferLength: 1024 });
duolet.sendToWorker({ type: "start" });
in the worker thread
const duolet = require("duolet.audioworker/worker")(self);
const Driver = require("pico.driver.audioworker/worker");
const DSP = require("./dsp");
duolet.compose({ dsp: new DSP(), driver: new Driver(self) });
duolet.recvFromClient = (e) => {
if (e.type === "start") {
duolet.start();
}
};
API
client/Duolet
constructor()
Instance attributes
driver: pico.driver
sampleRate: number
(implicit readonly)bufferLength: number
(implicit readonly)
Instance methods
compose(spec: object): self
setup(opts: object): self
start(): self
stop(): self
sendToServer(data: any): void
worker/Duolet
constructor(self: AudioWorkerGlobalScope)
Instance attributes
dsp: duoletDSP
sampleRate: number
(implicit readonly)bufferLength: number
(implicit readonly)
Instance methods
compose(spec: object): self
setup(opts: object): self
start(): self
stop(): self
sendToClient(data: any): void
Interfaces
interface duoletDSP {
optional setup(opts: object) => void;
optional start() => void;
optional stop() => void;
process(bufL: Float32Array, bufR: Float32Array) => void;
}
Audio Drivers
- https://github.com/mohayonao/pico.driver
License
MIT