From c8b3c4289167d3db3ad625d4fd74907d02dc7226 Mon Sep 17 00:00:00 2001 From: picklesrus Date: Wed, 9 May 2018 15:59:42 -0700 Subject: [PATCH] Move the add event listener code to be in the same place where we call connect so there is only one place to do it. --- src/extensions/scratch3_speech/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/extensions/scratch3_speech/index.js b/src/extensions/scratch3_speech/index.js index 166c6de36..f78b4473e 100644 --- a/src/extensions/scratch3_speech/index.js +++ b/src/extensions/scratch3_speech/index.js @@ -523,7 +523,6 @@ class Scratch3SpeechBlocks { */ _resumeListening () { this._context.resume.bind(this._context); - this._scriptNode.addEventListener('audioprocess', this._processAudioCallback); this._newWebsocket(); } @@ -573,8 +572,6 @@ class Scratch3SpeechBlocks { _initScriptNode () { // Create a node that sends raw bytes across the websocket this._scriptNode = this._context.createScriptProcessor(4096, 1, 1); - // Need the maximum value for 16-bit signed samples, to convert from float. - this._scriptNode.addEventListener('audioprocess', this._processAudioCallback); } /** @@ -646,6 +643,7 @@ class Scratch3SpeechBlocks { // Hook up the scriptNode to the mic this._sourceNode = this._context.createMediaStreamSource(this._micStream); this._sourceNode.connect(this._scriptNode); + this._scriptNode.addEventListener('audioprocess', this._processAudioCallback); this._scriptNode.connect(this._context.destination); }