blob: c40b5a7179aefe43d30439a017625460ee03ccff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
let singleton;
class Singleton extends AudioWorkletProcessor {
constructor() {
if (!singleton) {
singleton = new AudioWorkletProcessor();
singleton.process = function() {
this.port.postMessage({message: "process called"});
// This function will be called at most once for each AudioWorkletNode
// if the node has no input connections.
return false;
}
}
return singleton;
}
}
registerProcessor("singleton", Singleton);
|