Here's a gist that should help: https://gist.github.com/kevincennis/9754325.
I haven't actually tested this, so there might be a stupid typo or something, but the basic approach will work (I've done it before).
Essentially, you're going to use the web worker from Recorder.js directly so that you can process one big AudioBuffer all in one shot, rather than recording it incrementally in real-time.
I'll paste the code here too, just in case something happens to the gist...
// assuming a var named `buffer` exists and is an AudioBuffer instance
// start a new worker
// we can't use Recorder directly, since it doesn't support what we're trying to do
var worker = new Worker('recorderWorker.js');
// initialize the new worker
worker.postMessage({
command: 'init',
config: {sampleRate: 44100}
});
// callback for `exportWAV`
worker.onmessage = function( e ) {
var blob = e.data;
// this is would be your WAV blob
};
// send the channel data from our buffer to the worker
worker.postMessage({
command: 'record',
buffer: [
buffer.getChannelData(0),
buffer.getChannelData(1)
]
});
// ask the worker for a WAV
worker.postMessage({
command: 'exportWAV',
type: 'audio/wav'
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…