* Can be used to scale a DataArray back down to fit its contents.
()
| 24 | * Can be used to scale a DataArray back down to fit its contents. |
| 25 | */ |
| 26 | rescale() { |
| 27 | if (this.length < this.data.length / 2) { |
| 28 | // Find the power of 2 size that fits the data |
| 29 | const targetLength = 1 << Math.ceil(Math.log2(this.length)); |
| 30 | const newData = new Float32Array(targetLength); |
| 31 | newData.set(this.data.subarray(0, this.length), 0); |
| 32 | this.data = newData; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * A full reset, which allocates a new underlying Float32Array at its initial |