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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user