New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imaadpcm

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imaadpcm - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

101

index.js

@@ -83,4 +83,3 @@ /*!

encoderPredicted = -0x8000;
}
else if (encoderPredicted > 0x7fff) {
} else if (encoderPredicted > 0x7fff) {
encoderPredicted = 0x7fff;

@@ -91,4 +90,3 @@ }

encoderIndex = 0;
}
else if (encoderIndex > 88) {
} else if (encoderIndex > 88) {
encoderIndex = 88;

@@ -100,41 +98,2 @@ }

/**
* Return the head of a ADPCM sample block.
* @param {number} sample The first sample of the block.
* @return {!Array<number>}
*/
function blockHead(sample) {
encodeSample(sample);
let adpcmSamples = [];
adpcmSamples.push(byteData.pack(sample, int16)[0]);
adpcmSamples.push(byteData.pack(sample, int16)[1]);
adpcmSamples.push(encoderIndex);
adpcmSamples.push(0);
return adpcmSamples;
}
/**
* Encode a block of 505 16-bit samples as 4-bit ADPCM samples.
* @param {!Array<number>} block A sample block of 505 samples.
* @return {!Array<number>}
*/
function encodeBlock(block) {
let adpcmSamples = blockHead(block[0]);
let x = 0;
for (let i=1; i<block.length; i++) {
x++;
if (x == 1) {
let sample2 = encodeSample(block[i]);
let sample = encodeSample(block[i + 1]);
adpcmSamples.push((sample << 4) | sample2);
} else {
x = 0;
}
}
while (adpcmSamples.length < 256) {
adpcmSamples.push(0);
}
return adpcmSamples;
}
/**
* Decode a 4-bit ADPCM sample into a 16-bit PCM sample.

@@ -176,2 +135,35 @@ * @param {number} nibble A 4-bit adpcm sample.

/**
* Return the head of a ADPCM sample block.
* @param {number} sample The first sample of the block.
* @return {!Array<number>}
*/
function blockHead(sample) {
encodeSample(sample);
let adpcmSamples = [];
adpcmSamples.push(byteData.pack(sample, int16)[0]);
adpcmSamples.push(byteData.pack(sample, int16)[1]);
adpcmSamples.push(encoderIndex);
adpcmSamples.push(0);
return adpcmSamples;
}
/**
* Encode a block of 505 16-bit samples as 4-bit ADPCM samples.
* @param {!Array<number>} block A sample block of 505 samples.
* @return {!Array<number>}
*/
function encodeBlock(block) {
let adpcmSamples = blockHead(block[0]);
for (let i=3; i<block.length; i+=2) {
let sample2 = encodeSample(block[i]);
let sample = encodeSample(block[i + 1]);
adpcmSamples.push((sample << 4) | sample2);
}
while (adpcmSamples.length < 256) {
adpcmSamples.push(0);
}
return adpcmSamples;
}
/**
* Decode a block of 256 ADPCM samples into 16-bit PCM samples.

@@ -185,3 +177,6 @@ * @param {!Array<number>} block A adpcm sample block of 256 samples.

decoderStep = stepTable[decoderIndex];
let result = [decoderPredicted];
let result = [
decoderPredicted,
byteData.unpack([block[2], block[3]], int16)
];
for (let i=4; i<block.length; i++) {

@@ -205,11 +200,7 @@ let original_sample = block[i];

let block = [];
let x = 0;
for (let i=0;i<samples.length;i++) {
if (x < 505) {
block.push(samples[i]);
x++;
} else {
for (let i=0; i<samples.length; i++) {
block.push(samples[i]);
if ((i % 505 == 0 && i != 0) || i == samples.length - 1) {
adpcmSamples = adpcmSamples.concat(encodeBlock(block));
block = [];
x = 0;
}

@@ -229,12 +220,8 @@ }

let block = [];
let x = 0;
for (let i=0; i<adpcmSamples.length; i++) {
if (x < blockAlign - 1) {
block.push(adpcmSamples[i]);
x++;
} else {
if (i % blockAlign == 0 && i != 0) {
samples = samples.concat(decodeBlock(block));
block = [];
x = 0;
}
block.push(adpcmSamples[i]);
}

@@ -241,0 +228,0 @@ return samples;

{
"name": "imaadpcm",
"version": "1.0.4",
"version": "1.1.0",
"description": "JavaScript IMA ADPCM codec.",

@@ -13,3 +13,5 @@ "homepage": "https://github.com/rochars/imaadpcm",

"audio",
"codec"
"codec",
"encode",
"decode"
],

@@ -16,0 +18,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc