diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6060f82c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp +.DS-Store diff --git a/README.md b/README.md index 3830a91d..77be1db0 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ Creates a recorder instance. - **workerPath** - Path to recorder.js worker script. Defaults to 'js/recorderjs/recorderWorker.js' - **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'. +- **callback** - A default callback to be used with `exportAudio`. +- **type** - The type of the Blob generated by `exportAudio`. Defaults to 'audio/wav'. --------- #### Instance Methods @@ -31,7 +31,7 @@ Pretty self-explanatory... **record** will begin capturing audio and **stop** wi This will clear the recording. - rec.exportWAV([callback][, type]) + rec.exportAudio([callback][, type]) This will generate a Blob object containing the recording in WAV format. The callback will be called with the Blob as its sole argument. If a callback is not specified, the default callback (as defined in the config) will be used. If no default has been set, an error will be thrown. diff --git a/recorderWorkerMP3.js b/recorderWorkerMP3.js index a8c6dcc0..c91151eb 100644 --- a/recorderWorkerMP3.js +++ b/recorderWorkerMP3.js @@ -21,6 +21,11 @@ this.onmessage = function(e) { } }; +// The initilization default sample rate of the input audio at 44k +// and scaled it down to 22k output. Not sure why this is necessary but is +// needed for the sound to come out right. +// The channels is set to mono and listenning to channel 1 which is the left channel. +// There is some problem with stereo channel support. function init(config) { if (!config) { config = {}; @@ -43,6 +48,9 @@ function record(buffer) { recLength += mp3data.data.length; } +// Similar to the original exportWAV, it grabs the mp3 data from Lame encoder +// object and build an mp3 blob with it. +// When done, it posts the audio blob message to the worker. function exportAudio() { var mp3data = Lame.encode_flush(mp3codec); @@ -59,6 +67,8 @@ function exportAudio() { this.postMessage(audioBlob); } +// Close the Lame encoder object stream, empty out the data in buffer and +// reset the buffer length stored. function clear() { Lame.close(mp3codec); mp3codec = null;