dist/wavefile.js
function decodeSample(aLawSample) {
  /** @type {number} */
  let sign = 0;
  aLawSample ^= 0x55;
  if (aLawSample & 0x80) {
    aLawSample &= ~(1 << 7);
    sign = -1;
  }
  /** @type {number} */
  let position = ((aLawSample & 0xF0) >> 4) + 4;
  /** @type {number} */
  let decoded = 0;
  if (position != 4) {
    decoded = ((1 << position) |
      ((aLawSample & 0x0F) << (position - 4)) |
      (1 << (position - 5)));
  } else {
    decoded = (aLawSample << 1)|1;
  }
  decoded = (sign === 0) ? (decoded) : (-decoded);
  return (decoded * 8) * -1;
}
function decodeSample(aLawSample) {
  /** @type {number} */
  let sign = 0;
  aLawSample ^= 0x55;
  if (aLawSample & 0x80) {
    aLawSample &= ~(1 << 7);
    sign = -1;
  }
  /** @type {number} */
  let position = ((aLawSample & 0xF0) >> 4) + 4;
  /** @type {number} */
  let decoded = 0;
  if (position != 4) {
    decoded = ((1 << position) |
      ((aLawSample & 0x0F) << (position - 4)) |
      (1 << (position - 5)));
  } else {
    decoded = (aLawSample << 1)|1;
  }
  decoded = (sign === 0) ? (decoded) : (-decoded);
  return (decoded * 8) * -1;
}
function decodeSample ( aLawSample ) { /** @type {number} */ let sign = 0 ; aLawSample ^= 0x55 ; if ( aLawSample & 0x80 ) { aLawSample &= ~ ( 1 << 7 ) ; sign = - 1 ; } /** @type {number} */ let position = ( ( aLawSample & 0xF0 ) >> 4 ) + 4 ; /** @type {number} */ let decoded = 0 ; if ( position != 4 ) { decoded = ( ( 1 << position ) | ( ( aLawSample & 0x0F ) << ( position - 4 ) ) | ( 1 << ( position - 5 ) ) ) ; } else { decoded = ( aLawSample << 1 ) | 1 ; } decoded = ( sign === 0 ) ? ( decoded ) : ( - decoded ) ; return ( decoded * 8 ) * - 1 ; }
Decode a 8-bit A-Law sample as 16-bit PCM.
@param {number} aLawSample The 8-bit A-Law sample
@return {number}
Decode a 8 - bit A - Law sample as 16 - bit PCM .