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 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/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; 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 */