lib/core.js
function WaveformData(response_data, adapter) {
  /**
   * Backend adapter used to manage access to the data.
   *
   * @type {Object}
   */

  this.adapter = adapter.fromResponseData(response_data);

  /**
   * Defined segments.
   *
   * ```javascript
   * var waveform = new WaveformData({ ... }, WaveformData.adapters.object);
   *
   * console.log(waveform.segments.speakerA); // -> undefined
   *
   * waveform.set_segment(30, 90, "speakerA");
   *
   * console.log(waveform.segments.speakerA.start); // -> 30
   * ```
   *
   * @type {Object} A hash of `WaveformDataSegment` objects.
   */

  this.segments = {};

  /**
   * Defined points.
   *
   * ```javascript
   * var waveform = new WaveformData({ ... }, WaveformData.adapters.object);
   *
   * console.log(waveform.points.speakerA); // -> undefined
   *
   * waveform.set_point(30, "speakerA");
   *
   * console.log(waveform.points.speakerA.timeStamp); // -> 30
   * ```
   *
   * @type {Object} A hash of `WaveformDataPoint` objects.
   */

  this.points = {};

  this.offset(0, this.adapter.length);
}
function WaveformData(response_data, adapter) {
  /**
   * Backend adapter used to manage access to the data.
   *
   * @type {Object}
   */

  this.adapter = adapter.fromResponseData(response_data);

  /**
   * Defined segments.
   *
   * ```javascript
   * var waveform = new WaveformData({ ... }, WaveformData.adapters.object);
   *
   * console.log(waveform.segments.speakerA); // -> undefined
   *
   * waveform.set_segment(30, 90, "speakerA");
   *
   * console.log(waveform.segments.speakerA.start); // -> 30
   * ```
   *
   * @type {Object} A hash of `WaveformDataSegment` objects.
   */

  this.segments = {};

  /**
   * Defined points.
   *
   * ```javascript
   * var waveform = new WaveformData({ ... }, WaveformData.adapters.object);
   *
   * console.log(waveform.points.speakerA); // -> undefined
   *
   * waveform.set_point(30, "speakerA");
   *
   * console.log(waveform.points.speakerA.timeStamp); // -> 30
   * ```
   *
   * @type {Object} A hash of `WaveformDataPoint` objects.
   */

  this.points = {};

  this.offset(0, this.adapter.length);
}
function WaveformData ( response_data , adapter ) { /**
   * Backend adapter used to manage access to the data.
   *
   * @type {Object}
   */ this . adapter = adapter . fromResponseData ( response_data ) ; /**
   * Defined segments.
   *
   * ```javascript
   * var waveform = new WaveformData({ ... }, WaveformData.adapters.object);
   *
   * console.log(waveform.segments.speakerA); // -> undefined
   *
   * waveform.set_segment(30, 90, "speakerA");
   *
   * console.log(waveform.segments.speakerA.start); // -> 30
   * ```
   *
   * @type {Object} A hash of `WaveformDataSegment` objects.
   */ this . segments = { } ; /**
   * Defined points.
   *
   * ```javascript
   * var waveform = new WaveformData({ ... }, WaveformData.adapters.object);
   *
   * console.log(waveform.points.speakerA); // -> undefined
   *
   * waveform.set_point(30, "speakerA");
   *
   * console.log(waveform.points.speakerA.timeStamp); // -> 30
   * ```
   *
   * @type {Object} A hash of `WaveformDataPoint` objects.
   */ this . points = { } ; this . offset ( 0 , this . adapter . length ) ; }
Facade to iterate on audio waveform response.

```javascript
var waveform = new WaveformData({ ... }, WaveformData.adapters.object);

var json_waveform = new WaveformData(xhr.responseText, WaveformData.adapters.object);

var arraybuff_waveform = new WaveformData(
getArrayBufferData(),
WaveformData.adapters.arraybuffer
);
```

## Offsets

An **offset** is a non-destructive way to iterate on a subset of data.

It is the easiest way to **navigate** through data without having to deal
with complex calculations. Simply iterate over the data to display them.

*Notice*: the default offset is the entire set of data.

@param {String|ArrayBuffer|Mixed} response_data Waveform data,
to be consumed by the related adapter.
@param {WaveformData.adapter|Function} adapter Backend adapter used to manage
access to the data.
@constructor
Facade to iterate on audio waveform response .