@audio/encode-wavpack 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/encode-wavpack",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Encode PCM audio samples to WavPack (.wv) with libwavpack WASM",
5
5
  "type": "module",
6
6
  "main": "wavpack-encode.js",
package/wavpack-encode.js CHANGED
@@ -77,7 +77,7 @@ export default async function wavpack(opts = {}) {
77
77
  for (let i = 0; i < n; i++) for (let c = 0; c < channels; c++) {
78
78
  let v = chData[c][i]
79
79
  let s = v < 0 ? v * div : v * max
80
- i32[k++] = s < -div ? -div : s > max ? max : Math.round(s)
80
+ i32[k++] = s < -div ? -div : s > max ? max : Math.floor(s + 0.5) // floor(x + 0.5): Math.round for every float32 sample, several times faster in V8
81
81
  }
82
82
  }
83
83
  if (!m._we_pack(h, n)) throw Error(readError(m, h))