fix mic meter and distribute participant positions
This commit is contained in:
1 parent
7b9ff4c098
commit
2888a54259
2 files changed
+23
-25
No files matched your search
@@ -6,6 +6,7 @@ export class AudioManager {
|
||||
this.source = null;
|
||||
this.gainNode = null;
|
||||
this.analyser = null;
|
||||
this.meterSink = null;
|
||||
this.meterData = new Float32Array(1024);
|
||||
this.gain = Number(localStorage.getItem('voicepoc.micGain') || 1);
|
||||
}
|
||||
@@ -25,20 +26,24 @@ export class AudioManager {
|
||||
this.gainNode.gain.value = this.gain;
|
||||
this.analyser = this.context.createAnalyser();
|
||||
this.analyser.fftSize = 1024;
|
||||
this.meterSink = this.context.createGain();
|
||||
this.meterSink.gain.value = 0;
|
||||
const destination = this.context.createMediaStreamDestination();
|
||||
this.source.connect(this.gainNode).connect(this.analyser);
|
||||
// Keep the analyser alive without sending the microphone to the speakers.
|
||||
this.analyser.connect(this.meterSink).connect(this.context.destination);
|
||||
this.gainNode.connect(destination);
|
||||
this.outputStream = destination.stream;
|
||||
return this.outputStream;
|
||||
}
|
||||
|
||||
detachInput() {
|
||||
for (const node of [this.source, this.gainNode, this.analyser]) {
|
||||
for (const node of [this.source, this.gainNode, this.analyser, this.meterSink]) {
|
||||
try { node?.disconnect(); } catch {}
|
||||
}
|
||||
this.outputStream?.getTracks().forEach((track) => track.stop());
|
||||
this.rawStream?.getTracks().forEach((track) => track.stop());
|
||||
this.source = this.gainNode = this.analyser = null;
|
||||
this.source = this.gainNode = this.analyser = this.meterSink = null;
|
||||
this.outputStream = this.rawStream = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user