index.js
function start (timeslice) {
    if (this.state !== 'inactive') {
      return this.em.dispatchEvent(error('start'))
    }

    this.state = 'recording'

    if (!context) {
      context = new AudioContext()
    }
    this.clone = this.stream.clone()
    var input = context.createMediaStreamSource(this.clone)

    if (!processor) {
      processor = context.createScriptProcessor(2048, 1, 1)
    }

    var recorder = this
    processor.onaudioprocess = function (e) {
      if (recorder.state === 'recording') {
        recorder.encoder.postMessage([
          'encode', e.inputBuffer.getChannelData(0)
        ])
      }
    }

    input.connect(processor)
    processor.connect(context.destination)

    this.em.dispatchEvent(new Event('start'))

    if (timeslice) {
      this.slicing = setInterval(function () {
        if (recorder.state === 'recording') recorder.requestData()
      }, timeslice)
    }

    return undefined
  }
function start (timeslice) {
    if (this.state !== 'inactive') {
      return this.em.dispatchEvent(error('start'))
    }

    this.state = 'recording'

    if (!context) {
      context = new AudioContext()
    }
    this.clone = this.stream.clone()
    var input = context.createMediaStreamSource(this.clone)

    if (!processor) {
      processor = context.createScriptProcessor(2048, 1, 1)
    }

    var recorder = this
    processor.onaudioprocess = function (e) {
      if (recorder.state === 'recording') {
        recorder.encoder.postMessage([
          'encode', e.inputBuffer.getChannelData(0)
        ])
      }
    }

    input.connect(processor)
    processor.connect(context.destination)

    this.em.dispatchEvent(new Event('start'))

    if (timeslice) {
      this.slicing = setInterval(function () {
        if (recorder.state === 'recording') recorder.requestData()
      }, timeslice)
    }

    return undefined
  }
function start ( timeslice ) { if ( this . state !== 'inactive' ) { return this . em . dispatchEvent ( error ( 'start' ) ) } this . state = 'recording' if ( ! context ) { context = new AudioContext ( ) } this . clone = this . stream . clone ( ) var input = context . createMediaStreamSource ( this . clone ) if ( ! processor ) { processor = context . createScriptProcessor ( 2048 , 1 , 1 ) } var recorder = this processor . onaudioprocess = function ( e ) { if ( recorder . state === 'recording' ) { recorder . encoder . postMessage ( [ 'encode' , e . inputBuffer . getChannelData ( 0 ) ] ) } } input . connect ( processor ) processor . connect ( context . destination ) this . em . dispatchEvent ( new Event ( 'start' ) ) if ( timeslice ) { this . slicing = setInterval ( function ( ) { if ( recorder . state === 'recording' ) recorder . requestData ( ) } , timeslice ) } return undefined }
Begins recording media.

@param {number} [timeslice] The milliseconds to record into each `Blob`.
If this parameter isn’t included, single `Blob`
will be recorded.

@return {undefined}

@example
recordButton.addEventListener('click', function () {
recorder.start()
})
Begins recording media .