@buffered-audio/nodes 0.15.2 → 0.16.0

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/index.js +48 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -29946,7 +29946,7 @@ async function reverseBuffer(source, dest) {
29946
29946
  // package.json
29947
29947
  var package_default = {
29948
29948
  name: "@buffered-audio/nodes",
29949
- version: "0.15.2"};
29949
+ version: "0.16.0"};
29950
29950
 
29951
29951
  // src/package-metadata.ts
29952
29952
  var PACKAGE_NAME = package_default.name;
@@ -35745,8 +35745,8 @@ function betaForBand(_bandIndex) {
35745
35745
  }
35746
35746
  function schroederTargetToDelay(magnitude, amount = 1) {
35747
35747
  const binCount = magnitude.length;
35748
- const delay = new Float32Array(binCount);
35749
- if (binCount < 2) return delay;
35748
+ const delay2 = new Float32Array(binCount);
35749
+ if (binCount < 2) return delay2;
35750
35750
  const phase2 = schroederTargetPhase(magnitude);
35751
35751
  const dOmega = Math.PI / (binCount - 1);
35752
35752
  const scale = Math.max(0, Math.min(1, amount));
@@ -35756,9 +35756,9 @@ function schroederTargetToDelay(magnitude, amount = 1) {
35756
35756
  const dPhi = (phase2[hi] ?? 0) - (phase2[lo] ?? 0);
35757
35757
  const span = (hi - lo) * dOmega;
35758
35758
  const tau = span > 0 ? -dPhi / span : 0;
35759
- delay[bin] = scale * Math.max(0, tau);
35759
+ delay2[bin] = scale * Math.max(0, tau);
35760
35760
  }
35761
- return delay;
35761
+ return delay2;
35762
35762
  }
35763
35763
  function poleRadius(halfWidth, beta) {
35764
35764
  const delta = Math.max(0, halfWidth);
@@ -35773,14 +35773,14 @@ function poleRadius(halfWidth, beta) {
35773
35773
  if (!Number.isFinite(rho)) return 0;
35774
35774
  return Math.max(0, Math.min(MAX_POLE_RADIUS, rho));
35775
35775
  }
35776
- function designDispersionAllpass(delay, order) {
35777
- const binCount = delay.length;
35776
+ function designDispersionAllpass(delay2, order) {
35777
+ const binCount = delay2.length;
35778
35778
  const poles = [];
35779
35779
  if (binCount < 2 || order <= 0) return { denominator: Float32Array.from([1]), poles };
35780
35780
  const dOmega = Math.PI / (binCount - 1);
35781
35781
  let rawHalfArea = 0;
35782
35782
  for (let bin = 0; bin < binCount - 1; bin++) {
35783
- rawHalfArea += 0.5 * ((delay[bin] ?? 0) + (delay[bin + 1] ?? 0)) * dOmega;
35783
+ rawHalfArea += 0.5 * ((delay2[bin] ?? 0) + (delay2[bin + 1] ?? 0)) * dOmega;
35784
35784
  }
35785
35785
  let naturalOrder = Math.round(rawHalfArea / Math.PI);
35786
35786
  if (naturalOrder < 0) naturalOrder = 0;
@@ -35792,9 +35792,9 @@ function designDispersionAllpass(delay, order) {
35792
35792
  }
35793
35793
  if (rawHalfArea > bandOrder * Math.PI && rawHalfArea > 0) {
35794
35794
  const areaScale = bandOrder * Math.PI / rawHalfArea;
35795
- for (let bin = 0; bin < binCount; bin++) scaled[bin] = areaScale * (delay[bin] ?? 0);
35795
+ for (let bin = 0; bin < binCount; bin++) scaled[bin] = areaScale * (delay2[bin] ?? 0);
35796
35796
  } else {
35797
- for (let bin = 0; bin < binCount; bin++) scaled[bin] = delay[bin] ?? 0;
35797
+ for (let bin = 0; bin < binCount; bin++) scaled[bin] = delay2[bin] ?? 0;
35798
35798
  constantDelay = Math.max(0, (bandOrder * Math.PI - rawHalfArea) / Math.PI);
35799
35799
  }
35800
35800
  const omegaAt = (bin) => bin * dOmega;
@@ -36243,8 +36243,8 @@ async function streamLatticeTrajectory(buffer, frameSize, hopSize, backend, addo
36243
36243
  }
36244
36244
  windowPeaks[nextFrame] = { peakMagnitude: windowPeak, headroom: amount };
36245
36245
  peakSampleIndex[nextFrame] = start + peakPos;
36246
- const delay = schroederTargetToDelay(sumMagnitude, amount);
36247
- const { denominator } = designDispersionAllpass(delay, order);
36246
+ const delay2 = schroederTargetToDelay(sumMagnitude, amount);
36247
+ const { denominator } = designDispersionAllpass(delay2, order);
36248
36248
  const reflection = stepDownToReflection(denominator);
36249
36249
  const row = new Float32Array(order);
36250
36250
  for (let section = 0; section < order; section++) row[section] = reflection[section] ?? 0;
@@ -39106,6 +39106,14 @@ function kimVocal2(options) {
39106
39106
  var CHUNK_FRAMES11 = 48e3;
39107
39107
  var READY_LINE = "READY\n";
39108
39108
  var READY_TIMEOUT_MS = 3e5;
39109
+ var VstHostExitedBeforeReadyError = class extends Error {
39110
+ constructor(code, stderr) {
39111
+ super(`vst-host exited before READY (code ${code ?? "null"}): ${stderr}`);
39112
+ this.name = "VstHostExitedBeforeReadyError";
39113
+ this.code = code;
39114
+ this.stderr = stderr;
39115
+ }
39116
+ };
39109
39117
  function spawnVstHost(binaryPath, args) {
39110
39118
  const proc = spawn(binaryPath, [...args], {
39111
39119
  stdio: ["pipe", "pipe", "pipe"]
@@ -39151,7 +39159,7 @@ function spawnVstHost(binaryPath, args) {
39151
39159
  };
39152
39160
  const onClose = (code) => {
39153
39161
  const stderrOutput = Buffer.concat(stderrChunks).toString();
39154
- fail(new Error(`vst-host exited before READY (code ${code ?? "null"}): ${stderrOutput}`));
39162
+ fail(new VstHostExitedBeforeReadyError(code, stderrOutput));
39155
39163
  };
39156
39164
  const timer = setTimeout(() => {
39157
39165
  fail(new Error(`vst-host did not emit READY within ${READY_TIMEOUT_MS}ms`));
@@ -39164,6 +39172,28 @@ function spawnVstHost(binaryPath, args) {
39164
39172
  });
39165
39173
  return { proc, stdin, stdout, stderr, ready, stderrChunks };
39166
39174
  }
39175
+ var CLEAN_WRAPPER_EXIT_CODES = /* @__PURE__ */ new Set([0, 1, 2]);
39176
+ function isRetryableInitCrash(error50) {
39177
+ return error50 instanceof VstHostExitedBeforeReadyError && !CLEAN_WRAPPER_EXIT_CODES.has(error50.code ?? -1);
39178
+ }
39179
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
39180
+ async function spawnVstHostReady(binaryPath, args, options = {}) {
39181
+ const maxAttempts = options.maxAttempts ?? 5;
39182
+ const backoffMs = options.backoffMs ?? 750;
39183
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
39184
+ const handle = spawnVstHost(binaryPath, args);
39185
+ try {
39186
+ await handle.ready;
39187
+ return handle;
39188
+ } catch (error50) {
39189
+ handle.proc.kill();
39190
+ if (attempt >= maxAttempts || !isRetryableInitCrash(error50)) throw error50;
39191
+ options.onRetry?.(attempt, error50);
39192
+ await delay(backoffMs);
39193
+ }
39194
+ }
39195
+ throw new Error(`spawnVstHostReady: exhausted ${maxAttempts} attempts without a result`);
39196
+ }
39167
39197
  async function writeStagesJson(stages) {
39168
39198
  const dir = await mkdtemp(join(tmpdir(), "vst-host-stages-"));
39169
39199
  const path2 = join(dir, "stages.json");
@@ -39283,13 +39313,11 @@ var Vst3Stream = class extends BufferedTransformStream {
39283
39313
  "--channels",
39284
39314
  String(channels)
39285
39315
  ];
39286
- const handle = spawnVstHost(this.properties.vstHostPath, args);
39287
- try {
39288
- await handle.ready;
39289
- } catch (error50) {
39290
- handle.proc.kill();
39291
- throw error50;
39292
- }
39316
+ const handle = await spawnVstHostReady(this.properties.vstHostPath, args, {
39317
+ onRetry: (failedAttempt, error50) => {
39318
+ console.error(`[vst3] vst-host init crash on attempt ${failedAttempt}, retrying: ${error50.message}`);
39319
+ }
39320
+ });
39293
39321
  await processStreamingThroughVstHost(handle, buffer, channels, sampleRate, bd);
39294
39322
  }
39295
39323
  async _teardown() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buffered-audio/nodes",
3
- "version": "0.15.2",
3
+ "version": "0.16.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {