v78: fade-in 10мс — убирает щелчок при воспроизведении

This commit is contained in:
“Naeel”
2026-05-22 21:43:00 +04:00
parent 201ca095e7
commit 80cee77afc
3 changed files with 12 additions and 4 deletions
+5 -1
View File
@@ -105,7 +105,11 @@ async function playTrimmed(blob) {
}
const src = ctx.createBufferSource();
src.buffer = buf;
src.connect(ctx.destination);
const gain = ctx.createGain();
// Fade-in 10мс — убирает щелчок при старте
gain.gain.setValueAtTime(0, ctx.currentTime);
gain.gain.linearRampToValueAtTime(1, ctx.currentTime + 0.01);
src.connect(gain).connect(ctx.destination);
src.start();
return new Promise(resolve => { src.onended = resolve; });
}