| 1 | class TrioProcessor extends AudioWorkletProcessor { |
| 2 | constructor(options) { |
| 3 | super(options); |
| 4 | const wasmBytes = options.processorOptions.wasmBytes; |
| 5 | |
| 6 | const mod = new WebAssembly.Module(wasmBytes); |
| 7 | this.wasm = new WebAssembly.Instance(mod, {}); |
| 8 | |
| 9 | this.dsp = this.wasm.exports.newdsp(sampleRate); |
| 10 | this.outptr = this.wasm.exports.alloc(128); |
| 11 | this.outbuf = new Float32Array( |
| 12 | this.wasm.exports.memory.buffer, |
| 13 | this.outptr, |
| 14 | 128 |
| 15 | ); |
| 16 | this.port.onmessage = |
| 17 | (event) => this.onmessage(event.data); |
| 18 | } |
| 19 | |
| 20 | process(inputs, outputs, parameters) { |
| 21 | const output = outputs[0]; |