[lib.audio-manager] chromium/webkit fix (must connect scriptProcessor to output
This commit is contained in:
parent
9f6bc383bf
commit
04c6e37527
|
@ -54,6 +54,7 @@ export default class AudioManager{
|
||||||
|
|
||||||
/* (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);
|
||||||
|
/*Chrome fix*/this.network.out.connect(this.output);
|
||||||
|
|
||||||
/* (6) Set up our filters' parameters */
|
/* (6) Set up our filters' parameters */
|
||||||
this.setUpFilters();
|
this.setUpFilters();
|
||||||
|
@ -99,9 +100,6 @@ export default class AudioManager{
|
||||||
|
|
||||||
}.bind(this.dbg), this.dbg.interval*1000);
|
}.bind(this.dbg), this.dbg.interval*1000);
|
||||||
|
|
||||||
|
|
||||||
this.test = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,21 +160,24 @@ export default class AudioManager{
|
||||||
/* (1) Disconnect all by default */
|
/* (1) Disconnect all by default */
|
||||||
this.input.disconnect();
|
this.input.disconnect();
|
||||||
|
|
||||||
/* (2) Get first filter */
|
/* (2) Also link to analyser */
|
||||||
|
this.input.connect(this.analyser);
|
||||||
|
|
||||||
|
/* (3) Get first filter */
|
||||||
let first_filter = this.filters.voice_clarity;
|
let first_filter = this.filters.voice_clarity;
|
||||||
let last_filter = this.filters.voice_sss;
|
let last_filter = this.filters.voice_sss;
|
||||||
|
|
||||||
/* (3) If unlink -> connect directly to NETWORK output */
|
/* (4) If unlink -> connect directly to NETWORK output */
|
||||||
if( unlink === true )
|
if( unlink === true )
|
||||||
return this.input.connect(this.network.out);
|
return this.input.connect(this.network.out);
|
||||||
|
|
||||||
/* (4) If linking -> connect input to volume */
|
/* (5) If linking -> connect input to volume */
|
||||||
this.input.connect(this.volume);
|
this.input.connect(this.volume);
|
||||||
|
|
||||||
/* (5) If linking -> connect volume to filter stack */
|
/* (6) If linking -> connect volume to filter stack */
|
||||||
this.volume.connect(first_filter);
|
this.volume.connect(first_filter);
|
||||||
|
|
||||||
/* (5) If linking -> connect stack end to network.out */
|
/* (7) If linking -> connect stack end to network.out */
|
||||||
last_filter.connect(this.network.out);
|
last_filter.connect(this.network.out);
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,8 +191,9 @@ export default class AudioManager{
|
||||||
|
|
||||||
/* (1) Bind audio stream
|
/* (1) Bind audio stream
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
|
console.log('BINDING', _stream);
|
||||||
|
|
||||||
/* (1) bind our audio stream to our source */
|
/* (1) bind our audio stream to our source */
|
||||||
console.log(_stream);
|
|
||||||
this.input = this.ctx.createMediaStreamSource(_stream);
|
this.input = this.ctx.createMediaStreamSource(_stream);
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,9 +202,6 @@ export default class AudioManager{
|
||||||
/* (1) Link through filters */
|
/* (1) Link through filters */
|
||||||
this.linkFilters();
|
this.linkFilters();
|
||||||
|
|
||||||
/* (2) Also link to analyser */
|
|
||||||
this.input.connect(this.analyser);
|
|
||||||
|
|
||||||
|
|
||||||
gs.get.audio_conn = 2; // voice connected
|
gs.get.audio_conn = 2; // voice connected
|
||||||
|
|
||||||
|
@ -406,7 +405,7 @@ export default class AudioManager{
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
/* (3) Debug */
|
/* (3) Debug */
|
||||||
this.ws.onopen = () => ( gs.get.audio_conn = 1 ); // listening
|
this.ws.onopen = () => gs.get.audio_conn !== 2 && (gs.get.audio_conn = 1); // listening
|
||||||
this.ws.onclose = () => ( gs.get.audio_conn = null ); // disconnected
|
this.ws.onclose = () => ( gs.get.audio_conn = null ); // disconnected
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,29 +421,54 @@ export default class AudioManager{
|
||||||
/* (1) Start websocket */
|
/* (1) Start websocket */
|
||||||
this.wsconnect(wsAddress);
|
this.wsconnect(wsAddress);
|
||||||
|
|
||||||
if( navigator.mediaDevices && navigator.mediaDevices.getUserMedia ){
|
/* (2) Set our streaming binding function */
|
||||||
|
let streaming_binding = function(stream){
|
||||||
|
|
||||||
navigator.mediaDevices.getUserMedia({ audio: true })
|
// this.recorder = new MediaRecorder(stream);
|
||||||
.then( stream => {
|
|
||||||
|
|
||||||
this.recorder = new MediaRecorder(stream);
|
|
||||||
this.bindRecorderStream(stream);
|
this.bindRecorderStream(stream);
|
||||||
|
|
||||||
this.recorder.onstart = () => console.warn('[audio] recording');
|
// this.recorder.onstart = () => console.warn('[audio] recording');
|
||||||
this.recorder.onstop = () => {
|
|
||||||
this.recorder.stream.getTracks().map( t => t.stop() );
|
|
||||||
this.recorder = null;
|
|
||||||
console.warn('[audio] stopped recording');
|
|
||||||
};
|
|
||||||
|
|
||||||
// start recording
|
// this.recorder.onstop = () => {
|
||||||
this.recorder.start();
|
// this.recorder.stream.getTracks().map( t => t.stop() );
|
||||||
|
// this.recorder = null;
|
||||||
|
// console.warn('[audio] stopped recording');
|
||||||
|
// };
|
||||||
|
|
||||||
})
|
// // start recording
|
||||||
.catch( e => console.warn('[audio] microphone permission issue', e) );
|
// this.recorder.start();
|
||||||
|
|
||||||
}else
|
}.bind(this);
|
||||||
console.warn('[audio] microphone not supported');
|
|
||||||
|
|
||||||
|
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
|
||||||
|
|
||||||
|
|
||||||
|
/* (3) If navigator.mediaDevices.getUserMedia */
|
||||||
|
if( navigator.mediaDevices && navigator.mediaDevices.getUserMedia ){
|
||||||
|
|
||||||
|
console.log('[audio] using "navigator.mediaDevices.getUserMedia"')
|
||||||
|
|
||||||
|
return navigator.mediaDevices.getUserMedia({ audio: true })
|
||||||
|
.then(streaming_binding)
|
||||||
|
.catch((e) => console.warn('[audio] microphone recorder issue', e));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (4) If old version */
|
||||||
|
if( navigator.getUserMedia ){
|
||||||
|
|
||||||
|
console.log('[audio] using "navigator.getUserMedia"')
|
||||||
|
|
||||||
|
return navigator.getUserMedia({ audio: true },
|
||||||
|
streaming_binding,
|
||||||
|
(e) => console.warn('[audio] microphone recorder issue', e));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.warn('[audio] recorder not supported');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue