Coder Social home page Coder Social logo

wav-recorder's Introduction

wav-recorder

Introduction

PhoneGap Cordova Plugin for Android Platform. Records uncompressed audio data to disk as WAV format. The audio buffer is accessible from the webview, thus it is possible ro render to the client the audio data in real time.

Installation

Using the Cordova Command-line Interface:

cordova plugin add https://github.com/petrica/wav-recorder.git

Initialize Recorder

var recorder = new martinescu.Recorder(src, [config], [statusCallback], [bufferCallback]);
  • src - file to write the audio data to, you should use Recorder.location() to work out the exact path after creation
  • config - configure capture format
    • sampleRate - sample rate: 44100, 22050, 11025, 8000
    • channels - for now only single channel recording is available: 1 or 2
    • encoding - this is the bit rate of the recording: 8 or 16
  • statusCallback - callback for recorder status change, including errors. Receives two parameters: first is the status code, the second is the error message, on error.
  • bufferCallback - callback for receiving the current recorder raw audio data

Sample Initialization

// status callback 
var statusCallback = function (mediaStatus, error) {
  if (martinescu.Recorder.STATUS_ERROR == mediaStatus) {
    alert(error);
  }
}

// buffer callback
var bufferCallback = function (buffer) {
  console.log(buffer);
}

var recorder = new martinescu.Recorder('/record.wav', { sampleRate: 22050 }, statusCallback, bufferCallback);

Start Recording

Start recording audio data:

recorder.record();

Stop recording

recorder.stop();

Record for a fixed amount of time

recorder.recordForMillis(durationMilliseconds);

Use the statusCallback to determine when the audio recording has stopped.

Get file location

Find the path of the created wav file as a local absolute path

recorder.location();

Release Recorder

When done with the recorder, call release() in order to free allocated memory.

recorder.release();

Media Status

Recorder.STATUS_INITIALIZING = 'INITIALIZING';
Recorder.STATUS_READY = 'READY';
Recorder.STATUS_RECORDING = 'RECORDING';
Recorder.STATUS_ERROR = 'ERROR';
Recorder.STATUS_STOPPED = 'STOPPED';

wav-recorder's People

Contributors

petrica avatar

Watchers

James Cloos 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.