diff options
author | MetaMuffin <metamuffin@yandex.com> | 2021-08-06 15:48:09 +0200 |
---|---|---|
committer | MetaMuffin <metamuffin@yandex.com> | 2021-08-06 15:48:09 +0200 |
commit | c5f4438589be44208ce4946c3c090350840113ba (patch) | |
tree | 12dce24038ef6a2e712b236e14cb2e06408c00b0 /public/rnnoise/rnnoise-processor.js | |
parent | fe66a0b23dafd562fc50ddfe5ba326ee33872c24 (diff) | |
download | keks-meet-c5f4438589be44208ce4946c3c090350840113ba.tar keks-meet-c5f4438589be44208ce4946c3c090350840113ba.tar.bz2 keks-meet-c5f4438589be44208ce4946c3c090350840113ba.tar.zst |
fixed firefox specific bug
Diffstat (limited to 'public/rnnoise/rnnoise-processor.js')
-rw-r--r-- | public/rnnoise/rnnoise-processor.js | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/public/rnnoise/rnnoise-processor.js b/public/rnnoise/rnnoise-processor.js index 1008e87..5b594a4 100644 --- a/public/rnnoise/rnnoise-processor.js +++ b/public/rnnoise/rnnoise-processor.js @@ -1,2 +1,41 @@ -'use strict';{let b,d;registerProcessor("rnnoise",class extends AudioWorkletProcessor{constructor(a){super({...a,numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1]});b||(d=new Float32Array((b=(new WebAssembly.Instance(a.processorOptions.module)).exports).memory.buffer));this.state=b.newState();this.alive=!0;this.port.onmessage=({data:a})=>{this.alive&&(a?this.port.postMessage({vadProb:b.getVadProb(this.state)}):(this.alive=!1,b.deleteState(this.state)))}}process(a,c,e){if(this.alive)return d.set(a[0][0], -b.getInput(this.state)/4),a=c[0][0],(c=b.pipe(this.state,a.length)/4)&&a.set(d.subarray(c,c+a.length)),!0}})}; +"use strict"; +{ + let b, d; + registerProcessor( + "rnnoise", + class extends AudioWorkletProcessor { + constructor(a) { + super({ + ...a, + numberOfInputs: 1, + numberOfOutputs: 1, + outputChannelCount: [1], + }); + b || + (d = new Float32Array( + (b = new WebAssembly.Instance(a.processorOptions.module) + .exports).memory.buffer + )); + this.state = b.newState(); + this.alive = !0; + this.port.onmessage = ({ data: a }) => { + this.alive && + (a + ? this.port.postMessage({ vadProb: b.getVadProb(this.state) }) + : ((this.alive = !1), b.deleteState(this.state))); + }; + } + process(a, c, e) { + if (!a[0][0]) return 1 + if (this.alive) + return ( + d.set(a[0][0], b.getInput(this.state) / 4), + (a = c[0][0]), + (c = b.pipe(this.state, a.length) / 4) && + a.set(d.subarray(c, c + a.length)), + !0 + ); + } + } + ); +} |