V45.32: fix (1) latency preview MIDI keyboard - flush ring bridge sink (bridgeAudioWorklet _MAX 32 ~170ms audio cu render truoc) tai idle->active live note-on trong __clearMasterFxQueue (cung dieu kien V45.26: _liveHeldCount===0 && im lang >500ms) de note moi nghe ngay; guard _timelinePlaying (khong flush khi timeline dang play); (2) crackle VST2 tremolo/loop - overrun crossfade tich luy moi block drop cong 256 mau cap 1024 (~21ms) thay vi co dinh 64 mau (1.3ms qua ngan -> blip/wow khi drop loat block o chord nhieu voice) (tai lap tu V45.28, giu ring 32 de latency thap). v=202608311858

This commit is contained in:
2026-08-31 19:00:24 +07:00
parent 21cc8421a5
commit 5f8844637e
5 changed files with 30 additions and 11 deletions
+10 -3
View File
@@ -18,7 +18,8 @@ class BridgeAudioSinkProcessor extends AudioWorkletProcessor {
this._gain = 1.0;
this._lastOutL = 0.0;
this._lastOutR = 0.0;
this._skipFade = 0; // >0: crossfade dang chay sau overrun drop
this._skipFade = 0; // >0: con lai cua crossfade dang chay sau overrun drop
this._fadeLen = 0; // tong chieu dai crossfade hien tai (cap 1024)
this._skipFromL = 0.0;
this._skipFromR = 0.0;
this._wasUnderrun = false;
@@ -31,14 +32,19 @@ class BridgeAudioSinkProcessor extends AudioWorkletProcessor {
this._ring.push({ l: m.l, r: m.r });
while (this._ring.length > this._MAX) {
// overrun: bo block cu nhat; lan consume toi se crossfade ranh gioi
// V45.32: crossfade tich luy — moi block drop cong 256 mau fade, cap
// 1024 (~21ms) thay vi co dinh 64 mau (1.3ms qua ngan -> blip/wow khi
// drop loat block o chord nhieu voice = crackle VST2 tremolo/loop)
this._ring.shift();
this._skipFade = 64;
this._skipFade = Math.min(this._skipFade + 256, 1024);
this._fadeLen = this._skipFade;
this._stats.overruns++;
}
} else if (m.type === 'flush') {
this._ring.length = 0;
this._gain = 1.0;
this._skipFade = 0;
this._fadeLen = 0;
}
};
}
@@ -56,8 +62,9 @@ class BridgeAudioSinkProcessor extends AudioWorkletProcessor {
const avail = blk.l.length;
const take = Math.min(avail, n - w);
if (this._skipFade > 0) {
const done = this._fadeLen - this._skipFade;
for (let i = 0; i < take; i++) {
const t = i / 64;
const t = (done + i) / this._fadeLen;
L[w + i] = (this._lastOutL * (1 - t) + blk.l[i] * t) * this._gain;
R[w + i] = (this._lastOutR * (1 - t) + blk.r[i] * t) * this._gain;
}