I am currently developing a walkie-talkie type environment. Recording and resampling audio work fine now (thanks for the help), playing works .. sort of.
My data comes in (WAV-) blobs, so here's what I do:
audioPlay(blob)
{
var fileReader = new FileReader();
fileReader.onload = function() {
theContext.decodeAudioData(this.result, function(buffer) {
var source = theContext.createBufferSource();
source.buffer = buffer;
source.connect(theContext.destination);
source.start(0);
});
};
fileReader.readAsArrayBuffer(blob);
}
But every new audio adds a slight start-delay which grows with every new audio. After a few audios, the delay adds almost 2-3 seconds. Logging doesn't show any delays, program flows fine all the way down to .source.start.
Any ideas?
Michaela, this sounds more like it might be a problem in the source - are you sure each incoming blob is correct (of correct length, and has audio at the beginning?) It seems like it might be that you're just tacking the new recording on to the end of an empty buffer at that end. Barring that specific problem, I'd take a look at the audio blob that's coming in - maybe the decode is too expensive for some reasons? (I.e. if you have a 2-3 second cumulative delay, you should be able to tell from logging if the delay is in receiving the data, decoding it, or in the buffer itself.