From 3d2f89e10f58cea39a8975411c19440f0bd282bc Mon Sep 17 00:00:00 2001 From: hhhzzzsss Date: Fri, 31 May 2024 22:38:00 -0500 Subject: [PATCH] Cut short the starting delay of midis if too long --- .../songplayer/conversion/MidiConverter.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/conversion/MidiConverter.java b/src/main/java/com/github/hhhzzzsss/songplayer/conversion/MidiConverter.java index f36b74a..89fb227 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/conversion/MidiConverter.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/conversion/MidiConverter.java @@ -126,6 +126,17 @@ public class MidiConverter { } song.sort(); + + // Shift to beginning if delay is too long + if (!song.notes.isEmpty()) { + long shift = song.notes.get(0).time - 1000; + if (song.notes.get(0).time > 1000) { + for (Note note : song.notes) { + note.time -= shift; + } + } + song.length -= shift; + } return song; }