fix: schedule SpessaSynth noteOn by startTime via setTimeout
Root cause: timeline play passes exactAudioTime as 4th param which SpessaSynth interprets as enableReverh (boolean). All notes at T=0. Fix: compute delay = startTime - ctx.currentTime, use setTimeout to call noteOn(channel, pitch, vel) at correct future time. Never pass startTime to noteOn() — SpessaSynth doesn't support it.
This commit is contained in:
@@ -159,13 +159,18 @@
|
|||||||
}
|
}
|
||||||
if (channel === undefined) channel = 0;
|
if (channel === undefined) channel = 0;
|
||||||
const durSec = durationMs / 1000;
|
const durSec = durationMs / 1000;
|
||||||
try {
|
const now = ctx.currentTime;
|
||||||
_synthInstance.noteOn(channel, midiPitch, midiVel);
|
const delay = (typeof startTime === 'number' && startTime > now) ? (startTime - now) : 0;
|
||||||
setTimeout(() => { try { _synthInstance.noteOff(channel, midiPitch); } catch (e) {} }, durSec * 1000);
|
const doNote = () => {
|
||||||
} catch (e) {
|
try {
|
||||||
console.warn("[SonicSF] SpessaSynth noteOn error, oscillator fallback:", e);
|
_synthInstance.noteOn(channel, midiPitch, midiVel);
|
||||||
this._playNoteOsc(note, velocity, durationMs, startTime, program, null, channel, synthEngine);
|
setTimeout(() => { try { _synthInstance.noteOff(channel, midiPitch); } catch (e) {} }, durSec * 1000);
|
||||||
}
|
} catch (e) {
|
||||||
|
console.warn("[SonicSF] SpessaSynth noteOn error:", e);
|
||||||
|
this._playNoteOsc(note, velocity, durationMs, startTime, program, null, channel, synthEngine);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (delay > 0) setTimeout(doNote, delay * 1000); else doNote();
|
||||||
},
|
},
|
||||||
|
|
||||||
_playNoteOsc: function (note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine) {
|
_playNoteOsc: function (note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine) {
|
||||||
|
|||||||
Reference in New Issue
Block a user