@audio/denoise-core 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/stft.js +1 -0
  3. package/util.js +5 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/denoise-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Shared restoration primitives — STFT (batch/stream/analyse), noise estimation (min-stats, IMCRA), VAD, AR modeling, quality metrics",
5
5
  "type": "module",
6
6
  "sideEffects": false,
package/stft.js CHANGED
@@ -93,6 +93,7 @@ export function stftStream(process, opts) {
93
93
  ob[base + i] += sf[i] * win[i]
94
94
  nb[base + i] += win[i] * win[i]
95
95
  }
96
+ st.hi = Math.max(st.hi, st.pos + N)
96
97
  aPos += hop
97
98
  st.pos += hop
98
99
  }
package/util.js CHANGED
@@ -120,7 +120,7 @@ export function makeStreamBufs(N, nf = 0) {
120
120
  N, nf,
121
121
  ib: new Float32Array(N * 4), il: 0,
122
122
  ob: new Float32Array(N * 8), nb: new Float32Array(N * 8),
123
- pos: 0, oread: 0
123
+ pos: 0, oread: 0, hi: 0
124
124
  }
125
125
  }
126
126
 
@@ -156,9 +156,11 @@ export function take(st, upTo) {
156
156
  }
157
157
  st.oread += len
158
158
  if (st.oread > st.N * 8) {
159
+ // shift left; zero only past the high-water mark — frames extend N−hop beyond
160
+ // pos, so zeroing from pos would erase the last frame's partial overlap-add tail
159
161
  st.ob.copyWithin(0, st.oread); st.nb.copyWithin(0, st.oread)
160
- st.pos -= st.oread; st.oread = 0
161
- st.ob.fill(0, st.pos); st.nb.fill(0, st.pos)
162
+ st.pos -= st.oread; st.hi = Math.max(0, st.hi - st.oread); st.oread = 0
163
+ st.ob.fill(0, st.hi); st.nb.fill(0, st.hi)
162
164
  }
163
165
  return out
164
166
  }