tone
Version:
A Web Audio framework for making interactive music in the browser.
36 lines (30 loc) • 812 B
text/typescript
import { addToWorklet } from "./WorkletGlobalScope.js";
const toneAudioWorkletProcessor = /* javascript */ `
/**
* The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}.
*/
class ToneAudioWorkletProcessor extends AudioWorkletProcessor {
constructor(options) {
super(options);
/**
* If the processor was disposed or not. Keep alive until it's disposed.
*/
this.disposed = false;
/**
* The number of samples in the processing block
*/
this.blockSize = 128;
/**
* the sample rate
*/
this.sampleRate = sampleRate;
this.port.onmessage = (event) => {
// when it receives a dispose
if (event.data === "dispose") {
this.disposed = true;
}
};
}
}
`;
addToWorklet(toneAudioWorkletProcessor);