@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 +4 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -561,6 +561,7 @@ async function getMeyda() {
|
|
|
561
561
|
}
|
|
562
562
|
return meydaModule.default ?? meydaModule;
|
|
563
563
|
}
|
|
564
|
+
var F0_YIELD_EVERY_N_FRAMES = 16;
|
|
564
565
|
async function detectF0Contour(samples, sampleRate) {
|
|
565
566
|
const detect = await getPitchDetector(sampleRate);
|
|
566
567
|
const frameSize = getFrameSize(sampleRate);
|
|
@@ -587,6 +588,9 @@ async function detectF0Contour(samples, sampleRate) {
|
|
|
587
588
|
sum += (frame[j] ?? 0) * (frame[j] ?? 0);
|
|
588
589
|
}
|
|
589
590
|
amplitudes.push(Math.sqrt(sum / frame.length));
|
|
591
|
+
if (i > 0 && i < numFrames - 1 && i % F0_YIELD_EVERY_N_FRAMES === 0) {
|
|
592
|
+
await yieldToMainThread();
|
|
593
|
+
}
|
|
590
594
|
}
|
|
591
595
|
return { f0, amplitudes, periods };
|
|
592
596
|
}
|