[lib.audio-manager] fixed routing

This commit is contained in:
xdrm-brackets 2018-04-06 12:57:22 +02:00
parent 854adb244d
commit f3a62a0a6d
1 changed files with 14 additions and 10 deletions

View File

@ -37,19 +37,19 @@ export default class AudioManager{
voice_sss: this.ctx.createBiquadFilter() voice_sss: this.ctx.createBiquadFilter()
}; };
/* (3) Set up our filters' parameters */ /* (3) Create network I/O controller (WebSocket) */
this.setUpFilters();
/* (4) Create network I/O controller (WebSocket) */
this.network = { this.network = {
out: this.ctx.createScriptProcessor(AudioManager.BUFFER_SIZE, 1, 1) out: this.ctx.createScriptProcessor(AudioManager.BUFFER_SIZE, 1, 1)
}; };
/* (4) Initialise websocket */
this.ws = null;
/* (5) Bind network controller to send() function */ /* (5) Bind network controller to send() function */
this.network.out.onaudioprocess = this.send.bind(this); this.network.out.onaudioprocess = this.send.bind(this);
/* (6) Initialise websocket */ /* (6) Set up our filters' parameters */
this.ws = null; this.setUpFilters();
@ -133,8 +133,8 @@ export default class AudioManager{
/* (3) Connect presence reduction to 'ss' removal */ /* (3) Connect presence reduction to 'ss' removal */
this.filters.voice_presence.connect( this.filters.voice_sss ); this.filters.voice_presence.connect( this.filters.voice_sss );
/* (4) Connect last filter to MASTER gain */ /* (4) Connect last filter to NETWORK output */
this.filters.voice_sss.connect(this.master); this.filters.voice_sss.connect(this.network.out);
} }
@ -152,9 +152,9 @@ export default class AudioManager{
/* (2) Get first filter */ /* (2) Get first filter */
let first_filter = this.filters.voice_clarity; 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 ) if( unlink === true )
return this.input.connect(this.master); return this.input.connect(this.network.out);
/* (4) If linking -> connect input to filter stack */ /* (4) If linking -> connect input to filter stack */
this.input.connect(first_filter); this.input.connect(first_filter);
@ -191,6 +191,10 @@ export default class AudioManager{
let buf16 = this.f32toi16(buf32); let buf16 = this.f32toi16(buf32);
// exit if no connection
if( this.ws === null || this.ws.readyState !== 1 )
return;
this.ws.send(buf16); this.ws.send(buf16);
this.dbg.data.packets_sent++; this.dbg.data.packets_sent++;