diff --git a/js/recorderjs/recorderWorker.js b/js/recorderjs/recorderWorker.js index c2c0802..57bdd51 100644 --- a/js/recorderjs/recorderWorker.js +++ b/js/recorderjs/recorderWorker.js @@ -141,13 +141,13 @@ function encodeWAV(samples, mono){ /* sample format (raw) */ view.setUint16(20, 1, true); /* channel count */ - view.setUint16(22, mono?1:2, true); + view.setUint16(22, mono ? 1 : 2, true); /* sample rate */ view.setUint32(24, sampleRate, true); - /* byte rate (sample rate * block align) */ - view.setUint32(28, sampleRate * 4, true); + /* byte rate (sample rate * channels * bytes per sample) */ + view.setUint32(28, sampleRate * (mono ? 1 : 2) * 2, true); /* block align (channel count * bytes per sample) */ - view.setUint16(32, 4, true); + view.setUint16(32, (mono ? 1 : 2) * 2, true); /* bits per sample */ view.setUint16(34, 16, true); /* data chunk identifier */