fix: ScriptProcessorNode fallback + worklet process() logging
- ScriptProcessorNode fallback khi AudioWorkletNode fails - Render trực tiếp trong onaudioprocess callback, không cần setInterval - Worklet log peak + queue depth mỗi 50 process() calls - Log audioCtx state + sampleRate khi init
This commit is contained in:
@@ -3,6 +3,7 @@ class FluidSynthBridge extends AudioWorkletProcessor {
|
||||
super();
|
||||
this.leftQ = [];
|
||||
this.rightQ = [];
|
||||
this.called = 0;
|
||||
this.port.onmessage = (e) => {
|
||||
const d = e.data;
|
||||
if (d.type === 'PCM') {
|
||||
@@ -15,6 +16,7 @@ class FluidSynthBridge extends AudioWorkletProcessor {
|
||||
process(inputs, outputs) {
|
||||
const out = outputs[0];
|
||||
if (!out) return true;
|
||||
this.called++;
|
||||
const len = out[0].length;
|
||||
const qL = this.leftQ;
|
||||
const qR = this.rightQ;
|
||||
@@ -28,6 +30,14 @@ class FluidSynthBridge extends AudioWorkletProcessor {
|
||||
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);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user