added debug

This commit is contained in:
xdrm-brackets 2018-04-06 01:08:09 +02:00
parent 05eb18d0ad
commit 0b3d093cb2
1 changed files with 7 additions and 1 deletions

View File

@ -41,12 +41,15 @@ export default class AudioManager{
if( self.ws.readyState !== 1 ) // not connected -> stack
return self._ws.stack.push(_data);
console.warn(`send buffer[${_data.length}]`);
self.ws.send(_data);
},
};
/* (9) Manage websocket message stack */
this.ws.onopen = function(){
console.warn(`pop stack of size ${this._ws.stack.length}`);
while( this._ws.stack.length > 0 )
this.ws.send(this._ws.stack.shift());
}.bind(this);
@ -54,6 +57,7 @@ export default class AudioManager{
/* (10) Manage websocket responses */
this.ws.onmessage = function(_blob){
console.warn(`received`, _blob);
if( !(_blob instanceof Blob) )
return console.warn('NIQUE');
@ -117,7 +121,6 @@ export default class AudioManager{
bindRecorderStream(_stream){
/* (1) Bind audio stream */
console.warn(_stream);
this.input = this.ctx.createMediaStreamSource(_stream);
}
@ -135,12 +138,15 @@ export default class AudioManager{
let buf16 = this.f32toi16(buf32);
console.log(`read buffer[${buf16.length}]`);
this._ws.send(buf16);
}
receive(_buffer){
console.log(`play buffer[${_buffer.length}]`);
/* (1) Convert to Float32Array */
let buf32 = this.i16tof32(_buffer);