A-Law and mu-Law codecs in JavaScript.
npm install alawmulaw
npm install alawmulaw
`
Use
$3
Use the alawmulaw.js file in the /dist folder:
`html
`
Or get it from the jsDelivr CDN:
`html
`
Or get it from unpkg:
`html
`
$3
Require from 'alawmulaw'
`javascript
const alawmulaw = require('alawmulaw');
// Encode all the samples in a file
// Only 16-bit samples are supported
let aLawSamples = alawmulaw.alaw.encode(pcmSamples);
`
API
$3
`javascript
/**
* Encode a 16-bit linear PCM sample as 8-bit A-Law.
* @param {number} sample A 16-bit PCM sample
* @return {number}
*/
export function encodeSample(sample) {}
/**
* Decode a 8-bit A-Law sample as 16-bit PCM.
* @param {number} aLawSample The 8-bit A-Law sample
* @return {number}
*/
export function decodeSample(aLawSample) {}
/**
* Encode 16-bit linear PCM samples as 8-bit A-Law samples.
* @param {!Int16Array} samples A array of 16-bit PCM samples.
* @return {!Uint8Array}
*/
export function encode(samples) {}
/**
* Decode 8-bit A-Law samples into 16-bit linear PCM samples.
* @param {!Uint8Array} samples A array of 8-bit A-Law samples.
* @return {!Int16Array}
*/
export function decode(samples) {}
`
$3
`javascript
/**
* Encode a 16-bit linear PCM sample as 8-bit mu-Law.
* @param {number} sample A 16-bit PCM sample
* @return {number}
*/
export function encodeSample(sample) {}
/**
* Decode a 8-bit mu-Law sample as 16-bit PCM.
* @param {number} muLawSample The 8-bit mu-Law sample
* @return {number}
*/
export function decodeSample(muLawSample) {}
/**
* Encode 16-bit linear PCM samples into 8-bit mu-Law samples.
* @param {!Int16Array} samples A array of 16-bit PCM samples.
* @return {!Uint8Array}
*/
export function encode(samples) {}
/**
* Decode 8-bit mu-Law samples into 16-bit PCM samples.
* @param {!Uint8Array} samples A array of 8-bit mu-Law samples.
* @return {!Int16Array}
*/
export function decode(samples) {}
``