Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bounce an AudioBuffer to WAV with RecorderWorker.js
// assuming you have an AudioBuffer instance called `buffer`,
// and an AudioContext (or OfflineAudioContext) called `ctx`...
// create a new Worker...
var worker = new Worker('recorderWorker.js');
// get it started and send some config data...
command: 'init',
config: {
sampleRate: ctx.sampleRate
// pass it your full buffer...
command: 'record',
buffer: [
// ask it to export your WAV...
command: 'exportWAV',
type: 'audio/wav'
// force a download when it's done
worker.onmessage = function(e){
Recorder.forceDownload(, 'SomeFileName.wav');

This comment has been minimized.

Copy link

@1j01 1j01 commented Nov 16, 2015

Configuring numChannels was necessary to get this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment