@k13engineering/rubberband 0.0.5 → 0.0.6

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.
Files changed (2) hide show
  1. package/dist/lib/index.js +10 -1
  2. package/package.json +1 -1
package/dist/lib/index.js CHANGED
@@ -55,6 +55,10 @@ const createRubberbandWrapper = ({
55
55
  throw new Error("plane length exceeds max buffer size");
56
56
  }
57
57
 
58
+ if (plane.length !== sampleCount) {
59
+ throw new Error("all planes must have the same length");
60
+ }
61
+
58
62
  const channelDataPtr = channelDataPtrs[channelIndex];
59
63
  rubberbandApi.memWrite(channelDataPtr, plane);
60
64
  });
@@ -94,7 +98,12 @@ const createRubberbandWrapper = ({
94
98
  let planes/*: Float32Array[]*/ = [];
95
99
 
96
100
  channelDataPtrs.forEach((channelDataPtr) => {
97
- const plane = rubberbandApi.memReadF32(channelDataPtr, samplesReceived);
101
+ // memReadF32 returns a view of the WASM memory, so we need to copy it out
102
+ const stolenPlane = rubberbandApi.memReadF32(channelDataPtr, samplesReceived);
103
+
104
+ const plane = new Float32Array(samplesReceived);
105
+ plane.set(stolenPlane);
106
+
98
107
  planes = [...planes, plane];
99
108
  });
100
109
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.5",
2
+ "version": "0.0.6",
3
3
  "name": "@k13engineering/rubberband",
4
4
  "type": "module",
5
5
  "description": "Rubberband wrapper for Node.js",