From 18586eb951143e20a4dba2a19a88686c9a261bd3 Mon Sep 17 00:00:00 2001 From: Saqib Shaikh Date: Fri, 8 Jan 2016 20:23:03 +0000 Subject: [PATCH 1/3] In the wave header, bytes 29-32 were not being set correctly for mono audio --- dist/recorder.js | 2 +- lib/recorder.js | 2 +- src/recorder.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/recorder.js b/dist/recorder.js index 42a6ad0f..5b1b8215 100644 --- a/dist/recorder.js +++ b/dist/recorder.js @@ -259,7 +259,7 @@ /* sample rate */ view.setUint32(24, sampleRate, true); /* byte rate (sample rate * block align) */ - view.setUint32(28, sampleRate * 4, true); + view.setUint32(28, sampleRate * numChannels * 2, true); /* block align (channel count * bytes per sample) */ view.setUint16(32, numChannels * 2, true); /* bits per sample */ diff --git a/lib/recorder.js b/lib/recorder.js index d19cb210..dfc1ea2e 100644 --- a/lib/recorder.js +++ b/lib/recorder.js @@ -210,7 +210,7 @@ var Recorder = exports.Recorder = (function () { /* sample rate */ view.setUint32(24, sampleRate, true); /* byte rate (sample rate * block align) */ - view.setUint32(28, sampleRate * 4, true); + view.setUint32(28, sampleRate * numChannels * 2, true); /* block align (channel count * bytes per sample) */ view.setUint16(32, numChannels * 2, true); /* bits per sample */ diff --git a/src/recorder.js b/src/recorder.js index 68ca8ca6..5004c9c5 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -173,7 +173,7 @@ export class Recorder { /* sample rate */ view.setUint32(24, sampleRate, true); /* byte rate (sample rate * block align) */ - view.setUint32(28, sampleRate * 4, true); + view.setUint32(28, sampleRate * numChannels * 2, true); /* block align (channel count * bytes per sample) */ view.setUint16(32, numChannels * 2, true); /* bits per sample */ From 660de5c48ea3b0a32143b6d5cf7a49ef2933c77f Mon Sep 17 00:00:00 2001 From: Saqib Shaikh Date: Fri, 8 Jan 2016 20:27:32 +0000 Subject: [PATCH 2/3] Updating sample to work with Firefox --- examples/example_simple_exportwav.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_simple_exportwav.html b/examples/example_simple_exportwav.html index a28bda64..bd82c7f5 100644 --- a/examples/example_simple_exportwav.html +++ b/examples/example_simple_exportwav.html @@ -86,7 +86,7 @@

Log

try { // webkit shim window.AudioContext = window.AudioContext || window.webkitAudioContext; - navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia; + navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; window.URL = window.URL || window.webkitURL; audio_context = new AudioContext; From 603c7f6ce747ed0f38334d2ada3c6ec9731b2d10 Mon Sep 17 00:00:00 2001 From: Saqib Shaikh Date: Fri, 8 Jan 2016 20:52:58 +0000 Subject: [PATCH 3/3] Updating readme to include details of sampleRate and numChannels settings --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3830a91d..786ed8e2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Recorder.js +# Recorder.js ## A plugin for recording/exporting the output of Web Audio API nodes @@ -18,6 +18,8 @@ Creates a recorder instance. - **bufferLen** - The length of the buffer that the internal JavaScriptNode uses to capture the audio. Can be tweaked if experiencing performance issues. Defaults to 4096. - **callback** - A default callback to be used with `exportWAV`. - **type** - The type of the Blob generated by `exportWAV`. Defaults to 'audio/wav'. +- **sampleRate** - The sample rate. +- **numChannels** - Determines whether audio is mono (1) or stereo (2). Defaults to 2. --------- #### Instance Methods