Git Product home page Git Product logo

audiorecorder's Introduction

AudioRecorder

AudioRecorder [seeks to be] a cross platform javascript utility for recording and playing audio in all major browsers. The clips that AudioRecorder produces contain both raw wave audio data and speex encoded data. Included with AudioRecorder is a utility for encoding raw samples to speex (Codec.encode(samples)) and decoding from speex (Codec.decode(speex)). If you are uploading audio data to a server, upload only the speex data and reconstruct the samples client side later for playback.

To use AudioRecorder:

  1. Include the script build/release/audiorecorder.js

That will look something like: <script type="text/javscript" src="audiorecorder.min.js"></script>

This creates the AudioRecorder object for you but does not initialize it. It also creates the Clip object.

  1. Call AudioRecorder.init(config);

Config is an object like this: var config = { 'worker_path': 'worker.min.js' };

This will request the user's permission to access their microphone.

  1. You can now use the entire AudioRecorder and Clip APIs. Hooray!

AudioRecorder API

The best documentation is the code itself. Have a look at src/audiorecorder/main.js?

You will also find that examples/recorder.html (src) does a very nice job of demonstrating the API.

AudioRecorder.init(config);

Initializes the AudioRecorder.

config is an object like this: var config = { 'worker_path': 'worker.min.js' };

AudioRecorder.record();

Starts recording to the current clip.

AudioRecorder.stopRecording(cb);

Stops recording and passes the newly created Clip object to the callback function cb

I'll say that again for emphasis. This is where Clip objects come from. This is how you get inputs for the Clip API.

AudioRecorder.clear();

Clears the current clip back to empty

AudioRecorder.playClip(clip, inHowLong, offset);

Plays clip starting from the appropriate position at the appropriate time. clip is a Clip object. inHowLong and offset are in milliseconds.

AudioRecorder.stopPlaying();

Stops all currently playing clips.

AudioRecorder.isRecording();

Returns True if currently recording, False otherwise

Clip API

The best documentation is the code itself. Have a look at src/common/clip.js?

clip.samples

An array of samples representing the audio signal

clip.speex

The speex encoding of the audio signal. If you have to save something server side, save this.

The following methods and more are provided by the Clip object. Long running methods like createFromSpeex should not be called directly since they will cause the browser to hang while they run. Instead they should be called only in a web worker, for instance by the AudioRecorder API.

Clip.create()

Creates a new empty clip object

Clip.createFromSamples(samples)

Creates a new clip object from the provided samples

Clip.createFromSamples(speex)

Creates a new clip object from the provided speex encoded data

Clip.getLength(clip)

Returns the length of clip in milliseconds

And more! Take a look at src/common/clip.js for the full API.

Codec API

Codec.encode(samples)

Returns a buffer containing the speex data representing the audio signal

Codec.decode(speex)

Returns a buffer containing the PCM data representing the audio signal

Thanks

AudioRecorder builds on an emscripten compiled speex codec jpemartins/speex.js and takes many lessons from mattdiamond/Recorderjs and jwagener/recorder.js. I am developing AudioRecorder primarily as part of Teach Everyone, but am open sourcing it separately with the hope that it is more generally useful.

audiorecorder's People

Contributors

dbieber avatar moizj00 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.