From f48618394ee1daaa1214e41ba38ff518ea0e9c4a Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Sat, 4 Feb 2017 21:11:58 +0100 Subject: [PATCH] [#25] Adding GainNode --- ts/Stream/StreamClient.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ts/Stream/StreamClient.ts b/ts/Stream/StreamClient.ts index bb86154..8237b4c 100644 --- a/ts/Stream/StreamClient.ts +++ b/ts/Stream/StreamClient.ts @@ -15,6 +15,7 @@ class StreamClient { private audioContext: AudioContext; private mediaStreamSource: MediaStreamAudioSourceNode; + private gainNode: GainNode; private userSpeechAnalyser: AnalyserNode; private recorder: Recorder; private resampleProcessor; @@ -175,7 +176,14 @@ class StreamClient { this.mediaStreamSource = this.audioContext.createMediaStreamSource(stream); this.onEvent(IStreamClient.EVENT.MSG_MEDIA_STREAM_CREATED, "Media stream created"); + + // create audio nodes + this.gainNode = this.audioContext.createGain(); this.userSpeechAnalyser = this.audioContext.createAnalyser(); + + // connect: input ~> gain ~> userSpeechAnalyser ~> output + this.mediaStreamSource.connect(this.gainNode); + this.gainNode.connect(this.userSpeechAnalyser); this.mediaStreamSource.connect(this.userSpeechAnalyser); this.recorder = new Recorder(this.mediaStreamSource); this.onEvent(IStreamClient.EVENT.MSG_INIT_RECORDER, "Recorder initialized");