@audio/shift-pvoc 1.1.4 → 1.1.5

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/audio.js +6 -8
  2. package/index.js +1 -1
  3. package/package.json +2 -2
package/audio.js CHANGED
@@ -1,11 +1,9 @@
1
1
  // audio manifest — wraps the phase-vocoder pitch shift per @audio/compile CONTRACT.
2
2
  // The kernel streams (stftStream writer), but write(chunk) returns variable-length
3
- // bursts (frame/hop bookkeeping is not 1:1 with input chunking) — a per-channel FIFO
4
- // absorbs that into the fixed equal-frames-in/out shape §process requires, at a fixed
5
- // extra delay. Measured end-to-end through this manifest (tone-burst envelope
6
- // cross-correlation at ratio 1, blocks 128–4096): 2048 samples = 1× frameSize =
7
- // 4× hopSize, block-size-invariant, confirmed independently by input/output
8
- // sample-count bookkeeping (steady-state deficit 2048).
3
+ // bursts: fourier-transform/stft holds a sample back at most FRAME samples, with output
4
+ // sample j aligned to input sample j. A per-channel FIFO primed with FRAME zeros turns
5
+ // the bursts into the fixed equal-frames-in/out shape §process requires: it never runs
6
+ // dry, so the delay is exactly FRAME under any block size (pinned in test.js).
9
7
  //
10
8
  // `semitones` is live: the writer is constructed with a function ratio (the kernel
11
9
  // samples it per analysis frame via makeFrameRatio), reading a cell this manifest
@@ -15,9 +13,9 @@
15
13
  import vocoderFn from './index.js'
16
14
 
17
15
  const FRAME = 2048, HOP = 512
18
- const LATENCY = 2048
16
+ const LATENCY = FRAME
19
17
 
20
- function makeFifo() { return { buf: new Float32Array(1 << 14), len: 0 } }
18
+ function makeFifo() { return { buf: new Float32Array(1 << 14), len: LATENCY } } // primed with zeros
21
19
  function fifoPush(f, chunk) {
22
20
  if (!chunk.length) return
23
21
  let need = f.len + chunk.length
package/index.js CHANGED
@@ -10,7 +10,7 @@ import { makeFrameRatio, wrapPhase, scatterGated } from '@audio/spectral-pvoc'
10
10
  function process(mag, phase, state, ctx) {
11
11
  if (!state.fr) state.fr = makeFrameRatio(ctx.ratioFn || ctx.ratio || 1)
12
12
  let { half, hop } = ctx
13
- let ratio = state.fr.at(ctx.frameStart, ctx.sampleRate)
13
+ let ratio = state.fr.at(ctx.frameStart + ctx.N / 2, ctx.sampleRate)
14
14
  if (!state.prev) {
15
15
  state.prev = new Float64Array(half + 1)
16
16
  state.syn = new Float64Array(half + 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/shift-pvoc",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Canonical phase vocoder (Bernsee/SMB) pitch shift",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@audio/spectral-pvoc": "^1.0.0",
25
- "fourier-transform": "^2.3.0"
25
+ "fourier-transform": "^2.4.2"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"