@entros/pulse-sdk 1.5.1 → 1.5.2

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.
package/dist/index.js CHANGED
@@ -652,6 +652,7 @@ async function getMeyda() {
652
652
  }
653
653
  return meydaModule.default ?? meydaModule;
654
654
  }
655
+ var F0_YIELD_EVERY_N_FRAMES = 16;
655
656
  async function detectF0Contour(samples, sampleRate) {
656
657
  const detect = await getPitchDetector(sampleRate);
657
658
  const frameSize = getFrameSize(sampleRate);
@@ -678,6 +679,9 @@ async function detectF0Contour(samples, sampleRate) {
678
679
  sum += (frame[j] ?? 0) * (frame[j] ?? 0);
679
680
  }
680
681
  amplitudes.push(Math.sqrt(sum / frame.length));
682
+ if (i > 0 && i < numFrames - 1 && i % F0_YIELD_EVERY_N_FRAMES === 0) {
683
+ await yieldToMainThread();
684
+ }
681
685
  }
682
686
  return { f0, amplitudes, periods };
683
687
  }