@100mslive/hms-noise-suppression
Advanced tools
Comparing version
@@ -17,2 +17,3 @@ import { HMSAudioPlugin, HMSAudioPluginType } from '@100mslive/hms-video'; | ||
setNoiseSuppression(value: boolean): void; | ||
removeNoise(buffer: any, module: any): void; | ||
processAudioTrack(audioContext: AudioContext, sourceNode: MediaStreamAudioSourceNode): Promise<AudioNode>; | ||
@@ -19,0 +20,0 @@ private log; |
{ | ||
"version": "0.1.3", | ||
"version": "0.1.4-1", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
@@ -77,3 +77,7 @@ // @ts-ignore | ||
this.setNoiseSuppression(false); | ||
this.processingNode.disconnect(); | ||
if(this.processingNode){ | ||
this.processingNode.disconnect(); | ||
} | ||
//TODO: see if we need to disconnect audio nodes also | ||
@@ -85,2 +89,13 @@ } | ||
} | ||
removeNoise(buffer: any, module: any) { | ||
let ptr = module.ptr; | ||
let st = module.st; | ||
for (let i = 0; i < 480; i++) { | ||
module.HEAPF32[(ptr >> 2) + i] = buffer[i] * 32768; | ||
} | ||
module._rnnoise_process_frame(st, ptr, ptr); | ||
for (let i = 0; i < 480; i++) { | ||
buffer[i] = module.HEAPF32[(ptr >> 2) + i] / 32768; | ||
} | ||
} | ||
@@ -116,13 +131,4 @@ processAudioTrack(audioContext: AudioContext, sourceNode: MediaStreamAudioSourceNode): Promise<AudioNode> { | ||
function removeNoise(buffer: any, module: any) { | ||
let ptr = module.ptr; | ||
let st = module.st; | ||
for (let i = 0; i < 480; i++) { | ||
module.HEAPF32[(ptr >> 2) + i] = buffer[i] * 32768; | ||
} | ||
module._rnnoise_process_frame(st, ptr, ptr); | ||
for (let i = 0; i < 480; i++) { | ||
buffer[i] = module.HEAPF32[(ptr >> 2) + i] / 32768; | ||
} | ||
} | ||
this.log(TAG, this.suppressNoise); | ||
@@ -134,4 +140,3 @@ this.processingNode.onaudioprocess = (e: any) => { | ||
// Drain input buffer. | ||
this.log(TAG, this.suppressNoise); | ||
for (let i = 0; i < bufferSize; i++) { | ||
@@ -147,3 +152,3 @@ inputBuffer.push(input[i]); | ||
if (this.suppressNoise) { | ||
removeNoise(frameBuffer, this.module); | ||
this.removeNoise(frameBuffer, this.module); | ||
} | ||
@@ -150,0 +155,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
18626
0.04%7033658
-0.49%