dist/wavefile.js
function decodeSample_(nibble) {
  /** @type {number} */
  let difference = 0;
  if (nibble & 4) {
    difference += decoderStep_;
  }
  if (nibble & 2) {
    difference += decoderStep_ >> 1;
  }
  if (nibble & 1) {
    difference += decoderStep_ >> 2;
  }
  difference += decoderStep_ >> 3;
  if (nibble & 8) {
    difference = -difference;
  }
  decoderPredicted_ += difference;
  if (decoderPredicted_ > 32767) {
    decoderPredicted_ = 32767;
  } else if (decoderPredicted_ < -32767) {
    decoderPredicted_ = -32767;
  }
  updateDecoder_(nibble);
  return decoderPredicted_;
}
function decodeSample_(nibble) {
  /** @type {number} */
  let difference = 0;
  if (nibble & 4) {
    difference += decoderStep_;
  }
  if (nibble & 2) {
    difference += decoderStep_ >> 1;
  }
  if (nibble & 1) {
    difference += decoderStep_ >> 2;
  }
  difference += decoderStep_ >> 3;
  if (nibble & 8) {
    difference = -difference;
  }
  decoderPredicted_ += difference;
  if (decoderPredicted_ > 32767) {
    decoderPredicted_ = 32767;
  } else if (decoderPredicted_ < -32767) {
    decoderPredicted_ = -32767;
  }
  updateDecoder_(nibble);
  return decoderPredicted_;
}
function decodeSample_ ( nibble ) { /** @type {number} */ let difference = 0 ; if ( nibble & 4 ) { difference += decoderStep_ ; } if ( nibble & 2 ) { difference += decoderStep_ >> 1 ; } if ( nibble & 1 ) { difference += decoderStep_ >> 2 ; } difference += decoderStep_ >> 3 ; if ( nibble & 8 ) { difference = - difference ; } decoderPredicted_ += difference ; if ( decoderPredicted_ > 32767 ) { decoderPredicted_ = 32767 ; } else if ( decoderPredicted_ < - 32767 ) { decoderPredicted_ = - 32767 ; } updateDecoder_ ( nibble ) ; return decoderPredicted_ ; }
Decode a 4-bit ADPCM sample into a 16-bit PCM sample.
@param {number} nibble A 4-bit adpcm sample.
@return {number}
@private
Decode a 4 - bit ADPCM sample into a 16 - bit PCM sample .