mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
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.
This commit is contained in:
parent
d2cff42a99
commit
c8b3c42891
1 changed files with 1 additions and 3 deletions
|
@ -523,7 +523,6 @@ class Scratch3SpeechBlocks {
|
||||||
*/
|
*/
|
||||||
_resumeListening () {
|
_resumeListening () {
|
||||||
this._context.resume.bind(this._context);
|
this._context.resume.bind(this._context);
|
||||||
this._scriptNode.addEventListener('audioprocess', this._processAudioCallback);
|
|
||||||
this._newWebsocket();
|
this._newWebsocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,8 +572,6 @@ class Scratch3SpeechBlocks {
|
||||||
_initScriptNode () {
|
_initScriptNode () {
|
||||||
// Create a node that sends raw bytes across the websocket
|
// Create a node that sends raw bytes across the websocket
|
||||||
this._scriptNode = this._context.createScriptProcessor(4096, 1, 1);
|
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
|
// Hook up the scriptNode to the mic
|
||||||
this._sourceNode = this._context.createMediaStreamSource(this._micStream);
|
this._sourceNode = this._context.createMediaStreamSource(this._micStream);
|
||||||
this._sourceNode.connect(this._scriptNode);
|
this._sourceNode.connect(this._scriptNode);
|
||||||
|
this._scriptNode.addEventListener('audioprocess', this._processAudioCallback);
|
||||||
this._scriptNode.connect(this._context.destination);
|
this._scriptNode.connect(this._context.destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue