Skip to content

Commit

Permalink
Fix: encode() return a even number of samples
Browse files Browse the repository at this point in the history
  • Loading branch information
rochars committed Sep 11, 2019
1 parent 0a41a01 commit 0b4e847
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## v4.1.1 (2019-09-11)
- Fix: encode() should always return a even number of samples

## v4.1.0 (2019-09-06)
- No clicks or time changes when compressing/decompressing
- Fix: Range error bug when compressing
Expand Down
6 changes: 5 additions & 1 deletion dist/imaadpcm.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ function encode(samples) {
}
block.push(samples[i]);
}
return adpcmSamples.slice(0, (samples.length/2) + 512);
let samplesLength = (samples.length / 2);
if (samplesLength % 2) {
samplesLength--;
}
return adpcmSamples.slice(0, samplesLength + 512);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion dist/imaadpcm.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ function encode(samples) {
}
block.push(samples[i]);
}
return adpcmSamples.slice(0, (samples.length/2) + 512);
let samplesLength = (samples.length / 2);
if (samplesLength % 2) {
samplesLength--;
}
return adpcmSamples.slice(0, samplesLength + 512);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions dist/imaadpcm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion dist/imaadpcm.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
}
block.push(samples[i]);
}
return adpcmSamples.slice(0, (samples.length/2) + 512);
let samplesLength = (samples.length / 2);
if (samplesLength % 2) {
samplesLength--;
}
return adpcmSamples.slice(0, samplesLength + 512);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ <h2>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Sep 06 2019 13:38:13 GMT-0300 (Hora oficial do Brasil) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 11 2019 04:25:44 GMT-0300 (Hora oficial do Brasil) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
8 changes: 6 additions & 2 deletions docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ <h1 class="page-title">index.js</h1>
}
block.push(samples[i]);
}
return adpcmSamples.slice(0, (samples.length/2) + 512);
let samplesLength = (samples.length / 2);
if (samplesLength % 2) {
samplesLength--;
}
return adpcmSamples.slice(0, samplesLength + 512);
}

/**
Expand Down Expand Up @@ -370,7 +374,7 @@ <h1 class="page-title">index.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Sep 06 2019 13:38:13 GMT-0300 (Hora oficial do Brasil) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 11 2019 04:25:44 GMT-0300 (Hora oficial do Brasil) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
8 changes: 4 additions & 4 deletions docs/module-imaadpcm.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h4 class="name" id=".decode"><span class="type-signature">(static) </span>decod

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line118">line 118</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line122">line 122</a>
</li></ul></dd>


Expand Down Expand Up @@ -258,7 +258,7 @@ <h4 class="name" id=".decodeBlock"><span class="type-signature">(static) </span>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line160">line 160</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line164">line 164</a>
</li></ul></dd>


Expand Down Expand Up @@ -560,7 +560,7 @@ <h4 class="name" id=".encodeBlock"><span class="type-signature">(static) </span>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line142">line 142</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line146">line 146</a>
</li></ul></dd>


Expand Down Expand Up @@ -712,7 +712,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Sep 06 2019 13:38:13 GMT-0300 (Hora oficial do Brasil) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 11 2019 04:25:44 GMT-0300 (Hora oficial do Brasil) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ export function encode(samples) {
}
block.push(samples[i]);
}
return adpcmSamples.slice(0, (samples.length/2) + 512);
let samplesLength = (samples.length / 2);
if (samplesLength % 2) {
samplesLength--;
}
return adpcmSamples.slice(0, samplesLength + 512);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imaadpcm",
"version": "4.1.0",
"version": "4.1.1",
"description": "IMA ADPCM codec in JavaScript.",
"homepage": "https://github.com/rochars/imaadpcm",
"author": "Rafael S. Rocha <[email protected]>",
Expand Down

0 comments on commit 0b4e847

Please sign in to comment.