(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AV = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Asset, BufferSource, Decoder, Demuxer, EventEmitter, FileSource, HTTPSource,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('./core/events');

  HTTPSource = require('./sources/node/http');

  FileSource = require('./sources/node/file');

  BufferSource = require('./sources/buffer');

  Demuxer = require('./demuxer');

  Decoder = require('./decoder');

  Asset = (function(superClass) {
    extend(Asset, superClass);

    function Asset(source) {
      this.source = source;
      this._decode = bind(this._decode, this);
      this.findDecoder = bind(this.findDecoder, this);
      this.probe = bind(this.probe, this);
      this.buffered = 0;
      this.duration = null;
      this.format = null;
      this.metadata = null;
      this.active = false;
      this.demuxer = null;
      this.decoder = null;
      this.source.once('data', this.probe);
      this.source.on('error', (function(_this) {
        return function(err) {
          _this.emit('error', err);
          return _this.stop();
        };
      })(this));
      this.source.on('progress', (function(_this) {
        return function(buffered) {
          _this.buffered = buffered;
          return _this.emit('buffer', _this.buffered);
        };
      })(this));
    }

    Asset.fromURL = function(url, opts) {
      return new Asset(new HTTPSource(url, opts));
    };

    Asset.fromFile = function(file) {
      return new Asset(new FileSource(file));
    };

    Asset.fromBuffer = function(buffer) {
      return new Asset(new BufferSource(buffer));
    };

    Asset.prototype.start = function(decode) {
      if (this.active) {
        return;
      }
      if (decode != null) {
        this.shouldDecode = decode;
      }
      if (this.shouldDecode == null) {
        this.shouldDecode = true;
      }
      this.active = true;
      this.source.start();
      if (this.decoder && this.shouldDecode) {
        return this._decode();
      }
    };

    Asset.prototype.stop = function() {
      if (!this.active) {
        return;
      }
      this.active = false;
      return this.source.pause();
    };

    Asset.prototype.get = function(event, callback) {
      if (event !== 'format' && event !== 'duration' && event !== 'metadata') {
        return;
      }
      if (this[event] != null) {
        return callback(this[event]);
      } else {
        this.once(event, (function(_this) {
          return function(value) {
            _this.stop();
            return callback(value);
          };
        })(this));
        return this.start();
      }
    };

    Asset.prototype.decodePacket = function() {
      return this.decoder.decode();
    };

    Asset.prototype.decodeToBuffer = function(callback) {
      var chunks, dataHandler, length;
      length = 0;
      chunks = [];
      this.on('data', dataHandler = function(chunk) {
        length += chunk.length;
        return chunks.push(chunk);
      });
      this.once('end', function() {
        var buf, chunk, j, len, offset;
        buf = new Float32Array(length);
        offset = 0;
        for (j = 0, len = chunks.length; j < len; j++) {
          chunk = chunks[j];
          buf.set(chunk, offset);
          offset += chunk.length;
        }
        this.off('data', dataHandler);
        return callback(buf);
      });
      return this.start();
    };

    Asset.prototype.probe = function(chunk) {
      var demuxer;
      if (!this.active) {
        return;
      }
      demuxer = Demuxer.find(chunk);
      if (!demuxer) {
        return this.emit('error', 'A demuxer for this container was not found.');
      }
      this.demuxer = new demuxer(this.source, chunk);
      this.demuxer.on('format', this.findDecoder);
      this.demuxer.on('duration', (function(_this) {
        return function(duration) {
          _this.duration = duration;
          return _this.emit('duration', _this.duration);
        };
      })(this));
      this.demuxer.on('metadata', (function(_this) {
        return function(metadata) {
          _this.metadata = metadata;
          return _this.emit('metadata', _this.metadata);
        };
      })(this));
      return this.demuxer.on('error', (function(_this) {
        return function(err) {
          _this.emit('error', err);
          return _this.stop();
        };
      })(this));
    };

    Asset.prototype.findDecoder = function(format) {
      var decoder, div;
      this.format = format;
      if (!this.active) {
        return;
      }
      this.emit('format', this.format);
      decoder = Decoder.find(this.format.formatID);
      if (!decoder) {
        return this.emit('error', "A decoder for " + this.format.formatID + " was not found.");
      }
      this.decoder = new decoder(this.demuxer, this.format);
      if (this.format.floatingPoint) {
        this.decoder.on('data', (function(_this) {
          return function(buffer) {
            return _this.emit('data', buffer);
          };
        })(this));
      } else {
        div = Math.pow(2, this.format.bitsPerChannel - 1);
        this.decoder.on('data', (function(_this) {
          return function(buffer) {
            var buf, i, j, len, sample;
            buf = new Float32Array(buffer.length);
            for (i = j = 0, len = buffer.length; j < len; i = ++j) {
              sample = buffer[i];
              buf[i] = sample / div;
            }
            return _this.emit('data', buf);
          };
        })(this));
      }
      this.decoder.on('error', (function(_this) {
        return function(err) {
          _this.emit('error', err);
          return _this.stop();
        };
      })(this));
      this.decoder.on('end', (function(_this) {
        return function() {
          return _this.emit('end');
        };
      })(this));
      this.emit('decodeStart');
      if (this.shouldDecode) {
        return this._decode();
      }
    };

    Asset.prototype._decode = function() {
      while (this.decoder.decode() && this.active) {
        continue;
      }
      if (this.active) {
        return this.decoder.once('data', this._decode);
      }
    };

    Asset.prototype.destroy = function() {
      var ref, ref1, ref2;
      this.stop();
      if ((ref = this.demuxer) != null) {
        ref.off();
      }
      if ((ref1 = this.decoder) != null) {
        ref1.off();
      }
      if ((ref2 = this.source) != null) {
        ref2.off();
      }
      return this.off();
    };

    return Asset;

  })(EventEmitter);

  module.exports = Asset;

}).call(this);

},{"./core/events":8,"./decoder":11,"./demuxer":14,"./sources/buffer":31,"./sources/node/file":29,"./sources/node/http":30}],2:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var key, ref, val;

  ref = require('./aurora_base');
  for (key in ref) {
    val = ref[key];
    exports[key] = val;
  }

  require('./demuxers/caf');

  require('./demuxers/m4a');

  require('./demuxers/aiff');

  require('./demuxers/wave');

  require('./demuxers/au');

  require('./decoders/lpcm');

  require('./decoders/xlaw');

}).call(this);

},{"./aurora_base":3,"./decoders/lpcm":12,"./decoders/xlaw":13,"./demuxers/aiff":15,"./demuxers/au":16,"./demuxers/caf":17,"./demuxers/m4a":18,"./demuxers/wave":19}],3:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  exports.Base = require('./core/base');

  exports.Buffer = require('./core/buffer');

  exports.BufferList = require('./core/bufferlist');

  exports.Stream = require('./core/stream');

  exports.Bitstream = require('./core/bitstream');

  exports.EventEmitter = require('./core/events');

  exports.UnderflowError = require('./core/underflow');

  exports.HTTPSource = require('./sources/node/http');

  exports.FileSource = require('./sources/node/file');

  exports.BufferSource = require('./sources/buffer');

  exports.Demuxer = require('./demuxer');

  exports.Decoder = require('./decoder');

  exports.AudioDevice = require('./device');

  exports.Asset = require('./asset');

  exports.Player = require('./player');

  exports.Filter = require('./filter');

  exports.VolumeFilter = require('./filters/volume');

  exports.BalanceFilter = require('./filters/balance');

}).call(this);

},{"./asset":1,"./core/base":4,"./core/bitstream":5,"./core/buffer":6,"./core/bufferlist":7,"./core/events":8,"./core/stream":9,"./core/underflow":10,"./decoder":11,"./demuxer":14,"./device":20,"./filter":24,"./filters/balance":25,"./filters/volume":26,"./player":27,"./sources/buffer":31,"./sources/node/file":29,"./sources/node/http":30}],4:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Base,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty,
    indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  Base = (function() {
    var fnTest;

    function Base() {}

    fnTest = /\b_super\b/;

    Base.extend = function(prop) {
      var Class, _super, fn, key, keys, ref;
      Class = (function(superClass) {
        extend(Class, superClass);

        function Class() {
          return Class.__super__.constructor.apply(this, arguments);
        }

        return Class;

      })(this);
      if (typeof prop === 'function') {
        keys = Object.keys(Class.prototype);
        prop.call(Class, Class);
        prop = {};
        ref = Class.prototype;
        for (key in ref) {
          fn = ref[key];
          if (indexOf.call(keys, key) < 0) {
            prop[key] = fn;
          }
        }
      }
      _super = Class.__super__;
      for (key in prop) {
        fn = prop[key];
        if (typeof fn === 'function' && fnTest.test(fn)) {
          (function(key, fn) {
            return Class.prototype[key] = function() {
              var ret, tmp;
              tmp = this._super;
              this._super = _super[key];
              ret = fn.apply(this, arguments);
              this._super = tmp;
              return ret;
            };
          })(key, fn);
        } else {
          Class.prototype[key] = fn;
        }
      }
      return Class;
    };

    return Base;

  })();

  module.exports = Base;

}).call(this);

},{}],5:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Bitstream;

  Bitstream = (function() {
    function Bitstream(stream) {
      this.stream = stream;
      this.bitPosition = 0;
    }

    Bitstream.prototype.copy = function() {
      var result;
      result = new Bitstream(this.stream.copy());
      result.bitPosition = this.bitPosition;
      return result;
    };

    Bitstream.prototype.offset = function() {
      return 8 * this.stream.offset + this.bitPosition;
    };

    Bitstream.prototype.available = function(bits) {
      return this.stream.available((bits + 8 - this.bitPosition) / 8);
    };

    Bitstream.prototype.advance = function(bits) {
      var pos;
      pos = this.bitPosition + bits;
      this.stream.advance(pos >> 3);
      return this.bitPosition = pos & 7;
    };

    Bitstream.prototype.rewind = function(bits) {
      var pos;
      pos = this.bitPosition - bits;
      this.stream.rewind(Math.abs(pos >> 3));
      return this.bitPosition = pos & 7;
    };

    Bitstream.prototype.seek = function(offset) {
      var curOffset;
      curOffset = this.offset();
      if (offset > curOffset) {
        return this.advance(offset - curOffset);
      } else if (offset < curOffset) {
        return this.rewind(curOffset - offset);
      }
    };

    Bitstream.prototype.align = function() {
      if (this.bitPosition !== 0) {
        this.bitPosition = 0;
        return this.stream.advance(1);
      }
    };

    Bitstream.prototype.read = function(bits, signed) {
      var a, a0, a1, a2, a3, a4, mBits;
      if (bits === 0) {
        return 0;
      }
      mBits = bits + this.bitPosition;
      if (mBits <= 8) {
        a = ((this.stream.peekUInt8() << this.bitPosition) & 0xff) >>> (8 - bits);
      } else if (mBits <= 16) {
        a = ((this.stream.peekUInt16() << this.bitPosition) & 0xffff) >>> (16 - bits);
      } else if (mBits <= 24) {
        a = ((this.stream.peekUInt24() << this.bitPosition) & 0xffffff) >>> (24 - bits);
      } else if (mBits <= 32) {
        a = (this.stream.peekUInt32() << this.bitPosition) >>> (32 - bits);
      } else if (mBits <= 40) {
        a0 = this.stream.peekUInt8(0) * 0x0100000000;
        a1 = this.stream.peekUInt8(1) << 24 >>> 0;
        a2 = this.stream.peekUInt8(2) << 16;
        a3 = this.stream.peekUInt8(3) << 8;
        a4 = this.stream.peekUInt8(4);
        a = a0 + a1 + a2 + a3 + a4;
        a %= Math.pow(2, 40 - this.bitPosition);
        a = Math.floor(a / Math.pow(2, 40 - this.bitPosition - bits));
      } else {
        throw new Error("Too many bits!");
      }
      if (signed) {
        if (mBits < 32) {
          if (a >>> (bits - 1)) {
            a = ((1 << bits >>> 0) - a) * -1;
          }
        } else {
          if (a / Math.pow(2, bits - 1) | 0) {
            a = (Math.pow(2, bits) - a) * -1;
          }
        }
      }
      this.advance(bits);
      return a;
    };

    Bitstream.prototype.peek = function(bits, signed) {
      var a, a0, a1, a2, a3, a4, mBits;
      if (bits === 0) {
        return 0;
      }
      mBits = bits + this.bitPosition;
      if (mBits <= 8) {
        a = ((this.stream.peekUInt8() << this.bitPosition) & 0xff) >>> (8 - bits);
      } else if (mBits <= 16) {
        a = ((this.stream.peekUInt16() << this.bitPosition) & 0xffff) >>> (16 - bits);
      } else if (mBits <= 24) {
        a = ((this.stream.peekUInt24() << this.bitPosition) & 0xffffff) >>> (24 - bits);
      } else if (mBits <= 32) {
        a = (this.stream.peekUInt32() << this.bitPosition) >>> (32 - bits);
      } else if (mBits <= 40) {
        a0 = this.stream.peekUInt8(0) * 0x0100000000;
        a1 = this.stream.peekUInt8(1) << 24 >>> 0;
        a2 = this.stream.peekUInt8(2) << 16;
        a3 = this.stream.peekUInt8(3) << 8;
        a4 = this.stream.peekUInt8(4);
        a = a0 + a1 + a2 + a3 + a4;
        a %= Math.pow(2, 40 - this.bitPosition);
        a = Math.floor(a / Math.pow(2, 40 - this.bitPosition - bits));
      } else {
        throw new Error("Too many bits!");
      }
      if (signed) {
        if (mBits < 32) {
          if (a >>> (bits - 1)) {
            a = ((1 << bits >>> 0) - a) * -1;
          }
        } else {
          if (a / Math.pow(2, bits - 1) | 0) {
            a = (Math.pow(2, bits) - a) * -1;
          }
        }
      }
      return a;
    };

    Bitstream.prototype.readLSB = function(bits, signed) {
      var a, mBits;
      if (bits === 0) {
        return 0;
      }
      if (bits > 40) {
        throw new Error("Too many bits!");
      }
      mBits = bits + this.bitPosition;
      a = (this.stream.peekUInt8(0)) >>> this.bitPosition;
      if (mBits > 8) {
        a |= (this.stream.peekUInt8(1)) << (8 - this.bitPosition);
      }
      if (mBits > 16) {
        a |= (this.stream.peekUInt8(2)) << (16 - this.bitPosition);
      }
      if (mBits > 24) {
        a += (this.stream.peekUInt8(3)) << (24 - this.bitPosition) >>> 0;
      }
      if (mBits > 32) {
        a += (this.stream.peekUInt8(4)) * Math.pow(2, 32 - this.bitPosition);
      }
      if (mBits >= 32) {
        a %= Math.pow(2, bits);
      } else {
        a &= (1 << bits) - 1;
      }
      if (signed) {
        if (mBits < 32) {
          if (a >>> (bits - 1)) {
            a = ((1 << bits >>> 0) - a) * -1;
          }
        } else {
          if (a / Math.pow(2, bits - 1) | 0) {
            a = (Math.pow(2, bits) - a) * -1;
          }
        }
      }
      this.advance(bits);
      return a;
    };

    Bitstream.prototype.peekLSB = function(bits, signed) {
      var a, mBits;
      if (bits === 0) {
        return 0;
      }
      if (bits > 40) {
        throw new Error("Too many bits!");
      }
      mBits = bits + this.bitPosition;
      a = (this.stream.peekUInt8(0)) >>> this.bitPosition;
      if (mBits > 8) {
        a |= (this.stream.peekUInt8(1)) << (8 - this.bitPosition);
      }
      if (mBits > 16) {
        a |= (this.stream.peekUInt8(2)) << (16 - this.bitPosition);
      }
      if (mBits > 24) {
        a += (this.stream.peekUInt8(3)) << (24 - this.bitPosition) >>> 0;
      }
      if (mBits > 32) {
        a += (this.stream.peekUInt8(4)) * Math.pow(2, 32 - this.bitPosition);
      }
      if (mBits >= 32) {
        a %= Math.pow(2, bits);
      } else {
        a &= (1 << bits) - 1;
      }
      if (signed) {
        if (mBits < 32) {
          if (a >>> (bits - 1)) {
            a = ((1 << bits >>> 0) - a) * -1;
          }
        } else {
          if (a / Math.pow(2, bits - 1) | 0) {
            a = (Math.pow(2, bits) - a) * -1;
          }
        }
      }
      return a;
    };

    return Bitstream;

  })();

  module.exports = Bitstream;

}).call(this);

},{}],6:[function(require,module,exports){
(function (global){
// Generated by CoffeeScript 1.11.1
(function() {
  var AVBuffer;

  AVBuffer = (function() {
    var BlobBuilder, URL;

    function AVBuffer(input) {
      var ref;
      if (input instanceof Uint8Array) {
        this.data = input;
      } else if (input instanceof ArrayBuffer || Array.isArray(input) || typeof input === 'number' || ((ref = global.Buffer) != null ? ref.isBuffer(input) : void 0)) {
        this.data = new Uint8Array(input);
      } else if (input.buffer instanceof ArrayBuffer) {
        this.data = new Uint8Array(input.buffer, input.byteOffset, input.length * input.BYTES_PER_ELEMENT);
      } else if (input instanceof AVBuffer) {
        this.data = input.data;
      } else {
        throw new Error("Constructing buffer with unknown type.");
      }
      this.length = this.data.length;
      this.next = null;
      this.prev = null;
    }

    AVBuffer.allocate = function(size) {
      return new AVBuffer(size);
    };

    AVBuffer.prototype.copy = function() {
      return new AVBuffer(new Uint8Array(this.data));
    };

    AVBuffer.prototype.slice = function(position, length) {
      if (length == null) {
        length = this.length;
      }
      if (position === 0 && length >= this.length) {
        return new AVBuffer(this.data);
      } else {
        return new AVBuffer(this.data.subarray(position, position + length));
      }
    };

    BlobBuilder = global.BlobBuilder || global.MozBlobBuilder || global.WebKitBlobBuilder;

    URL = global.URL || global.webkitURL || global.mozURL;

    AVBuffer.makeBlob = function(data, type) {
      var bb;
      if (type == null) {
        type = 'application/octet-stream';
      }
      try {
        return new Blob([data], {
          type: type
        });
      } catch (error) {}
      if (BlobBuilder != null) {
        bb = new BlobBuilder;
        bb.append(data);
        return bb.getBlob(type);
      }
      return null;
    };

    AVBuffer.makeBlobURL = function(data, type) {
      return URL != null ? URL.createObjectURL(this.makeBlob(data, type)) : void 0;
    };

    AVBuffer.revokeBlobURL = function(url) {
      return URL != null ? URL.revokeObjectURL(url) : void 0;
    };

    AVBuffer.prototype.toBlob = function() {
      return AVBuffer.makeBlob(this.data.buffer);
    };

    AVBuffer.prototype.toBlobURL = function() {
      return AVBuffer.makeBlobURL(this.data.buffer);
    };

    return AVBuffer;

  })();

  module.exports = AVBuffer;

}).call(this);

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})

},{}],7:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var BufferList;

  BufferList = (function() {
    function BufferList() {
      this.first = null;
      this.last = null;
      this.numBuffers = 0;
      this.availableBytes = 0;
      this.availableBuffers = 0;
    }

    BufferList.prototype.copy = function() {
      var result;
      result = new BufferList;
      result.first = this.first;
      result.last = this.last;
      result.numBuffers = this.numBuffers;
      result.availableBytes = this.availableBytes;
      result.availableBuffers = this.availableBuffers;
      return result;
    };

    BufferList.prototype.append = function(buffer) {
      var ref;
      buffer.prev = this.last;
      if ((ref = this.last) != null) {
        ref.next = buffer;
      }
      this.last = buffer;
      if (this.first == null) {
        this.first = buffer;
      }
      this.availableBytes += buffer.length;
      this.availableBuffers++;
      return this.numBuffers++;
    };

    BufferList.prototype.advance = function() {
      if (this.first) {
        this.availableBytes -= this.first.length;
        this.availableBuffers--;
        this.first = this.first.next;
        return this.first != null;
      }
      return false;
    };

    BufferList.prototype.rewind = function() {
      var ref;
      if (this.first && !this.first.prev) {
        return false;
      }
      this.first = ((ref = this.first) != null ? ref.prev : void 0) || this.last;
      if (this.first) {
        this.availableBytes += this.first.length;
        this.availableBuffers++;
      }
      return this.first != null;
    };

    BufferList.prototype.reset = function() {
      var results;
      results = [];
      while (this.rewind()) {
        continue;
      }
      return results;
    };

    return BufferList;

  })();

  module.exports = BufferList;

}).call(this);

},{}],8:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Base, EventEmitter,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty,
    slice = [].slice;

  Base = require('./base');

  EventEmitter = (function(superClass) {
    extend(EventEmitter, superClass);

    function EventEmitter() {
      return EventEmitter.__super__.constructor.apply(this, arguments);
    }

    EventEmitter.prototype.on = function(event, fn) {
      var base;
      if (this.events == null) {
        this.events = {};
      }
      if ((base = this.events)[event] == null) {
        base[event] = [];
      }
      return this.events[event].push(fn);
    };

    EventEmitter.prototype.off = function(event, fn) {
      var events, index, ref;
      if (this.events == null) {
        return;
      }
      if ((ref = this.events) != null ? ref[event] : void 0) {
        if (fn != null) {
          index = this.events[event].indexOf(fn);
          if (~index) {
            return this.events[event].splice(index, 1);
          }
        } else {
          return this.events[event];
        }
      } else if (event == null) {
        return events = {};
      }
    };

    EventEmitter.prototype.once = function(event, fn) {
      var cb;
      return this.on(event, cb = function() {
        this.off(event, cb);
        return fn.apply(this, arguments);
      });
    };

    EventEmitter.prototype.emit = function() {
      var args, event, fn, i, len, ref, ref1;
      event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
      if (!((ref = this.events) != null ? ref[event] : void 0)) {
        return;
      }
      ref1 = this.events[event].slice();
      for (i = 0, len = ref1.length; i < len; i++) {
        fn = ref1[i];
        fn.apply(this, args);
      }
    };

    return EventEmitter;

  })(Base);

  module.exports = EventEmitter;

}).call(this);

},{"./base":4}],9:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var AVBuffer, BufferList, Stream, UnderflowError;

  BufferList = require('./bufferlist');

  AVBuffer = require('./buffer');

  UnderflowError = require('./underflow');

  Stream = (function() {
    var buf, decodeString, float32, float64, float64Fallback, float80, int16, int32, int8, nativeEndian, uint16, uint32, uint8;

    buf = new ArrayBuffer(16);

    uint8 = new Uint8Array(buf);

    int8 = new Int8Array(buf);

    uint16 = new Uint16Array(buf);

    int16 = new Int16Array(buf);

    uint32 = new Uint32Array(buf);

    int32 = new Int32Array(buf);

    float32 = new Float32Array(buf);

    if (typeof Float64Array !== "undefined" && Float64Array !== null) {
      float64 = new Float64Array(buf);
    }

    nativeEndian = new Uint16Array(new Uint8Array([0x12, 0x34]).buffer)[0] === 0x3412;

    function Stream(list1) {
      this.list = list1;
      this.localOffset = 0;
      this.offset = 0;
    }

    Stream.fromBuffer = function(buffer) {
      var list;
      list = new BufferList;
      list.append(buffer);
      return new Stream(list);
    };

    Stream.prototype.copy = function() {
      var result;
      result = new Stream(this.list.copy());
      result.localOffset = this.localOffset;
      result.offset = this.offset;
      return result;
    };

    Stream.prototype.available = function(bytes) {
      return bytes <= this.list.availableBytes - this.localOffset;
    };

    Stream.prototype.remainingBytes = function() {
      return this.list.availableBytes - this.localOffset;
    };

    Stream.prototype.advance = function(bytes) {
      if (!this.available(bytes)) {
        throw new UnderflowError();
      }
      this.localOffset += bytes;
      this.offset += bytes;
      while (this.list.first && this.localOffset >= this.list.first.length) {
        this.localOffset -= this.list.first.length;
        this.list.advance();
      }
      return this;
    };

    Stream.prototype.rewind = function(bytes) {
      if (bytes > this.offset) {
        throw new UnderflowError();
      }
      if (!this.list.first) {
        this.list.rewind();
        this.localOffset = this.list.first.length;
      }
      this.localOffset -= bytes;
      this.offset -= bytes;
      while (this.list.first.prev && this.localOffset < 0) {
        this.list.rewind();
        this.localOffset += this.list.first.length;
      }
      return this;
    };

    Stream.prototype.seek = function(position) {
      if (position > this.offset) {
        return this.advance(position - this.offset);
      } else if (position < this.offset) {
        return this.rewind(this.offset - position);
      }
    };

    Stream.prototype.readUInt8 = function() {
      var a;
      if (!this.available(1)) {
        throw new UnderflowError();
      }
      a = this.list.first.data[this.localOffset];
      this.localOffset += 1;
      this.offset += 1;
      if (this.localOffset === this.list.first.length) {
        this.localOffset = 0;
        this.list.advance();
      }
      return a;
    };

    Stream.prototype.peekUInt8 = function(offset) {
      var buffer;
      if (offset == null) {
        offset = 0;
      }
      if (!this.available(offset + 1)) {
        throw new UnderflowError();
      }
      offset = this.localOffset + offset;
      buffer = this.list.first;
      while (buffer) {
        if (buffer.length > offset) {
          return buffer.data[offset];
        }
        offset -= buffer.length;
        buffer = buffer.next;
      }
      return 0;
    };

    Stream.prototype.read = function(bytes, littleEndian) {
      var i, j, k, ref, ref1;
      if (littleEndian == null) {
        littleEndian = false;
      }
      if (littleEndian === nativeEndian) {
        for (i = j = 0, ref = bytes; j < ref; i = j += 1) {
          uint8[i] = this.readUInt8();
        }
      } else {
        for (i = k = ref1 = bytes - 1; k >= 0; i = k += -1) {
          uint8[i] = this.readUInt8();
        }
      }
    };

    Stream.prototype.peek = function(bytes, offset, littleEndian) {
      var i, j, k, ref, ref1;
      if (littleEndian == null) {
        littleEndian = false;
      }
      if (littleEndian === nativeEndian) {
        for (i = j = 0, ref = bytes; j < ref; i = j += 1) {
          uint8[i] = this.peekUInt8(offset + i);
        }
      } else {
        for (i = k = 0, ref1 = bytes; k < ref1; i = k += 1) {
          uint8[bytes - i - 1] = this.peekUInt8(offset + i);
        }
      }
    };

    Stream.prototype.readInt8 = function() {
      this.read(1);
      return int8[0];
    };

    Stream.prototype.peekInt8 = function(offset) {
      if (offset == null) {
        offset = 0;
      }
      this.peek(1, offset);
      return int8[0];
    };

    Stream.prototype.readUInt16 = function(littleEndian) {
      this.read(2, littleEndian);
      return uint16[0];
    };

    Stream.prototype.peekUInt16 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      this.peek(2, offset, littleEndian);
      return uint16[0];
    };

    Stream.prototype.readInt16 = function(littleEndian) {
      this.read(2, littleEndian);
      return int16[0];
    };

    Stream.prototype.peekInt16 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      this.peek(2, offset, littleEndian);
      return int16[0];
    };

    Stream.prototype.readUInt24 = function(littleEndian) {
      if (littleEndian) {
        return this.readUInt16(true) + (this.readUInt8() << 16);
      } else {
        return (this.readUInt16() << 8) + this.readUInt8();
      }
    };

    Stream.prototype.peekUInt24 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      if (littleEndian) {
        return this.peekUInt16(offset, true) + (this.peekUInt8(offset + 2) << 16);
      } else {
        return (this.peekUInt16(offset) << 8) + this.peekUInt8(offset + 2);
      }
    };

    Stream.prototype.readInt24 = function(littleEndian) {
      if (littleEndian) {
        return this.readUInt16(true) + (this.readInt8() << 16);
      } else {
        return (this.readInt16() << 8) + this.readUInt8();
      }
    };

    Stream.prototype.peekInt24 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      if (littleEndian) {
        return this.peekUInt16(offset, true) + (this.peekInt8(offset + 2) << 16);
      } else {
        return (this.peekInt16(offset) << 8) + this.peekUInt8(offset + 2);
      }
    };

    Stream.prototype.readUInt32 = function(littleEndian) {
      this.read(4, littleEndian);
      return uint32[0];
    };

    Stream.prototype.peekUInt32 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      this.peek(4, offset, littleEndian);
      return uint32[0];
    };

    Stream.prototype.readInt32 = function(littleEndian) {
      this.read(4, littleEndian);
      return int32[0];
    };

    Stream.prototype.peekInt32 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      this.peek(4, offset, littleEndian);
      return int32[0];
    };

    Stream.prototype.readFloat32 = function(littleEndian) {
      this.read(4, littleEndian);
      return float32[0];
    };

    Stream.prototype.peekFloat32 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      this.peek(4, offset, littleEndian);
      return float32[0];
    };

    Stream.prototype.readFloat64 = function(littleEndian) {
      this.read(8, littleEndian);
      if (float64) {
        return float64[0];
      } else {
        return float64Fallback();
      }
    };

    float64Fallback = function() {
      var exp, frac, high, low, out, sign;
      low = uint32[0], high = uint32[1];
      if (!high || high === 0x80000000) {
        return 0.0;
      }
      sign = 1 - (high >>> 31) * 2;
      exp = (high >>> 20) & 0x7ff;
      frac = high & 0xfffff;
      if (exp === 0x7ff) {
        if (frac) {
          return 0/0;
        }
        return sign * 2e308;
      }
      exp -= 1023;
      out = (frac | 0x100000) * Math.pow(2, exp - 20);
      out += low * Math.pow(2, exp - 52);
      return sign * out;
    };

    Stream.prototype.peekFloat64 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      this.peek(8, offset, littleEndian);
      if (float64) {
        return float64[0];
      } else {
        return float64Fallback();
      }
    };

    Stream.prototype.readFloat80 = function(littleEndian) {
      this.read(10, littleEndian);
      return float80();
    };

    float80 = function() {
      var a0, a1, exp, high, low, out, sign;
      high = uint32[0], low = uint32[1];
      a0 = uint8[9];
      a1 = uint8[8];
      sign = 1 - (a0 >>> 7) * 2;
      exp = ((a0 & 0x7F) << 8) | a1;
      if (exp === 0 && low === 0 && high === 0) {
        return 0;
      }
      if (exp === 0x7fff) {
        if (low === 0 && high === 0) {
          return sign * 2e308;
        }
        return 0/0;
      }
      exp -= 16383;
      out = low * Math.pow(2, exp - 31);
      out += high * Math.pow(2, exp - 63);
      return sign * out;
    };

    Stream.prototype.peekFloat80 = function(offset, littleEndian) {
      if (offset == null) {
        offset = 0;
      }
      this.peek(10, offset, littleEndian);
      return float80();
    };

    Stream.prototype.readBuffer = function(length) {
      var i, j, ref, result, to;
      result = AVBuffer.allocate(length);
      to = result.data;
      for (i = j = 0, ref = length; j < ref; i = j += 1) {
        to[i] = this.readUInt8();
      }
      return result;
    };

    Stream.prototype.peekBuffer = function(offset, length) {
      var i, j, ref, result, to;
      if (offset == null) {
        offset = 0;
      }
      result = AVBuffer.allocate(length);
      to = result.data;
      for (i = j = 0, ref = length; j < ref; i = j += 1) {
        to[i] = this.peekUInt8(offset + i);
      }
      return result;
    };

    Stream.prototype.readSingleBuffer = function(length) {
      var result;
      result = this.list.first.slice(this.localOffset, length);
      this.advance(result.length);
      return result;
    };

    Stream.prototype.peekSingleBuffer = function(offset, length) {
      var result;
      result = this.list.first.slice(this.localOffset + offset, length);
      return result;
    };

    Stream.prototype.readString = function(length, encoding) {
      if (encoding == null) {
        encoding = 'ascii';
      }
      return decodeString.call(this, 0, length, encoding, true);
    };

    Stream.prototype.peekString = function(offset, length, encoding) {
      if (offset == null) {
        offset = 0;
      }
      if (encoding == null) {
        encoding = 'ascii';
      }
      return decodeString.call(this, offset, length, encoding, false);
    };

    decodeString = function(offset, length, encoding, advance) {
      var b1, b2, b3, b4, bom, c, end, littleEndian, nullEnd, pt, result, w1, w2;
      encoding = encoding.toLowerCase();
      nullEnd = length === null ? 0 : -1;
      if (length == null) {
        length = 2e308;
      }
      end = offset + length;
      result = '';
      switch (encoding) {
        case 'ascii':
        case 'latin1':
          while (offset < end && (c = this.peekUInt8(offset++)) !== nullEnd) {
            result += String.fromCharCode(c);
          }
          break;
        case 'utf8':
        case 'utf-8':
          while (offset < end && (b1 = this.peekUInt8(offset++)) !== nullEnd) {
            if ((b1 & 0x80) === 0) {
              result += String.fromCharCode(b1);
            } else if ((b1 & 0xe0) === 0xc0) {
              b2 = this.peekUInt8(offset++) & 0x3f;
              result += String.fromCharCode(((b1 & 0x1f) << 6) | b2);
            } else if ((b1 & 0xf0) === 0xe0) {
              b2 = this.peekUInt8(offset++) & 0x3f;
              b3 = this.peekUInt8(offset++) & 0x3f;
              result += String.fromCharCode(((b1 & 0x0f) << 12) | (b2 << 6) | b3);
            } else if ((b1 & 0xf8) === 0xf0) {
              b2 = this.peekUInt8(offset++) & 0x3f;
              b3 = this.peekUInt8(offset++) & 0x3f;
              b4 = this.peekUInt8(offset++) & 0x3f;
              pt = (((b1 & 0x0f) << 18) | (b2 << 12) | (b3 << 6) | b4) - 0x10000;
              result += String.fromCharCode(0xd800 + (pt >> 10), 0xdc00 + (pt & 0x3ff));
            }
          }
          break;
        case 'utf16-be':
        case 'utf16be':
        case 'utf16le':
        case 'utf16-le':
        case 'utf16bom':
        case 'utf16-bom':
          switch (encoding) {
            case 'utf16be':
            case 'utf16-be':
              littleEndian = false;
              break;
            case 'utf16le':
            case 'utf16-le':
              littleEndian = true;
              break;
            case 'utf16bom':
            case 'utf16-bom':
              if (length < 2 || (bom = this.peekUInt16(offset)) === nullEnd) {
                if (advance) {
                  this.advance(offset += 2);
                }
                return result;
              }
              littleEndian = bom === 0xfffe;
              offset += 2;
          }
          while (offset < end && (w1 = this.peekUInt16(offset, littleEndian)) !== nullEnd) {
            offset += 2;
            if (w1 < 0xd800 || w1 > 0xdfff) {
              result += String.fromCharCode(w1);
            } else {
              if (w1 > 0xdbff) {
                throw new Error("Invalid utf16 sequence.");
              }
              w2 = this.peekUInt16(offset, littleEndian);
              if (w2 < 0xdc00 || w2 > 0xdfff) {
                throw new Error("Invalid utf16 sequence.");
              }
              result += String.fromCharCode(w1, w2);
              offset += 2;
            }
          }
          if (w1 === nullEnd) {
            offset += 2;
          }
          break;
        default:
          throw new Error("Unknown encoding: " + encoding);
      }
      if (advance) {
        this.advance(offset);
      }
      return result;
    };

    return Stream;

  })();

  module.exports = Stream;

}).call(this);

},{"./buffer":6,"./bufferlist":7,"./underflow":10}],10:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var UnderflowError,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  UnderflowError = (function(superClass) {
    extend(UnderflowError, superClass);

    function UnderflowError() {
      UnderflowError.__super__.constructor.apply(this, arguments);
      this.name = 'UnderflowError';
      this.stack = new Error().stack;
    }

    return UnderflowError;

  })(Error);

  module.exports = UnderflowError;

}).call(this);

},{}],11:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Bitstream, BufferList, Decoder, EventEmitter, Stream, UnderflowError,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('./core/events');

  BufferList = require('./core/bufferlist');

  Stream = require('./core/stream');

  Bitstream = require('./core/bitstream');

  UnderflowError = require('./core/underflow');

  Decoder = (function(superClass) {
    var codecs;

    extend(Decoder, superClass);

    function Decoder(demuxer, format) {
      var list;
      this.demuxer = demuxer;
      this.format = format;
      list = new BufferList;
      this.stream = new Stream(list);
      this.bitstream = new Bitstream(this.stream);
      this.receivedFinalBuffer = false;
      this.waiting = false;
      this.demuxer.on('cookie', (function(_this) {
        return function(cookie) {
          var error;
          try {
            return _this.setCookie(cookie);
          } catch (error1) {
            error = error1;
            return _this.emit('error', error);
          }
        };
      })(this));
      this.demuxer.on('data', (function(_this) {
        return function(chunk) {
          list.append(chunk);
          if (_this.waiting) {
            return _this.decode();
          }
        };
      })(this));
      this.demuxer.on('end', (function(_this) {
        return function() {
          _this.receivedFinalBuffer = true;
          if (_this.waiting) {
            return _this.decode();
          }
        };
      })(this));
      this.init();
    }

    Decoder.prototype.init = function() {};

    Decoder.prototype.setCookie = function(cookie) {};

    Decoder.prototype.readChunk = function() {};

    Decoder.prototype.decode = function() {
      var error, offset, packet;
      this.waiting = !this.receivedFinalBuffer;
      offset = this.bitstream.offset();
      try {
        packet = this.readChunk();
      } catch (error1) {
        error = error1;
        if (!(error instanceof UnderflowError)) {
          this.emit('error', error);
          return false;
        }
      }
      if (packet) {
        this.emit('data', packet);
        if (this.receivedFinalBuffer) {
          this.emit('end');
        }
        return true;
      } else if (!this.receivedFinalBuffer) {
        this.bitstream.seek(offset);
        this.waiting = true;
      } else {
        this.emit('end');
      }
      return false;
    };

    Decoder.prototype.seek = function(timestamp) {
      var seekPoint;
      seekPoint = this.demuxer.seek(timestamp);
      this.stream.seek(seekPoint.offset);
      return seekPoint.timestamp;
    };

    codecs = {};

    Decoder.register = function(id, decoder) {
      return codecs[id] = decoder;
    };

    Decoder.find = function(id) {
      return codecs[id] || null;
    };

    return Decoder;

  })(EventEmitter);

  module.exports = Decoder;

}).call(this);

},{"./core/bitstream":5,"./core/bufferlist":7,"./core/events":8,"./core/stream":9,"./core/underflow":10}],12:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Decoder, LPCMDecoder,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  Decoder = require('../decoder');

  LPCMDecoder = (function(superClass) {
    extend(LPCMDecoder, superClass);

    function LPCMDecoder() {
      this.readChunk = bind(this.readChunk, this);
      return LPCMDecoder.__super__.constructor.apply(this, arguments);
    }

    Decoder.register('lpcm', LPCMDecoder);

    LPCMDecoder.prototype.readChunk = function() {
      var chunkSize, i, j, k, l, littleEndian, m, n, o, output, ref, ref1, ref2, ref3, ref4, ref5, samples, stream;
      stream = this.stream;
      littleEndian = this.format.littleEndian;
      chunkSize = Math.min(4096, stream.remainingBytes());
      samples = chunkSize / (this.format.bitsPerChannel / 8) | 0;
      if (chunkSize < this.format.bitsPerChannel / 8) {
        return null;
      }
      if (this.format.floatingPoint) {
        switch (this.format.bitsPerChannel) {
          case 32:
            output = new Float32Array(samples);
            for (i = j = 0, ref = samples; j < ref; i = j += 1) {
              output[i] = stream.readFloat32(littleEndian);
            }
            break;
          case 64:
            output = new Float64Array(samples);
            for (i = k = 0, ref1 = samples; k < ref1; i = k += 1) {
              output[i] = stream.readFloat64(littleEndian);
            }
            break;
          default:
            throw new Error('Unsupported bit depth.');
        }
      } else {
        switch (this.format.bitsPerChannel) {
          case 8:
            output = new Int8Array(samples);
            for (i = l = 0, ref2 = samples; l < ref2; i = l += 1) {
              output[i] = stream.readInt8();
            }
            break;
          case 16:
            output = new Int16Array(samples);
            for (i = m = 0, ref3 = samples; m < ref3; i = m += 1) {
              output[i] = stream.readInt16(littleEndian);
            }
            break;
          case 24:
            output = new Int32Array(samples);
            for (i = n = 0, ref4 = samples; n < ref4; i = n += 1) {
              output[i] = stream.readInt24(littleEndian);
            }
            break;
          case 32:
            output = new Int32Array(samples);
            for (i = o = 0, ref5 = samples; o < ref5; i = o += 1) {
              output[i] = stream.readInt32(littleEndian);
            }
            break;
          default:
            throw new Error('Unsupported bit depth.');
        }
      }
      return output;
    };

    return LPCMDecoder;

  })(Decoder);

}).call(this);

},{"../decoder":11}],13:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Decoder, XLAWDecoder,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  Decoder = require('../decoder');

  XLAWDecoder = (function(superClass) {
    var BIAS, QUANT_MASK, SEG_MASK, SEG_SHIFT, SIGN_BIT;

    extend(XLAWDecoder, superClass);

    function XLAWDecoder() {
      this.readChunk = bind(this.readChunk, this);
      return XLAWDecoder.__super__.constructor.apply(this, arguments);
    }

    Decoder.register('ulaw', XLAWDecoder);

    Decoder.register('alaw', XLAWDecoder);

    SIGN_BIT = 0x80;

    QUANT_MASK = 0xf;

    SEG_SHIFT = 4;

    SEG_MASK = 0x70;

    BIAS = 0x84;

    XLAWDecoder.prototype.init = function() {
      var i, j, k, seg, t, table, val;
      this.format.bitsPerChannel = 16;
      this.table = table = new Int16Array(256);
      if (this.format.formatID === 'ulaw') {
        for (i = j = 0; j < 256; i = ++j) {
          val = ~i;
          t = ((val & QUANT_MASK) << 3) + BIAS;
          t <<= (val & SEG_MASK) >>> SEG_SHIFT;
          table[i] = val & SIGN_BIT ? BIAS - t : t - BIAS;
        }
      } else {
        for (i = k = 0; k < 256; i = ++k) {
          val = i ^ 0x55;
          t = val & QUANT_MASK;
          seg = (val & SEG_MASK) >>> SEG_SHIFT;
          if (seg) {
            t = (t + t + 1 + 32) << (seg + 2);
          } else {
            t = (t + t + 1) << 3;
          }
          table[i] = val & SIGN_BIT ? t : -t;
        }
      }
    };

    XLAWDecoder.prototype.readChunk = function() {
      var i, j, output, ref, ref1, samples, stream, table;
      ref = this, stream = ref.stream, table = ref.table;
      samples = Math.min(4096, this.stream.remainingBytes());
      if (samples === 0) {
        return;
      }
      output = new Int16Array(samples);
      for (i = j = 0, ref1 = samples; j < ref1; i = j += 1) {
        output[i] = table[stream.readUInt8()];
      }
      return output;
    };

    return XLAWDecoder;

  })(Decoder);

}).call(this);

},{"../decoder":11}],14:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var BufferList, Demuxer, EventEmitter, Stream,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('./core/events');

  BufferList = require('./core/bufferlist');

  Stream = require('./core/stream');

  Demuxer = (function(superClass) {
    var formats;

    extend(Demuxer, superClass);

    Demuxer.probe = function(buffer) {
      return false;
    };

    function Demuxer(source, chunk) {
      var list, received;
      list = new BufferList;
      list.append(chunk);
      this.stream = new Stream(list);
      received = false;
      source.on('data', (function(_this) {
        return function(chunk) {
          var e;
          received = true;
          list.append(chunk);
          try {
            return _this.readChunk(chunk);
          } catch (error) {
            e = error;
            return _this.emit('error', e);
          }
        };
      })(this));
      source.on('error', (function(_this) {
        return function(err) {
          return _this.emit('error', err);
        };
      })(this));
      source.on('end', (function(_this) {
        return function() {
          if (!received) {
            _this.readChunk(chunk);
          }
          return _this.emit('end');
        };
      })(this));
      this.seekPoints = [];
      this.init();
    }

    Demuxer.prototype.init = function() {};

    Demuxer.prototype.readChunk = function(chunk) {};

    Demuxer.prototype.addSeekPoint = function(offset, timestamp) {
      var index;
      index = this.searchTimestamp(timestamp);
      return this.seekPoints.splice(index, 0, {
        offset: offset,
        timestamp: timestamp
      });
    };

    Demuxer.prototype.searchTimestamp = function(timestamp, backward) {
      var high, low, mid, time;
      low = 0;
      high = this.seekPoints.length;
      if (high > 0 && this.seekPoints[high - 1].timestamp < timestamp) {
        return high;
      }
      while (low < high) {
        mid = (low + high) >> 1;
        time = this.seekPoints[mid].timestamp;
        if (time < timestamp) {
          low = mid + 1;
        } else if (time >= timestamp) {
          high = mid;
        }
      }
      if (high > this.seekPoints.length) {
        high = this.seekPoints.length;
      }
      return high;
    };

    Demuxer.prototype.seek = function(timestamp) {
      var index, seekPoint;
      if (this.format && this.format.framesPerPacket > 0 && this.format.bytesPerPacket > 0) {
        seekPoint = {
          timestamp: timestamp,
          offset: this.format.bytesPerPacket * timestamp / this.format.framesPerPacket
        };
        return seekPoint;
      } else {
        index = this.searchTimestamp(timestamp);
        return this.seekPoints[index];
      }
    };

    formats = [];

    Demuxer.register = function(demuxer) {
      return formats.push(demuxer);
    };

    Demuxer.find = function(buffer) {
      var e, format, i, len, offset, stream;
      stream = Stream.fromBuffer(buffer);
      for (i = 0, len = formats.length; i < len; i++) {
        format = formats[i];
        offset = stream.offset;
        try {
          if (format.probe(stream)) {
            return format;
          }
        } catch (error) {
          e = error;
        }
        stream.seek(offset);
      }
      return null;
    };

    return Demuxer;

  })(EventEmitter);

  module.exports = Demuxer;

}).call(this);

},{"./core/bufferlist":7,"./core/events":8,"./core/stream":9}],15:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var AIFFDemuxer, Demuxer,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  Demuxer = require('../demuxer');

  AIFFDemuxer = (function(superClass) {
    extend(AIFFDemuxer, superClass);

    function AIFFDemuxer() {
      return AIFFDemuxer.__super__.constructor.apply(this, arguments);
    }

    Demuxer.register(AIFFDemuxer);

    AIFFDemuxer.probe = function(buffer) {
      var ref;
      return buffer.peekString(0, 4) === 'FORM' && ((ref = buffer.peekString(8, 4)) === 'AIFF' || ref === 'AIFC');
    };

    AIFFDemuxer.prototype.readChunk = function() {
      var buffer, format, offset, ref;
      if (!this.readStart && this.stream.available(12)) {
        if (this.stream.readString(4) !== 'FORM') {
          return this.emit('error', 'Invalid AIFF.');
        }
        this.fileSize = this.stream.readUInt32();
        this.fileType = this.stream.readString(4);
        this.readStart = true;
        if ((ref = this.fileType) !== 'AIFF' && ref !== 'AIFC') {
          return this.emit('error', 'Invalid AIFF.');
        }
      }
      while (this.stream.available(1)) {
        if (!this.readHeaders && this.stream.available(8)) {
          this.type = this.stream.readString(4);
          this.len = this.stream.readUInt32();
        }
        switch (this.type) {
          case 'COMM':
            if (!this.stream.available(this.len)) {
              return;
            }
            this.format = {
              formatID: 'lpcm',
              channelsPerFrame: this.stream.readUInt16(),
              sampleCount: this.stream.readUInt32(),
              bitsPerChannel: this.stream.readUInt16(),
              sampleRate: this.stream.readFloat80(),
              framesPerPacket: 1,
              littleEndian: false,
              floatingPoint: false
            };
            this.format.bytesPerPacket = (this.format.bitsPerChannel / 8) * this.format.channelsPerFrame;
            if (this.fileType === 'AIFC') {
              format = this.stream.readString(4);
              this.format.littleEndian = format === 'sowt' && this.format.bitsPerChannel > 8;
              this.format.floatingPoint = format === 'fl32' || format === 'fl64';
              if (format === 'twos' || format === 'sowt' || format === 'fl32' || format === 'fl64' || format === 'NONE') {
                format = 'lpcm';
              }
              this.format.formatID = format;
              this.len -= 4;
            }
            this.stream.advance(this.len - 18);
            this.emit('format', this.format);
            this.emit('duration', this.format.sampleCount / this.format.sampleRate * 1000 | 0);
            break;
          case 'SSND':
            if (!(this.readSSNDHeader && this.stream.available(4))) {
              offset = this.stream.readUInt32();
              this.stream.advance(4);
              this.stream.advance(offset);
              this.readSSNDHeader = true;
            }
            buffer = this.stream.readSingleBuffer(this.len);
            this.len -= buffer.length;
            this.readHeaders = this.len > 0;
            this.emit('data', buffer);
            break;
          default:
            if (!this.stream.available(this.len)) {
              return;
            }
            this.stream.advance(this.len);
        }
        if (this.type !== 'SSND') {
          this.readHeaders = false;
        }
      }
    };

    return AIFFDemuxer;

  })(Demuxer);

}).call(this);

},{"../demuxer":14}],16:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var AUDemuxer, Demuxer,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  Demuxer = require('../demuxer');

  AUDemuxer = (function(superClass) {
    var bps, formats;

    extend(AUDemuxer, superClass);

    function AUDemuxer() {
      return AUDemuxer.__super__.constructor.apply(this, arguments);
    }

    Demuxer.register(AUDemuxer);

    AUDemuxer.probe = function(buffer) {
      return buffer.peekString(0, 4) === '.snd';
    };

    bps = [8, 8, 16, 24, 32, 32, 64];

    bps[26] = 8;

    formats = {
      1: 'ulaw',
      27: 'alaw'
    };

    AUDemuxer.prototype.readChunk = function() {
      var bytes, dataSize, encoding, size;
      if (!this.readHeader && this.stream.available(24)) {
        if (this.stream.readString(4) !== '.snd') {
          return this.emit('error', 'Invalid AU file.');
        }
        size = this.stream.readUInt32();
        dataSize = this.stream.readUInt32();
        encoding = this.stream.readUInt32();
        this.format = {
          formatID: formats[encoding] || 'lpcm',
          littleEndian: false,
          floatingPoint: encoding === 6 || encoding === 7,
          bitsPerChannel: bps[encoding - 1],
          sampleRate: this.stream.readUInt32(),
          channelsPerFrame: this.stream.readUInt32(),
          framesPerPacket: 1
        };
        if (this.format.bitsPerChannel == null) {
          return this.emit('error', 'Unsupported encoding in AU file.');
        }
        this.format.bytesPerPacket = (this.format.bitsPerChannel / 8) * this.format.channelsPerFrame;
        if (dataSize !== 0xffffffff) {
          bytes = this.format.bitsPerChannel / 8;
          this.emit('duration', dataSize / bytes / this.format.channelsPerFrame / this.format.sampleRate * 1000 | 0);
        }
        this.emit('format', this.format);
        this.readHeader = true;
      }
      if (this.readHeader) {
        while (this.stream.available(1)) {
          this.emit('data', this.stream.readSingleBuffer(this.stream.remainingBytes()));
        }
      }
    };

    return AUDemuxer;

  })(Demuxer);

}).call(this);

},{"../demuxer":14}],17:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var CAFDemuxer, Demuxer, M4ADemuxer,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  Demuxer = require('../demuxer');

  M4ADemuxer = require('./m4a');

  CAFDemuxer = (function(superClass) {
    extend(CAFDemuxer, superClass);

    function CAFDemuxer() {
      return CAFDemuxer.__super__.constructor.apply(this, arguments);
    }

    Demuxer.register(CAFDemuxer);

    CAFDemuxer.probe = function(buffer) {
      return buffer.peekString(0, 4) === 'caff';
    };

    CAFDemuxer.prototype.readChunk = function() {
      var buffer, byteOffset, cookie, entries, flags, i, j, k, key, metadata, offset, ref, ref1, sampleOffset, value;
      if (!this.format && this.stream.available(64)) {
        if (this.stream.readString(4) !== 'caff') {
          return this.emit('error', "Invalid CAF, does not begin with 'caff'");
        }
        this.stream.advance(4);
        if (this.stream.readString(4) !== 'desc') {
          return this.emit('error', "Invalid CAF, 'caff' is not followed by 'desc'");
        }
        if (!(this.stream.readUInt32() === 0 && this.stream.readUInt32() === 32)) {
          return this.emit('error', "Invalid 'desc' size, should be 32");
        }
        this.format = {};
        this.format.sampleRate = this.stream.readFloat64();
        this.format.formatID = this.stream.readString(4);
        flags = this.stream.readUInt32();
        if (this.format.formatID === 'lpcm') {
          this.format.floatingPoint = Boolean(flags & 1);
          this.format.littleEndian = Boolean(flags & 2);
        }
        this.format.bytesPerPacket = this.stream.readUInt32();
        this.format.framesPerPacket = this.stream.readUInt32();
        this.format.channelsPerFrame = this.stream.readUInt32();
        this.format.bitsPerChannel = this.stream.readUInt32();
        this.emit('format', this.format);
      }
      while (this.stream.available(1)) {
        if (!this.headerCache) {
          this.headerCache = {
            type: this.stream.readString(4),
            oversize: this.stream.readUInt32() !== 0,
            size: this.stream.readUInt32()
          };
          if (this.headerCache.oversize) {
            return this.emit('error', "Holy Shit, an oversized file, not supported in JS");
          }
        }
        switch (this.headerCache.type) {
          case 'kuki':
            if (this.stream.available(this.headerCache.size)) {
              if (this.format.formatID === 'aac ') {
                offset = this.stream.offset + this.headerCache.size;
                if (cookie = M4ADemuxer.readEsds(this.stream)) {
                  this.emit('cookie', cookie);
                }
                this.stream.seek(offset);
              } else {
                buffer = this.stream.readBuffer(this.headerCache.size);
                this.emit('cookie', buffer);
              }
              this.headerCache = null;
            }
            break;
          case 'pakt':
            if (this.stream.available(this.headerCache.size)) {
              if (this.stream.readUInt32() !== 0) {
                return this.emit('error', 'Sizes greater than 32 bits are not supported.');
              }
              this.numPackets = this.stream.readUInt32();
              if (this.stream.readUInt32() !== 0) {
                return this.emit('error', 'Sizes greater than 32 bits are not supported.');
              }
              this.numFrames = this.stream.readUInt32();
              this.primingFrames = this.stream.readUInt32();
              this.remainderFrames = this.stream.readUInt32();
              this.emit('duration', this.numFrames / this.format.sampleRate * 1000 | 0);
              this.sentDuration = true;
              byteOffset = 0;
              sampleOffset = 0;
              for (i = j = 0, ref = this.numPackets; j < ref; i = j += 1) {
                this.addSeekPoint(byteOffset, sampleOffset);
                byteOffset += this.format.bytesPerPacket || M4ADemuxer.readDescrLen(this.stream);
                sampleOffset += this.format.framesPerPacket || M4ADemuxer.readDescrLen(this.stream);
              }
              this.headerCache = null;
            }
            break;
          case 'info':
            entries = this.stream.readUInt32();
            metadata = {};
            for (i = k = 0, ref1 = entries; 0 <= ref1 ? k < ref1 : k > ref1; i = 0 <= ref1 ? ++k : --k) {
              key = this.stream.readString(null);
              value = this.stream.readString(null);
              metadata[key] = value;
            }
            this.emit('metadata', metadata);
            this.headerCache = null;
            break;
          case 'data':
            if (!this.sentFirstDataChunk) {
              this.stream.advance(4);
              this.headerCache.size -= 4;
              if (this.format.bytesPerPacket !== 0 && !this.sentDuration) {
                this.numFrames = this.headerCache.size / this.format.bytesPerPacket;
                this.emit('duration', this.numFrames / this.format.sampleRate * 1000 | 0);
              }
              this.sentFirstDataChunk = true;
            }
            buffer = this.stream.readSingleBuffer(this.headerCache.size);
            this.headerCache.size -= buffer.length;
            this.emit('data', buffer);
            if (this.headerCache.size <= 0) {
              this.headerCache = null;
            }
            break;
          default:
            if (this.stream.available(this.headerCache.size)) {
              this.stream.advance(this.headerCache.size);
              this.headerCache = null;
            }
        }
      }
    };

    return CAFDemuxer;

  })(Demuxer);

}).call(this);

},{"../demuxer":14,"./m4a":18}],18:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Demuxer, M4ADemuxer,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty,
    indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  Demuxer = require('../demuxer');

  M4ADemuxer = (function(superClass) {
    var BITS_PER_CHANNEL, TYPES, after, atom, atoms, bool, containers, diskTrack, genres, meta, string;

    extend(M4ADemuxer, superClass);

    function M4ADemuxer() {
      return M4ADemuxer.__super__.constructor.apply(this, arguments);
    }

    Demuxer.register(M4ADemuxer);

    TYPES = ['M4A ', 'M4P ', 'M4B ', 'M4V ', 'isom', 'mp42', 'qt  '];

    M4ADemuxer.probe = function(buffer) {
      var ref;
      return buffer.peekString(4, 4) === 'ftyp' && (ref = buffer.peekString(8, 4), indexOf.call(TYPES, ref) >= 0);
    };

    M4ADemuxer.prototype.init = function() {
      this.atoms = [];
      this.offsets = [];
      this.track = null;
      return this.tracks = [];
    };

    atoms = {};

    containers = {};

    atom = function(name, fn) {
      var c, container, k, len1, ref;
      c = [];
      ref = name.split('.').slice(0, -1);
      for (k = 0, len1 = ref.length; k < len1; k++) {
        container = ref[k];
        c.push(container);
        containers[c.join('.')] = true;
      }
      if (atoms[name] == null) {
        atoms[name] = {};
      }
      return atoms[name].fn = fn;
    };

    after = function(name, fn) {
      if (atoms[name] == null) {
        atoms[name] = {};
      }
      return atoms[name].after = fn;
    };

    M4ADemuxer.prototype.readChunk = function() {
      var handler, path, type;
      this["break"] = false;
      while (this.stream.available(1) && !this["break"]) {
        if (!this.readHeaders) {
          if (!this.stream.available(8)) {
            return;
          }
          this.len = this.stream.readUInt32() - 8;
          this.type = this.stream.readString(4);
          if (this.len === 0) {
            continue;
          }
          this.atoms.push(this.type);
          this.offsets.push(this.stream.offset + this.len);
          this.readHeaders = true;
        }
        path = this.atoms.join('.');
        handler = atoms[path];
        if (handler != null ? handler.fn : void 0) {
          if (!(this.stream.available(this.len) || path === 'mdat')) {
            return;
          }
          handler.fn.call(this);
          if (path in containers) {
            this.readHeaders = false;
          }
        } else if (path in containers) {
          this.readHeaders = false;
        } else {
          if (!this.stream.available(this.len)) {
            return;
          }
          this.stream.advance(this.len);
        }
        while (this.stream.offset >= this.offsets[this.offsets.length - 1]) {
          handler = atoms[this.atoms.join('.')];
          if (handler != null ? handler.after : void 0) {
            handler.after.call(this);
          }
          type = this.atoms.pop();
          this.offsets.pop();
          this.readHeaders = false;
        }
      }
    };

    atom('ftyp', function() {
      var ref;
      if (ref = this.stream.readString(4), indexOf.call(TYPES, ref) < 0) {
        return this.emit('error', 'Not a valid M4A file.');
      }
      return this.stream.advance(this.len - 4);
    });

    atom('moov.trak', function() {
      this.track = {};
      return this.tracks.push(this.track);
    });

    atom('moov.trak.tkhd', function() {
      this.stream.advance(4);
      this.stream.advance(8);
      this.track.id = this.stream.readUInt32();
      return this.stream.advance(this.len - 16);
    });

    atom('moov.trak.mdia.hdlr', function() {
      this.stream.advance(4);
      this.stream.advance(4);
      this.track.type = this.stream.readString(4);
      this.stream.advance(12);
      return this.stream.advance(this.len - 24);
    });

    atom('moov.trak.mdia.mdhd', function() {
      this.stream.advance(4);
      this.stream.advance(8);
      this.track.timeScale = this.stream.readUInt32();
      this.track.duration = this.stream.readUInt32();
      return this.stream.advance(4);
    });

    BITS_PER_CHANNEL = {
      ulaw: 8,
      alaw: 8,
      in24: 24,
      in32: 32,
      fl32: 32,
      fl64: 64
    };

    atom('moov.trak.mdia.minf.stbl.stsd', function() {
      var format, numEntries, ref, ref1, version;
      this.stream.advance(4);
      numEntries = this.stream.readUInt32();
      if (this.track.type !== 'soun') {
        return this.stream.advance(this.len - 8);
      }
      if (numEntries !== 1) {
        return this.emit('error', "Only expecting one entry in sample description atom!");
      }
      this.stream.advance(4);
      format = this.track.format = {};
      format.formatID = this.stream.readString(4);
      this.stream.advance(6);
      this.stream.advance(2);
      version = this.stream.readUInt16();
      this.stream.advance(6);
      format.channelsPerFrame = this.stream.readUInt16();
      format.bitsPerChannel = this.stream.readUInt16();
      this.stream.advance(4);
      format.sampleRate = this.stream.readUInt16();
      this.stream.advance(2);
      if (version === 1) {
        format.framesPerPacket = this.stream.readUInt32();
        this.stream.advance(4);
        format.bytesPerFrame = this.stream.readUInt32();
        this.stream.advance(4);
      } else if (version !== 0) {
        this.emit('error', 'Unknown version in stsd atom');
      }
      if (BITS_PER_CHANNEL[format.formatID] != null) {
        format.bitsPerChannel = BITS_PER_CHANNEL[format.formatID];
      }
      format.floatingPoint = (ref = format.formatID) === 'fl32' || ref === 'fl64';
      format.littleEndian = format.formatID === 'sowt' && format.bitsPerChannel > 8;
      if ((ref1 = format.formatID) === 'twos' || ref1 === 'sowt' || ref1 === 'in24' || ref1 === 'in32' || ref1 === 'fl32' || ref1 === 'fl64' || ref1 === 'raw ' || ref1 === 'NONE') {
        return format.formatID = 'lpcm';
      }
    });

    atom('moov.trak.mdia.minf.stbl.stsd.alac', function() {
      this.stream.advance(4);
      return this.track.cookie = this.stream.readBuffer(this.len - 4);
    });

    atom('moov.trak.mdia.minf.stbl.stsd.esds', function() {
      var offset;
      offset = this.stream.offset + this.len;
      this.track.cookie = M4ADemuxer.readEsds(this.stream);
      return this.stream.seek(offset);
    });

    atom('moov.trak.mdia.minf.stbl.stsd.wave.enda', function() {
      return this.track.format.littleEndian = !!this.stream.readUInt16();
    });

    M4ADemuxer.readDescrLen = function(stream) {
      var c, count, len;
      len = 0;
      count = 4;
      while (count--) {
        c = stream.readUInt8();
        len = (len << 7) | (c & 0x7f);
        if (!(c & 0x80)) {
          break;
        }
      }
      return len;
    };

    M4ADemuxer.readEsds = function(stream) {
      var codec_id, flags, len, tag;
      stream.advance(4);
      tag = stream.readUInt8();
      len = M4ADemuxer.readDescrLen(stream);
      if (tag === 0x03) {
        stream.advance(2);
        flags = stream.readUInt8();
        if (flags & 0x80) {
          stream.advance(2);
        }
        if (flags & 0x40) {
          stream.advance(stream.readUInt8());
        }
        if (flags & 0x20) {
          stream.advance(2);
        }
      } else {
        stream.advance(2);
      }
      tag = stream.readUInt8();
      len = M4ADemuxer.readDescrLen(stream);
      if (tag === 0x04) {
        codec_id = stream.readUInt8();
        stream.advance(1);
        stream.advance(3);
        stream.advance(4);
        stream.advance(4);
        tag = stream.readUInt8();
        len = M4ADemuxer.readDescrLen(stream);
        if (tag === 0x05) {
          return stream.readBuffer(len);
        }
      }
      return null;
    };

    atom('moov.trak.mdia.minf.stbl.stts', function() {
      var entries, i, k, ref;
      this.stream.advance(4);
      entries = this.stream.readUInt32();
      this.track.stts = [];
      for (i = k = 0, ref = entries; k < ref; i = k += 1) {
        this.track.stts[i] = {
          count: this.stream.readUInt32(),
          duration: this.stream.readUInt32()
        };
      }
      return this.setupSeekPoints();
    });

    atom('moov.trak.mdia.minf.stbl.stsc', function() {
      var entries, i, k, ref;
      this.stream.advance(4);
      entries = this.stream.readUInt32();
      this.track.stsc = [];
      for (i = k = 0, ref = entries; k < ref; i = k += 1) {
        this.track.stsc[i] = {
          first: this.stream.readUInt32(),
          count: this.stream.readUInt32(),
          id: this.stream.readUInt32()
        };
      }
      return this.setupSeekPoints();
    });

    atom('moov.trak.mdia.minf.stbl.stsz', function() {
      var entries, i, k, ref;
      this.stream.advance(4);
      this.track.sampleSize = this.stream.readUInt32();
      entries = this.stream.readUInt32();
      if (this.track.sampleSize === 0 && entries > 0) {
        this.track.sampleSizes = [];
        for (i = k = 0, ref = entries; k < ref; i = k += 1) {
          this.track.sampleSizes[i] = this.stream.readUInt32();
        }
      }
      return this.setupSeekPoints();
    });

    atom('moov.trak.mdia.minf.stbl.stco', function() {
      var entries, i, k, ref;
      this.stream.advance(4);
      entries = this.stream.readUInt32();
      this.track.chunkOffsets = [];
      for (i = k = 0, ref = entries; k < ref; i = k += 1) {
        this.track.chunkOffsets[i] = this.stream.readUInt32();
      }
      return this.setupSeekPoints();
    });

    atom('moov.trak.tref.chap', function() {
      var entries, i, k, ref;
      entries = this.len >> 2;
      this.track.chapterTracks = [];
      for (i = k = 0, ref = entries; k < ref; i = k += 1) {
        this.track.chapterTracks[i] = this.stream.readUInt32();
      }
    });

    M4ADemuxer.prototype.setupSeekPoints = function() {
      var i, j, k, l, len1, offset, position, ref, ref1, results, sampleIndex, size, stscIndex, sttsIndex, sttsSample, timestamp;
      if (!((this.track.chunkOffsets != null) && (this.track.stsc != null) && (this.track.sampleSize != null) && (this.track.stts != null))) {
        return;
      }
      stscIndex = 0;
      sttsIndex = 0;
      sttsIndex = 0;
      sttsSample = 0;
      sampleIndex = 0;
      offset = 0;
      timestamp = 0;
      this.track.seekPoints = [];
      ref = this.track.chunkOffsets;
      results = [];
      for (i = k = 0, len1 = ref.length; k < len1; i = ++k) {
        position = ref[i];
        for (j = l = 0, ref1 = this.track.stsc[stscIndex].count; l < ref1; j = l += 1) {
          this.track.seekPoints.push({
            offset: offset,
            position: position,
            timestamp: timestamp
          });
          size = this.track.sampleSize || this.track.sampleSizes[sampleIndex++];
          offset += size;
          position += size;
          timestamp += this.track.stts[sttsIndex].duration;
          if (sttsIndex + 1 < this.track.stts.length && ++sttsSample === this.track.stts[sttsIndex].count) {
            sttsSample = 0;
            sttsIndex++;
          }
        }
        if (stscIndex + 1 < this.track.stsc.length && i + 1 === this.track.stsc[stscIndex + 1].first) {
          results.push(stscIndex++);
        } else {
          results.push(void 0);
        }
      }
      return results;
    };

    after('moov', function() {
      var k, len1, ref, track;
      if (this.mdatOffset != null) {
        this.stream.seek(this.mdatOffset - 8);
      }
      ref = this.tracks;
      for (k = 0, len1 = ref.length; k < len1; k++) {
        track = ref[k];
        if (!(track.type === 'soun')) {
          continue;
        }
        this.track = track;
        break;
      }
      if (this.track.type !== 'soun') {
        this.track = null;
        return this.emit('error', 'No audio tracks in m4a file.');
      }
      this.emit('format', this.track.format);
      this.emit('duration', this.track.duration / this.track.timeScale * 1000 | 0);
      if (this.track.cookie) {
        this.emit('cookie', this.track.cookie);
      }
      return this.seekPoints = this.track.seekPoints;
    });

    atom('mdat', function() {
      var bytes, chunkSize, k, length, numSamples, offset, ref, sample, size;
      if (!this.startedData) {
        if (this.mdatOffset == null) {
          this.mdatOffset = this.stream.offset;
        }
        if (this.tracks.length === 0) {
          bytes = Math.min(this.stream.remainingBytes(), this.len);
          this.stream.advance(bytes);
          this.len -= bytes;
          return;
        }
        this.chunkIndex = 0;
        this.stscIndex = 0;
        this.sampleIndex = 0;
        this.tailOffset = 0;
        this.tailSamples = 0;
        this.startedData = true;
      }
      if (!this.readChapters) {
        this.readChapters = this.parseChapters();
        if (this["break"] = !this.readChapters) {
          return;
        }
        this.stream.seek(this.mdatOffset);
      }
      offset = this.track.chunkOffsets[this.chunkIndex] + this.tailOffset;
      length = 0;
      if (!this.stream.available(offset - this.stream.offset)) {
        this["break"] = true;
        return;
      }
      this.stream.seek(offset);
      while (this.chunkIndex < this.track.chunkOffsets.length) {
        numSamples = this.track.stsc[this.stscIndex].count - this.tailSamples;
        chunkSize = 0;
        for (sample = k = 0, ref = numSamples; k < ref; sample = k += 1) {
          size = this.track.sampleSize || this.track.sampleSizes[this.sampleIndex];
          if (!this.stream.available(length + size)) {
            break;
          }
          length += size;
          chunkSize += size;
          this.sampleIndex++;
        }
        if (sample < numSamples) {
          this.tailOffset += chunkSize;
          this.tailSamples += sample;
          break;
        } else {
          this.chunkIndex++;
          this.tailOffset = 0;
          this.tailSamples = 0;
          if (this.stscIndex + 1 < this.track.stsc.length && this.chunkIndex + 1 === this.track.stsc[this.stscIndex + 1].first) {
            this.stscIndex++;
          }
          if (offset + length !== this.track.chunkOffsets[this.chunkIndex]) {
            break;
          }
        }
      }
      if (length > 0) {
        this.emit('data', this.stream.readBuffer(length));
        return this["break"] = this.chunkIndex === this.track.chunkOffsets.length;
      } else {
        return this["break"] = true;
      }
    });

    M4ADemuxer.prototype.parseChapters = function() {
      var bom, id, k, len, len1, nextTimestamp, point, ref, ref1, ref2, ref3, title, track;
      if (!(((ref = this.track.chapterTracks) != null ? ref.length : void 0) > 0)) {
        return true;
      }
      id = this.track.chapterTracks[0];
      ref1 = this.tracks;
      for (k = 0, len1 = ref1.length; k < len1; k++) {
        track = ref1[k];
        if (track.id === id) {
          break;
        }
      }
      if (track.id !== id) {
        this.emit('error', 'Chapter track does not exist.');
      }
      if (this.chapters == null) {
        this.chapters = [];
      }
      while (this.chapters.length < track.seekPoints.length) {
        point = track.seekPoints[this.chapters.length];
        if (!this.stream.available(point.position - this.stream.offset + 32)) {
          return false;
        }
        this.stream.seek(point.position);
        len = this.stream.readUInt16();
        title = null;
        if (!this.stream.available(len)) {
          return false;
        }
        if (len > 2) {
          bom = this.stream.peekUInt16();
          if (bom === 0xfeff || bom === 0xfffe) {
            title = this.stream.readString(len, 'utf16-bom');
          }
        }
        if (title == null) {
          title = this.stream.readString(len, 'utf8');
        }
        nextTimestamp = (ref2 = (ref3 = track.seekPoints[this.chapters.length + 1]) != null ? ref3.timestamp : void 0) != null ? ref2 : track.duration;
        this.chapters.push({
          title: title,
          timestamp: point.timestamp / track.timeScale * 1000 | 0,
          duration: (nextTimestamp - point.timestamp) / track.timeScale * 1000 | 0
        });
      }
      this.emit('chapters', this.chapters);
      return true;
    };

    atom('moov.udta.meta', function() {
      this.metadata = {};
      return this.stream.advance(4);
    });

    after('moov.udta.meta', function() {
      return this.emit('metadata', this.metadata);
    });

    meta = function(field, name, fn) {
      return atom("moov.udta.meta.ilst." + field + ".data", function() {
        this.stream.advance(8);
        this.len -= 8;
        return fn.call(this, name);
      });
    };

    string = function(field) {
      return this.metadata[field] = this.stream.readString(this.len, 'utf8');
    };

    meta('©alb', 'album', string);

    meta('©arg', 'arranger', string);

    meta('©art', 'artist', string);

    meta('©ART', 'artist', string);

    meta('aART', 'albumArtist', string);

    meta('catg', 'category', string);

    meta('©com', 'composer', string);

    meta('©cpy', 'copyright', string);

    meta('cprt', 'copyright', string);

    meta('©cmt', 'comments', string);

    meta('©day', 'releaseDate', string);

    meta('desc', 'description', string);

    meta('©gen', 'genre', string);

    meta('©grp', 'grouping', string);

    meta('©isr', 'ISRC', string);

    meta('keyw', 'keywords', string);

    meta('©lab', 'recordLabel', string);

    meta('ldes', 'longDescription', string);

    meta('©lyr', 'lyrics', string);

    meta('©nam', 'title', string);

    meta('©phg', 'recordingCopyright', string);

    meta('©prd', 'producer', string);

    meta('©prf', 'performers', string);

    meta('purd', 'purchaseDate', string);

    meta('purl', 'podcastURL', string);

    meta('©swf', 'songwriter', string);

    meta('©too', 'encoder', string);

    meta('©wrt', 'composer', string);

    meta('covr', 'coverArt', function(field) {
      return this.metadata[field] = this.stream.readBuffer(this.len);
    });

    genres = ["Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "A Capella", "Euro-House", "Dance Hall"];

    meta('gnre', 'genre', function(field) {
      return this.metadata[field] = genres[this.stream.readUInt16() - 1];
    });

    meta('tmpo', 'tempo', function(field) {
      return this.metadata[field] = this.stream.readUInt16();
    });

    meta('rtng', 'rating', function(field) {
      var rating;
      rating = this.stream.readUInt8();
      return this.metadata[field] = rating === 2 ? 'Clean' : rating !== 0 ? 'Explicit' : 'None';
    });

    diskTrack = function(field) {
      this.stream.advance(2);
      this.metadata[field] = this.stream.readUInt16() + ' of ' + this.stream.readUInt16();
      return this.stream.advance(this.len - 6);
    };

    meta('disk', 'diskNumber', diskTrack);

    meta('trkn', 'trackNumber', diskTrack);

    bool = function(field) {
      return this.metadata[field] = this.stream.readUInt8() === 1;
    };

    meta('cpil', 'compilation', bool);

    meta('pcst', 'podcast', bool);

    meta('pgap', 'gapless', bool);

    return M4ADemuxer;

  })(Demuxer);

  module.exports = M4ADemuxer;

}).call(this);

},{"../demuxer":14}],19:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Demuxer, WAVEDemuxer,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  Demuxer = require('../demuxer');

  WAVEDemuxer = (function(superClass) {
    var formats;

    extend(WAVEDemuxer, superClass);

    function WAVEDemuxer() {
      return WAVEDemuxer.__super__.constructor.apply(this, arguments);
    }

    Demuxer.register(WAVEDemuxer);

    WAVEDemuxer.probe = function(buffer) {
      return buffer.peekString(0, 4) === 'RIFF' && buffer.peekString(8, 4) === 'WAVE';
    };

    formats = {
      0x0001: 'lpcm',
      0x0003: 'lpcm',
      0x0006: 'alaw',
      0x0007: 'ulaw'
    };

    WAVEDemuxer.prototype.readChunk = function() {
      var buffer, bytes, encoding;
      if (!this.readStart && this.stream.available(12)) {
        if (this.stream.readString(4) !== 'RIFF') {
          return this.emit('error', 'Invalid WAV file.');
        }
        this.fileSize = this.stream.readUInt32(true);
        this.readStart = true;
        if (this.stream.readString(4) !== 'WAVE') {
          return this.emit('error', 'Invalid WAV file.');
        }
      }
      while (this.stream.available(1)) {
        if (!this.readHeaders && this.stream.available(8)) {
          this.type = this.stream.readString(4);
          this.len = this.stream.readUInt32(true);
        }
        switch (this.type) {
          case 'fmt ':
            encoding = this.stream.readUInt16(true);
            if (!(encoding in formats)) {
              return this.emit('error', 'Unsupported format in WAV file.');
            }
            this.format = {
              formatID: formats[encoding],
              floatingPoint: encoding === 0x0003,
              littleEndian: formats[encoding] === 'lpcm',
              channelsPerFrame: this.stream.readUInt16(true),
              sampleRate: this.stream.readUInt32(true),
              framesPerPacket: 1
            };
            this.stream.advance(4);
            this.stream.advance(2);
            this.format.bitsPerChannel = this.stream.readUInt16(true);
            this.format.bytesPerPacket = (this.format.bitsPerChannel / 8) * this.format.channelsPerFrame;
            this.emit('format', this.format);
            this.stream.advance(this.len - 16);
            break;
          case 'data':
            if (!this.sentDuration) {
              bytes = this.format.bitsPerChannel / 8;
              this.emit('duration', this.len / bytes / this.format.channelsPerFrame / this.format.sampleRate * 1000 | 0);
              this.sentDuration = true;
            }
            buffer = this.stream.readSingleBuffer(this.len);
            this.len -= buffer.length;
            this.readHeaders = this.len > 0;
            this.emit('data', buffer);
            break;
          default:
            if (!this.stream.available(this.len)) {
              return;
            }
            this.stream.advance(this.len);
        }
        if (this.type !== 'data') {
          this.readHeaders = false;
        }
      }
    };

    return WAVEDemuxer;

  })(Demuxer);

}).call(this);

},{"../demuxer":14}],20:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var AudioDevice, EventEmitter,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('./core/events');

  AudioDevice = (function(superClass) {
    var devices;

    extend(AudioDevice, superClass);

    function AudioDevice(sampleRate1, channels1) {
      this.sampleRate = sampleRate1;
      this.channels = channels1;
      this.updateTime = bind(this.updateTime, this);
      this.playing = false;
      this.currentTime = 0;
      this._lastTime = 0;
    }

    AudioDevice.prototype.start = function() {
      if (this.playing) {
        return;
      }
      this.playing = true;
      if (this.device == null) {
        this.device = AudioDevice.create(this.sampleRate, this.channels);
      }
      if (!this.device) {
        throw new Error("No supported audio device found.");
      }
      this._lastTime = this.device.getDeviceTime();
      this._timer = setInterval(this.updateTime, 200);
      return this.device.on('refill', this.refill = (function(_this) {
        return function(buffer) {
          return _this.emit('refill', buffer);
        };
      })(this));
    };

    AudioDevice.prototype.stop = function() {
      if (!this.playing) {
        return;
      }
      this.playing = false;
      this.device.off('refill', this.refill);
      return clearInterval(this._timer);
    };

    AudioDevice.prototype.destroy = function() {
      var ref;
      this.stop();
      return (ref = this.device) != null ? ref.destroy() : void 0;
    };

    AudioDevice.prototype.seek = function(currentTime) {
      this.currentTime = currentTime;
      if (this.playing) {
        this._lastTime = this.device.getDeviceTime();
      }
      return this.emit('timeUpdate', this.currentTime);
    };

    AudioDevice.prototype.updateTime = function() {
      var time;
      time = this.device.getDeviceTime();
      this.currentTime += (time - this._lastTime) / this.device.sampleRate * 1000 | 0;
      this._lastTime = time;
      return this.emit('timeUpdate', this.currentTime);
    };

    devices = [];

    AudioDevice.register = function(device) {
      return devices.push(device);
    };

    AudioDevice.create = function(sampleRate, channels) {
      var device, i, len;
      for (i = 0, len = devices.length; i < len; i++) {
        device = devices[i];
        if (device.supported) {
          return new device(sampleRate, channels);
        }
      }
      return null;
    };

    return AudioDevice;

  })(EventEmitter);

  module.exports = AudioDevice;

}).call(this);

},{"./core/events":8}],21:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var AVBuffer, AudioDevice, EventEmitter, MozillaAudioDevice,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('../core/events');

  AudioDevice = require('../device');

  AVBuffer = require('../core/buffer');

  MozillaAudioDevice = (function(superClass) {
    var createTimer, destroyTimer;

    extend(MozillaAudioDevice, superClass);

    AudioDevice.register(MozillaAudioDevice);

    MozillaAudioDevice.supported = (typeof Audio !== "undefined" && Audio !== null) && 'mozWriteAudio' in new Audio;

    function MozillaAudioDevice(sampleRate, channels) {
      this.sampleRate = sampleRate;
      this.channels = channels;
      this.refill = bind(this.refill, this);
      this.audio = new Audio;
      this.audio.mozSetup(this.channels, this.sampleRate);
      this.writePosition = 0;
      this.prebufferSize = this.sampleRate / 2;
      this.tail = null;
      this.timer = createTimer(this.refill, 100);
    }

    MozillaAudioDevice.prototype.refill = function() {
      var available, buffer, currentPosition, written;
      if (this.tail) {
        written = this.audio.mozWriteAudio(this.tail);
        this.writePosition += written;
        if (this.writePosition < this.tail.length) {
          this.tail = this.tail.subarray(written);
        } else {
          this.tail = null;
        }
      }
      currentPosition = this.audio.mozCurrentSampleOffset();
      available = currentPosition + this.prebufferSize - this.writePosition;
      if (available > 0) {
        buffer = new Float32Array(available);
        this.emit('refill', buffer);
        written = this.audio.mozWriteAudio(buffer);
        if (written < buffer.length) {
          this.tail = buffer.subarray(written);
        }
        this.writePosition += written;
      }
    };

    MozillaAudioDevice.prototype.destroy = function() {
      return destroyTimer(this.timer);
    };

    MozillaAudioDevice.prototype.getDeviceTime = function() {
      return this.audio.mozCurrentSampleOffset() / this.channels;
    };

    createTimer = function(fn, interval) {
      var url, worker;
      url = AVBuffer.makeBlobURL("setInterval(function() { postMessage('ping'); }, " + interval + ");");
      if (url == null) {
        return setInterval(fn, interval);
      }
      worker = new Worker(url);
      worker.onmessage = fn;
      worker.url = url;
      return worker;
    };

    destroyTimer = function(timer) {
      if (timer.terminate) {
        timer.terminate();
        return URL.revokeObjectURL(timer.url);
      } else {
        return clearInterval(timer);
      }
    };

    return MozillaAudioDevice;

  })(EventEmitter);

}).call(this);

},{"../core/buffer":6,"../core/events":8,"../device":20}],22:[function(require,module,exports){
//JavaScript Audio Resampler
//Copyright (C) 2011-2015 Grant Galitz
//Released to Public Domain
function Resampler(fromSampleRate, toSampleRate, channels, inputBufferLength) {
  this.fromSampleRate = +fromSampleRate;
  this.toSampleRate = +toSampleRate;
  this.channels = channels | 0;
  this.inputBufferLength = inputBufferLength;
  this.initialize();
}

Resampler.prototype.initialize = function () {
  //Perform some checks:
  if (this.fromSampleRate > 0 && this.toSampleRate > 0 && this.channels > 0) {
    if (this.fromSampleRate == this.toSampleRate) {
      //Setup a resampler bypass:
      this.resampler = this.bypassResampler;    //Resampler just returns what was passed through.
      this.ratioWeight = 1;
    } else {
      this.ratioWeight = this.fromSampleRate / this.toSampleRate;
      if (this.fromSampleRate < this.toSampleRate) {
        /*
          Use generic linear interpolation if upsampling,
          as linear interpolation produces a gradient that we want
          and works fine with two input sample points per output in this case.
        */
        this.compileLinearInterpolationFunction();
        this.lastWeight = 1;
      } else {
        /*
          Custom resampler I wrote that doesn't skip samples
          like standard linear interpolation in high downsampling.
          This is more accurate than linear interpolation on downsampling.
        */
        this.compileMultiTapFunction();
        this.tailExists = false;
        this.lastWeight = 0;
      }

      var outputBufferSize = (Math.ceil(this.inputBufferLength * this.toSampleRate / this.fromSampleRate / this.channels * 1.01) * this.channels) + this.channels;
      this.outputBuffer = new Float32Array(outputBufferSize);
      this.lastOutput = new Float32Array(this.channels);
    }
  } else {
    throw(new Error("Invalid settings specified for the resampler."));
  }
};

Resampler.prototype.compileLinearInterpolationFunction = function () {
  var toCompile = "var outputOffset = 0;\
    var bufferLength = buffer.length;\
    if (bufferLength > 0) {\
      var weight = this.lastWeight;\
      var firstWeight = 0;\
      var secondWeight = 0;\
      var sourceOffset = 0;\
      var outputOffset = 0;\
      var outputBuffer = this.outputBuffer;\
      for (; weight < 1; weight += " + this.ratioWeight + ") {\
        secondWeight = weight % 1;\
        firstWeight = 1 - secondWeight;";
        for (var channel = 0; channel < this.channels; ++channel) {
          toCompile += "outputBuffer[outputOffset++] = (this.lastOutput[" + channel + "] * firstWeight) + (buffer[" + channel + "] * secondWeight);";
        }
      toCompile += "}\
      weight -= 1;\
      for (bufferLength -= " + this.channels + ", sourceOffset = Math.floor(weight) * " + this.channels + "; sourceOffset < bufferLength;) {\
        secondWeight = weight % 1;\
        firstWeight = 1 - secondWeight;";
        for (var channel = 0; channel < this.channels; ++channel) {
          toCompile += "outputBuffer[outputOffset++] = (buffer[sourceOffset" + ((channel > 0) ? (" + " + channel) : "") + "] * firstWeight) + (buffer[sourceOffset + " + (this.channels + channel) + "] * secondWeight);";
        }
        toCompile += "weight += " + this.ratioWeight + ";\
        sourceOffset = Math.floor(weight) * " + this.channels + ";\
      }";
      for (var channel = 0; channel < this.channels; ++channel) {
        toCompile += "this.lastOutput[" + channel + "] = buffer[sourceOffset++];";
      }
      toCompile += "this.lastWeight = weight % 1;\
    }\
    return this.outputBuffer;";

  this.resampler = Function("buffer", toCompile);
};

Resampler.prototype.compileMultiTapFunction = function () {
  var toCompile = "var outputOffset = 0;\
    var bufferLength = buffer.length;\
    if (bufferLength > 0) {\
      var weight = 0;";
      for (var channel = 0; channel < this.channels; ++channel) {
        toCompile += "var output" + channel + " = 0;"
      }
      toCompile += "var actualPosition = 0;\
      var amountToNext = 0;\
      var alreadyProcessedTail = !this.tailExists;\
      this.tailExists = false;\
      var outputBuffer = this.outputBuffer;\
      var currentPosition = 0;\
      do {\
        if (alreadyProcessedTail) {\
          weight = " + this.ratioWeight + ";";
          for (channel = 0; channel < this.channels; ++channel) {
            toCompile += "output" + channel + " = 0;"
          }
        toCompile += "}\
        else {\
          weight = this.lastWeight;";
          for (channel = 0; channel < this.channels; ++channel) {
            toCompile += "output" + channel + " = this.lastOutput[" + channel + "];"
          }
          toCompile += "alreadyProcessedTail = true;\
        }\
        while (weight > 0 && actualPosition < bufferLength) {\
          amountToNext = 1 + actualPosition - currentPosition;\
          if (weight >= amountToNext) {";
            for (channel = 0; channel < this.channels; ++channel) {
              toCompile += "output" + channel + " += buffer[actualPosition++] * amountToNext;"
            }
            toCompile += "currentPosition = actualPosition;\
            weight -= amountToNext;\
          }\
          else {";
            for (channel = 0; channel < this.channels; ++channel) {
              toCompile += "output" + channel + " += buffer[actualPosition" + ((channel > 0) ? (" + " + channel) : "") + "] * weight;"
            }
            toCompile += "currentPosition += weight;\
            weight = 0;\
            break;\
          }\
        }\
        if (weight <= 0) {";
          for (channel = 0; channel < this.channels; ++channel) {
            toCompile += "outputBuffer[outputOffset++] = output" + channel + " / " + this.ratioWeight + ";"
          }
        toCompile += "}\
        else {\
          this.lastWeight = weight;";
          for (channel = 0; channel < this.channels; ++channel) {
            toCompile += "this.lastOutput[" + channel + "] = output" + channel + ";"
          }
          toCompile += "this.tailExists = true;\
          break;\
        }\
      } while (actualPosition < bufferLength);\
    }\
    return this.outputBuffer;";

  this.resampler = Function("buffer", toCompile);
};

Resampler.prototype.bypassResampler = function (inputBuffer) {
  return inputBuffer;
};

module.exports = Resampler;

},{}],23:[function(require,module,exports){
(function (global){
// Generated by CoffeeScript 1.11.1
(function() {
  var AudioDevice, EventEmitter, Resampler, WebAudioDevice,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('../core/events');

  AudioDevice = require('../device');

  Resampler = require('./resampler');

  WebAudioDevice = (function(superClass) {
    var AudioContext, createProcessor, sharedContext;

    extend(WebAudioDevice, superClass);

    AudioDevice.register(WebAudioDevice);

    AudioContext = global.AudioContext || global.webkitAudioContext;

    WebAudioDevice.supported = AudioContext && (typeof AudioContext.prototype[createProcessor = 'createScriptProcessor'] === 'function' || typeof AudioContext.prototype[createProcessor = 'createJavaScriptNode'] === 'function');

    sharedContext = null;

    function WebAudioDevice(sampleRate, channels1) {
      this.sampleRate = sampleRate;
      this.channels = channels1;
      this.refill = bind(this.refill, this);
      this.context = sharedContext != null ? sharedContext : sharedContext = new AudioContext;
      this.deviceSampleRate = this.context.sampleRate;
      this.bufferSize = Math.ceil(4096 / (this.deviceSampleRate / this.sampleRate) * this.channels);
      this.bufferSize += this.bufferSize % this.channels;
      if (this.deviceSampleRate !== this.sampleRate) {
        this.resampler = new Resampler(this.sampleRate, this.deviceSampleRate, this.channels, this.bufferSize);
      }
      this.node = this.context[createProcessor](4096, this.channels, this.channels);
      this.node.onaudioprocess = this.refill;
      this.node.connect(this.context.destination);
    }

    WebAudioDevice.prototype.refill = function(event) {
      var channelCount, channels, data, i, j, k, l, n, outputBuffer, ref, ref1, ref2;
      outputBuffer = event.outputBuffer;
      channelCount = outputBuffer.numberOfChannels;
      channels = new Array(channelCount);
      for (i = j = 0, ref = channelCount; j < ref; i = j += 1) {
        channels[i] = outputBuffer.getChannelData(i);
      }
      data = new Float32Array(this.bufferSize);
      this.emit('refill', data);
      if (this.resampler) {
        data = this.resampler.resampler(data);
      }
      for (i = k = 0, ref1 = outputBuffer.length; k < ref1; i = k += 1) {
        for (n = l = 0, ref2 = channelCount; l < ref2; n = l += 1) {
          channels[n][i] = data[i * channelCount + n];
        }
      }
    };

    WebAudioDevice.prototype.destroy = function() {
      return this.node.disconnect(0);
    };

    WebAudioDevice.prototype.getDeviceTime = function() {
      return this.context.currentTime * this.sampleRate;
    };

    return WebAudioDevice;

  })(EventEmitter);

}).call(this);

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})

},{"../core/events":8,"../device":20,"./resampler":22}],24:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Filter;

  Filter = (function() {
    function Filter(context, key) {
      if (context && key) {
        Object.defineProperty(this, 'value', {
          get: function() {
            return context[key];
          }
        });
      }
    }

    Filter.prototype.process = function(buffer) {};

    return Filter;

  })();

  module.exports = Filter;

}).call(this);

},{}],25:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var BalanceFilter, Filter,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  Filter = require('../filter');

  BalanceFilter = (function(superClass) {
    extend(BalanceFilter, superClass);

    function BalanceFilter() {
      return BalanceFilter.__super__.constructor.apply(this, arguments);
    }

    BalanceFilter.prototype.process = function(buffer) {
      var i, j, pan, ref;
      if (this.value === 0) {
        return;
      }
      pan = Math.max(-50, Math.min(50, this.value));
      for (i = j = 0, ref = buffer.length; j < ref; i = j += 2) {
        buffer[i] *= Math.min(1, (50 - pan) / 50);
        buffer[i + 1] *= Math.min(1, (50 + pan) / 50);
      }
    };

    return BalanceFilter;

  })(Filter);

  module.exports = BalanceFilter;

}).call(this);

},{"../filter":24}],26:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Filter, VolumeFilter,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  Filter = require('../filter');

  VolumeFilter = (function(superClass) {
    extend(VolumeFilter, superClass);

    function VolumeFilter() {
      return VolumeFilter.__super__.constructor.apply(this, arguments);
    }

    VolumeFilter.prototype.process = function(buffer) {
      var i, j, ref, vol;
      if (this.value >= 100) {
        return;
      }
      vol = Math.max(0, Math.min(100, this.value)) / 100;
      for (i = j = 0, ref = buffer.length; j < ref; i = j += 1) {
        buffer[i] *= vol;
      }
    };

    return VolumeFilter;

  })(Filter);

  module.exports = VolumeFilter;

}).call(this);

},{"../filter":24}],27:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var Asset, AudioDevice, BalanceFilter, EventEmitter, Player, Queue, VolumeFilter,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('./core/events');

  Asset = require('./asset');

  VolumeFilter = require('./filters/volume');

  BalanceFilter = require('./filters/balance');

  Queue = require('./queue');

  AudioDevice = require('./device');

  Player = (function(superClass) {
    extend(Player, superClass);

    function Player(asset) {
      this.asset = asset;
      this.startPlaying = bind(this.startPlaying, this);
      this.playing = false;
      this.buffered = 0;
      this.currentTime = 0;
      this.duration = 0;
      this.volume = 100;
      this.pan = 0;
      this.metadata = {};
      this.filters = [new VolumeFilter(this, 'volume'), new BalanceFilter(this, 'pan')];
      this.asset.on('buffer', (function(_this) {
        return function(buffered) {
          _this.buffered = buffered;
          return _this.emit('buffer', _this.buffered);
        };
      })(this));
      this.asset.on('decodeStart', (function(_this) {
        return function() {
          _this.queue = new Queue(_this.asset);
          return _this.queue.once('ready', _this.startPlaying);
        };
      })(this));
      this.asset.on('format', (function(_this) {
        return function(format) {
          _this.format = format;
          return _this.emit('format', _this.format);
        };
      })(this));
      this.asset.on('metadata', (function(_this) {
        return function(metadata) {
          _this.metadata = metadata;
          return _this.emit('metadata', _this.metadata);
        };
      })(this));
      this.asset.on('duration', (function(_this) {
        return function(duration) {
          _this.duration = duration;
          return _this.emit('duration', _this.duration);
        };
      })(this));
      this.asset.on('error', (function(_this) {
        return function(error) {
          return _this.emit('error', error);
        };
      })(this));
    }

    Player.fromURL = function(url, opts) {
      return new Player(Asset.fromURL(url, opts));
    };

    Player.fromFile = function(file) {
      return new Player(Asset.fromFile(file));
    };

    Player.fromBuffer = function(buffer) {
      return new Player(Asset.fromBuffer(buffer));
    };

    Player.prototype.preload = function() {
      if (!this.asset) {
        return;
      }
      this.startedPreloading = true;
      return this.asset.start(false);
    };

    Player.prototype.play = function() {
      var ref;
      if (this.playing) {
        return;
      }
      if (!this.startedPreloading) {
        this.preload();
      }
      this.playing = true;
      return (ref = this.device) != null ? ref.start() : void 0;
    };

    Player.prototype.pause = function() {
      var ref;
      if (!this.playing) {
        return;
      }
      this.playing = false;
      return (ref = this.device) != null ? ref.stop() : void 0;
    };

    Player.prototype.togglePlayback = function() {
      if (this.playing) {
        return this.pause();
      } else {
        return this.play();
      }
    };

    Player.prototype.stop = function() {
      var ref;
      this.pause();
      this.asset.stop();
      return (ref = this.device) != null ? ref.destroy() : void 0;
    };

    Player.prototype.seek = function(timestamp) {
      var ref;
      if ((ref = this.device) != null) {
        ref.stop();
      }
      this.queue.once('ready', (function(_this) {
        return function() {
          var ref1, ref2;
          if ((ref1 = _this.device) != null) {
            ref1.seek(_this.currentTime);
          }
          if (_this.playing) {
            return (ref2 = _this.device) != null ? ref2.start() : void 0;
          }
        };
      })(this));
      timestamp = (timestamp / 1000) * this.format.sampleRate;
      timestamp = this.asset.decoder.seek(timestamp);
      this.currentTime = timestamp / this.format.sampleRate * 1000 | 0;
      this.queue.reset();
      return this.currentTime;
    };

    Player.prototype.startPlaying = function() {
      var frame, frameOffset;
      frame = this.queue.read();
      frameOffset = 0;
      this.device = new AudioDevice(this.format.sampleRate, this.format.channelsPerFrame);
      this.device.on('timeUpdate', (function(_this) {
        return function(currentTime) {
          _this.currentTime = currentTime;
          return _this.emit('progress', _this.currentTime);
        };
      })(this));
      this.refill = (function(_this) {
        return function(buffer) {
          var bufferOffset, filter, i, j, k, len, max, ref, ref1;
          if (!_this.playing) {
            return;
          }
          if (!frame) {
            frame = _this.queue.read();
            frameOffset = 0;
          }
          bufferOffset = 0;
          while (frame && bufferOffset < buffer.length) {
            max = Math.min(frame.length - frameOffset, buffer.length - bufferOffset);
            for (i = j = 0, ref = max; j < ref; i = j += 1) {
              buffer[bufferOffset++] = frame[frameOffset++];
            }
            if (frameOffset === frame.length) {
              frame = _this.queue.read();
              frameOffset = 0;
            }
          }
          ref1 = _this.filters;
          for (k = 0, len = ref1.length; k < len; k++) {
            filter = ref1[k];
            filter.process(buffer);
          }
          if (!frame) {
            if (_this.queue.ended) {
              _this.currentTime = _this.duration;
              _this.emit('progress', _this.currentTime);
              _this.emit('end');
              _this.stop();
            } else {
              _this.device.stop();
            }
          }
        };
      })(this);
      this.device.on('refill', this.refill);
      if (this.playing) {
        this.device.start();
      }
      return this.emit('ready');
    };

    Player.prototype.destroy = function() {
      var ref, ref1;
      this.stop();
      if ((ref = this.device) != null) {
        ref.off();
      }
      if ((ref1 = this.asset) != null) {
        ref1.destroy();
      }
      return this.off();
    };

    return Player;

  })(EventEmitter);

  module.exports = Player;

}).call(this);

},{"./asset":1,"./core/events":8,"./device":20,"./filters/balance":25,"./filters/volume":26,"./queue":28}],28:[function(require,module,exports){
// Generated by CoffeeScript 1.11.1
(function() {
  var EventEmitter, Queue,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('./core/events');

  Queue = (function(superClass) {
    extend(Queue, superClass);

    function Queue(asset) {
      this.asset = asset;
      this.write = bind(this.write, this);
      this.readyMark = 64;
      this.finished = false;
      this.buffering = true;
      this.ended = false;
      this.buffers = [];
      this.asset.on('data', this.write);
      this.asset.on('end', (function(_this) {
        return function() {
          return _this.ended = true;
        };
      })(this));
      this.asset.decodePacket();
    }

    Queue.prototype.write = function(buffer) {
      if (buffer) {
        this.buffers.push(buffer);
      }
      if (this.buffering) {
        if (this.buffers.length >= this.readyMark || this.ended) {
          this.buffering = false;
          return this.emit('ready');
        } else {
          return this.asset.decodePacket();
        }
      }
    };

    Queue.prototype.read = function() {
      if (this.buffers.length === 0) {
        return null;
      }
      this.asset.decodePacket();
      return this.buffers.shift();
    };

    Queue.prototype.reset = function() {
      this.buffers.length = 0;
      this.buffering = true;
      return this.asset.decodePacket();
    };

    return Queue;

  })(EventEmitter);

  module.exports = Queue;

}).call(this);

},{"./core/events":8}],29:[function(require,module,exports){
var AVBuffer, EventEmitter, FileSource,
  __hasProp = {}.hasOwnProperty,
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

EventEmitter = require('../../core/events');

AVBuffer = require('../../core/buffer');

FileSource = (function(_super) {
  __extends(FileSource, _super);

  function FileSource(file) {
    this.file = file;
    if (typeof FileReader === "undefined" || FileReader === null) {
      return this.emit('error', 'This browser does not have FileReader support.');
    }
    this.offset = 0;
    this.length = this.file.size;
    this.chunkSize = 1 << 20;
    this.file[this.slice = 'slice'] || this.file[this.slice = 'webkitSlice'] || this.file[this.slice = 'mozSlice'];
  }

  FileSource.prototype.start = function() {
    if (this.reader) {
      if (!this.active) {
        return this.loop();
      }
    }
    this.reader = new FileReader;
    this.active = true;
    this.reader.onload = (function(_this) {
      return function(e) {
        var buf;
        buf = new AVBuffer(new Uint8Array(e.target.result));
        _this.offset += buf.length;
        _this.emit('data', buf);
        _this.active = false;
        if (_this.offset < _this.length) {
          return _this.loop();
        }
      };
    })(this);
    this.reader.onloadend = (function(_this) {
      return function() {
        if (_this.offset === _this.length) {
          _this.emit('end');
          return _this.reader = null;
        }
      };
    })(this);
    this.reader.onerror = (function(_this) {
      return function(e) {
        return _this.emit('error', e);
      };
    })(this);
    this.reader.onprogress = (function(_this) {
      return function(e) {
        return _this.emit('progress', (_this.offset + e.loaded) / _this.length * 100);
      };
    })(this);
    return this.loop();
  };

  FileSource.prototype.loop = function() {
    var blob, endPos;
    this.active = true;
    endPos = Math.min(this.offset + this.chunkSize, this.length);
    blob = this.file[this.slice](this.offset, endPos);
    return this.reader.readAsArrayBuffer(blob);
  };

  FileSource.prototype.pause = function() {
    var _ref;
    this.active = false;
    try {
      return (_ref = this.reader) != null ? _ref.abort() : void 0;
    } catch (_error) {}
  };

  FileSource.prototype.reset = function() {
    this.pause();
    return this.offset = 0;
  };

  return FileSource;

})(EventEmitter);

module.exports = FileSource;

},{"../../core/buffer":6,"../../core/events":8}],30:[function(require,module,exports){
var AVBuffer, EventEmitter, HTTPSource,
  __hasProp = {}.hasOwnProperty,
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

EventEmitter = require('../../core/events');

AVBuffer = require('../../core/buffer');

HTTPSource = (function(_super) {
  __extends(HTTPSource, _super);

  function HTTPSource(url, opts) {
    this.url = url;
    this.opts = opts != null ? opts : {};
    this.chunkSize = 1 << 20;
    this.inflight = false;
    if (this.opts.length) {
      this.length = this.opts.length;
    }
    this.reset();
  }

  HTTPSource.prototype.start = function() {
    if (this.length) {
      if (!this.inflight) {
        return this.loop();
      }
    }
    this.inflight = true;
    this.xhr = new XMLHttpRequest();
    this.xhr.onload = (function(_this) {
      return function(event) {
        _this.length = parseInt(_this.xhr.getResponseHeader("Content-Length"));
        _this.inflight = false;
        return _this.loop();
      };
    })(this);
    this.xhr.onerror = (function(_this) {
      return function(err) {
        _this.pause();
        return _this.emit('error', err);
      };
    })(this);
    this.xhr.onabort = (function(_this) {
      return function(event) {
        return _this.inflight = false;
      };
    })(this);
    this.xhr.open("HEAD", this.url, true);
    return this.xhr.send(null);
  };

  HTTPSource.prototype.loop = function() {
    var endPos;
    if (this.inflight || !this.length) {
      return this.emit('error', 'Something is wrong in HTTPSource.loop');
    }
    this.inflight = true;
    this.xhr = new XMLHttpRequest();
    this.xhr.onload = (function(_this) {
      return function(event) {
        var buf, buffer, i, txt, _i, _ref;
        if (_this.xhr.response) {
          buf = new Uint8Array(_this.xhr.response);
        } else {
          txt = _this.xhr.responseText;
          buf = new Uint8Array(txt.length);
          for (i = _i = 0, _ref = txt.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
            buf[i] = txt.charCodeAt(i) & 0xff;
          }
        }
        buffer = new AVBuffer(buf);
        _this.offset += buffer.length;
        _this.emit('data', buffer);
        if (_this.offset >= _this.length) {
          _this.emit('end');
        }
        _this.inflight = false;
        if (!(_this.offset >= _this.length)) {
          return _this.loop();
        }
      };
    })(this);
    this.xhr.onprogress = (function(_this) {
      return function(event) {
        return _this.emit('progress', (_this.offset + event.loaded) / _this.length * 100);
      };
    })(this);
    this.xhr.onerror = (function(_this) {
      return function(err) {
        _this.emit('error', err);
        return _this.pause();
      };
    })(this);
    this.xhr.onabort = (function(_this) {
      return function(event) {
        return _this.inflight = false;
      };
    })(this);
    this.xhr.open("GET", this.url, true);
    this.xhr.responseType = "arraybuffer";
    endPos = Math.min(this.offset + this.chunkSize, this.length - 1);
    this.xhr.setRequestHeader("If-None-Match", "webkit-no-cache");
    this.xhr.setRequestHeader("Range", "bytes=" + this.offset + "-" + endPos);
    this.xhr.overrideMimeType('text/plain; charset=x-user-defined');
    return this.xhr.send(null);
  };

  HTTPSource.prototype.pause = function() {
    var _ref;
    this.inflight = false;
    return (_ref = this.xhr) != null ? _ref.abort() : void 0;
  };

  HTTPSource.prototype.reset = function() {
    this.pause();
    return this.offset = 0;
  };

  return HTTPSource;

})(EventEmitter);

module.exports = HTTPSource;

},{"../../core/buffer":6,"../../core/events":8}],31:[function(require,module,exports){
(function (global){
// Generated by CoffeeScript 1.11.1
(function() {
  var AVBuffer, BufferList, BufferSource, EventEmitter,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  EventEmitter = require('../core/events');

  BufferList = require('../core/bufferlist');

  AVBuffer = require('../core/buffer');

  BufferSource = (function(superClass) {
    var clearImmediate, setImmediate;

    extend(BufferSource, superClass);

    function BufferSource(input) {
      this.loop = bind(this.loop, this);
      if (input instanceof BufferList) {
        this.list = input;
      } else {
        this.list = new BufferList;
        this.list.append(new AVBuffer(input));
      }
      this.paused = true;
    }

    setImmediate = global.setImmediate || function(fn) {
      return global.setTimeout(fn, 0);
    };

    clearImmediate = global.clearImmediate || function(timer) {
      return global.clearTimeout(timer);
    };

    BufferSource.prototype.start = function() {
      this.paused = false;
      return this._timer = setImmediate(this.loop);
    };

    BufferSource.prototype.loop = function() {
      this.emit('progress', (this.list.numBuffers - this.list.availableBuffers + 1) / this.list.numBuffers * 100 | 0);
      this.emit('data', this.list.first);
      if (this.list.advance()) {
        return setImmediate(this.loop);
      } else {
        return this.emit('end');
      }
    };

    BufferSource.prototype.pause = function() {
      clearImmediate(this._timer);
      return this.paused = true;
    };

    BufferSource.prototype.reset = function() {
      this.pause();
      return this.list.rewind();
    };

    return BufferSource;

  })(EventEmitter);

  module.exports = BufferSource;

}).call(this);

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})

},{"../core/buffer":6,"../core/bufferlist":7,"../core/events":8}],32:[function(require,module,exports){
var key, val, _ref;

_ref = require('./src/aurora');
for (key in _ref) {
  val = _ref[key];
  exports[key] = val;
}

require('./src/devices/webaudio');

require('./src/devices/mozilla');

},{"./src/aurora":2,"./src/devices/mozilla":21,"./src/devices/webaudio":23}]},{},[32])(32)
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 201768 characters]
