src/framer.js
function(bufferOrArray, callback) {
    var self = this,
        ix = this.offset,
        frame = [],
        isArray = Object.prototype.toString.call( bufferOrArray) === '[object Array]';

    self.frameIx = 0;

    while (ix < bufferOrArray.length) {
      var value = isArray ? bufferOrArray[ix] : bufferOrArray['read' + self.sampleType](ix); 

      frame.push(this.map ? this.map[value] : value);

      if (frame.length == this.frameSize || ix+self.wordSize == bufferOrArray.length) finishFrame(frame);

      ix += self.wordSize;
    }

    // Did we not process any frames at all for some reason?
    if (this.frameIx == 0) callback(undefined);

    function finishFrame(frame) {
      if (this.scale) frame = frame.map(function (s, ix) {return s * self.scale[ix];});

      callback(frame, self.frameIx);

      if (ix != bufferOrArray.length - self.wordSize)
      {
          ix -= (self.frameSize - self.frameStep) * self.wordSize;

          self.frameIx++;
          frame.length = 0;
      }
    }
  }
function(bufferOrArray, callback) {
    var self = this,
        ix = this.offset,
        frame = [],
        isArray = Object.prototype.toString.call( bufferOrArray) === '[object Array]';

    self.frameIx = 0;

    while (ix < bufferOrArray.length) {
      var value = isArray ? bufferOrArray[ix] : bufferOrArray['read' + self.sampleType](ix); 

      frame.push(this.map ? this.map[value] : value);

      if (frame.length == this.frameSize || ix+self.wordSize == bufferOrArray.length) finishFrame(frame);

      ix += self.wordSize;
    }

    // Did we not process any frames at all for some reason?
    if (this.frameIx == 0) callback(undefined);

    function finishFrame(frame) {
      if (this.scale) frame = frame.map(function (s, ix) {return s * self.scale[ix];});

      callback(frame, self.frameIx);

      if (ix != bufferOrArray.length - self.wordSize)
      {
          ix -= (self.frameSize - self.frameStep) * self.wordSize;

          self.frameIx++;
          frame.length = 0;
      }
    }
  }
function ( bufferOrArray , callback ) { var self = this , ix = this . offset , frame = [ ] , isArray = Object . prototype . toString . call ( bufferOrArray ) === '[object Array]' ; self . frameIx = 0 ; while ( ix < bufferOrArray . length ) { var value = isArray ? bufferOrArray [ ix ] : bufferOrArray [ 'read' + self . sampleType ] ( ix ) ; frame . push ( this . map ? this . map [ value ] : value ) ; if ( frame . length == this . frameSize || ix + self . wordSize == bufferOrArray . length ) finishFrame ( frame ) ; ix += self . wordSize ; } // Did we not process any frames at all for some reason? if ( this . frameIx == 0 ) callback ( undefined ) ; function finishFrame ( frame ) { if ( this . scale ) frame = frame . map ( function ( s , ix ) { return s * self . scale [ ix ] ; } ) ; callback ( frame , self . frameIx ) ; if ( ix != bufferOrArray . length - self . wordSize ) { ix -= ( self . frameSize - self . frameStep ) * self . wordSize ; self . frameIx ++ ; frame . length = 0 ; } } }
Frames a buffer of single-byte char values or an array of Numbers into windows of the specified size.
Frames a buffer of single - byte char values or an array of Numbers into windows of the specified size .