Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ This will pass the recorded stereo buffer (as an array of two Float32Arrays, for
}

This sample code will play back the stereo buffer.
More simply:

rec.getAudioBuffer([callback])

This will pass the recorded AudioBuffer to the callback.

function getAudioBufferCallback( buffer ) {
var newSource = audioContext.createBufferSource();
newSource.buffer = newBuffer;
newSource.connect( audioContext.destination );
newSource.start(0);
}

This sample code will also play back the stereo buffer.



rec.configure(config)
Expand All @@ -73,4 +88,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 changes: 10 additions & 0 deletions recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@
currCallback = cb || config.callback;
worker.postMessage({ command: 'getBuffer' })
}

this.getAudioBuffer = function (cb, context) {
var ctx = context || this.context
this.getBuffer(function (buffers) {
var newBuffer = ctx.createBuffer(2, buffers[0].length, ctx.sampleRate);
newBuffer.getChannelData(0).set(buffers[0]);
newBuffer.getChannelData(1).set(buffers[1]);
cb(newBuffer)
})
}

this.exportWAV = function(cb, type){
currCallback = cb || config.callback;
Expand Down