MCPcopy Create free account
hub / github.com/PaulBatchelor/Trio / TrioProcessor

Class TrioProcessor

web/processor.js:1–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class 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];
22
23 this.wasm.exports.process(this.dsp, this.outptr, 128);
24 for (let c = 0; c < output.length; ++c) {
25 const outChan = output[c];
26 for (let i = 0; i < outChan.length; ++i) {
27 outChan[i] = this.outbuf[i];
28 //outChan[i] = Math.random()*0.1;
29 }
30 }
31
32 return true;
33 }
34
35 onmessage(event) {
36 if (event.type == "move") {
37 //console.log("processor move 2", event.x, event.y);
38 this.wasm.exports.vox_x_axis(this.dsp, event.x);
39 this.wasm.exports.vox_y_axis(this.dsp, 1.0 - event.y);
40 } else if (event.type == "off") {
41 //console.log("proc up 2");
42 this.wasm.exports.vox_gate(this.dsp, 0.0);
43 } else if (event.type == "on") {
44 console.log("proc down 2");
45 this.wasm.exports.vox_gate(this.dsp, 1.0);
46 }
47 }
48}
49
50registerProcessor('trio', TrioProcessor);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected