I'm building a simple voice chat app. I decide to use NodeJS, but I can't understand why buffers are always empty.
I'm using https://github.com/mattdiamond/Recorderjs
My code looks like this:
var audio_context;
var recorder;
function startUserMedia(stream) {
var input = audio_context.createMediaStreamSource(stream);
input.connect(audio_context.destination);
recorder = new Recorder(input);
}
function process() {
recorder.record();
setTimeout(function() {
recorder.getBuffer(function(data) {
console.log(data);
});
}, 3000);
}
window.onload = function init() {
try {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;
window.URL = window.URL || window.webkitURL;
audio_context = new AudioContext;
} catch (e) {
console.log(e);
}
navigator.getUserMedia({audio: true}, startUserMedia);
setTimeout(process, 1500);
};
The problem is that when the getBuffer callback is executed data is always containing 2 empty arrays :(