From a06e9c1789ef0c61656795bf4d42e9b4cda0cd96 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 9 Apr 2018 19:11:00 +0200 Subject: [PATCH] [lib.audio-manager] fixed buffer read (send() ScriptProcessor) + receive() only pushes to stack --- parcel/lib/audio-manager.js | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/parcel/lib/audio-manager.js b/parcel/lib/audio-manager.js index 79fd02b..6641799 100644 --- a/parcel/lib/audio-manager.js +++ b/parcel/lib/audio-manager.js @@ -260,6 +260,10 @@ export default class AudioManager{ /* (5) Send buffer through websocket */ this.ws.send(buf16); + /* (6) Read input buffer */ + this.stack.shift().start(this.ctx.currentTime); + + // DEBUG this.dbg.data.packets_sent++; @@ -291,27 +295,8 @@ export default class AudioManager{ source.connect(gain); gain.connect(this.master); - /* (7) If not empty stack -> play stack */ - if( this.stack.length > this.stack_save ){ - this.stack.shift().start(this.ctx.currentTime); - return this.stack.push(source); - } - - - /* (8) If empty stack -> play + chain */ - // chain stack - source.onended = function(){ - - this.dbg.data.packets_received++; - this.dbg.data.kB_received += _buffer.length * 16. / 8 / 1024; - - if( this.stack.length > this.stack_save ) - this.stack.shift().start(this.ctx.curentTime); - - }.bind(this); - - // push in stack - source.start(this.ctx.currentTime); + /* (7) Push in buffer stack */ + this.stack.push(source); }