fix: reduce MIDI playback crackling (no per-note prog reload, underrun-proof render loop, gentle stopAll)

This commit is contained in:
2026-07-31 10:49:31 +07:00
parent 05e6a467d8
commit ad5cda5a40
2 changed files with 24 additions and 28 deletions
+4 -8
View File
@@ -29,14 +29,10 @@ class FluidSynthBridge extends AudioWorkletProcessor {
si++;
if (si >= qL[fi].length) { fi++; si = 0; }
}
if (fi > 0) { this.leftQ.splice(0, fi); this.rightQ.splice(0, fi); }
if (this.called % 50 === 0) {
var pk = 0;
for (var j = 0; j < len; j++) {
var v = out[0][j] > 0 ? out[0][j] : -out[0][j];
if (v > pk) pk = v;
}
if (pk > 0) console.log('[FluidSynth:bridge] process #' + this.called + ' peak:' + pk.toFixed(6) + ' q:' + qL.length);
if (fi > 0) {
this.leftQ.splice(0, fi);
this.rightQ.splice(0, fi);
this.port.postMessage({ type: 'CONSUMED', n: fi });
}
return true;
}