From f3a62a0a6d5e369f86248588493eb5f1e6bc01c1 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 6 Apr 2018 12:57:22 +0200 Subject: [PATCH] [lib.audio-manager] fixed routing --- webpack/lib/audio-manager.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/webpack/lib/audio-manager.js b/webpack/lib/audio-manager.js index 9406b61..6d46599 100644 --- a/webpack/lib/audio-manager.js +++ b/webpack/lib/audio-manager.js @@ -37,19 +37,19 @@ export default class AudioManager{ voice_sss: this.ctx.createBiquadFilter() }; - /* (3) Set up our filters' parameters */ - this.setUpFilters(); - - /* (4) Create network I/O controller (WebSocket) */ + /* (3) Create network I/O controller (WebSocket) */ this.network = { out: this.ctx.createScriptProcessor(AudioManager.BUFFER_SIZE, 1, 1) }; + /* (4) Initialise websocket */ + this.ws = null; + /* (5) Bind network controller to send() function */ this.network.out.onaudioprocess = this.send.bind(this); - /* (6) Initialise websocket */ - this.ws = null; + /* (6) Set up our filters' parameters */ + this.setUpFilters(); @@ -133,8 +133,8 @@ export default class AudioManager{ /* (3) Connect presence reduction to 'ss' removal */ this.filters.voice_presence.connect( this.filters.voice_sss ); - /* (4) Connect last filter to MASTER gain */ - this.filters.voice_sss.connect(this.master); + /* (4) Connect last filter to NETWORK output */ + this.filters.voice_sss.connect(this.network.out); } @@ -152,9 +152,9 @@ export default class AudioManager{ /* (2) Get first filter */ let first_filter = this.filters.voice_clarity; - /* (3) If unlink -> connect directly to MASTER gain */ + /* (3) If unlink -> connect directly to NETWORK output */ if( unlink === true ) - return this.input.connect(this.master); + return this.input.connect(this.network.out); /* (4) If linking -> connect input to filter stack */ this.input.connect(first_filter); @@ -191,6 +191,10 @@ export default class AudioManager{ let buf16 = this.f32toi16(buf32); + // exit if no connection + if( this.ws === null || this.ws.readyState !== 1 ) + return; + this.ws.send(buf16); this.dbg.data.packets_sent++;