Skip leading silence in preview playback

Normalize event times to start at 0 in SoundfontMIDIPlayer,
matching the existing fix in SynthesisEngine. Prevents delay
when MIDI files have silence before the first note.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
b1rdmania
2025-12-18 23:34:06 +00:00
parent bfb96c65b5
commit f11967f8d3
+5 -1
View File
@@ -25,7 +25,11 @@ export class SoundfontMIDIPlayer {
}
async load(events: NoteEvent[]): Promise<void> {
this.events = [...events].sort((a, b) => a.time - b.time);
const sorted = [...events].sort((a, b) => a.time - b.time);
// Normalize times to start at 0 (skip leading silence)
const minTime = sorted.length > 0 ? sorted[0].time : 0;
this.events = sorted.map(e => ({ ...e, time: e.time - minTime }));
this.currentEventIndex = 0;
// Load the acoustic grand piano instrument (most versatile for MIDI playback)