From 4642f14acd6c0a796857677e77afdec24c093722 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:06:50 +0700 Subject: [PATCH] mabe an isFirst --- .../chipmunk/chayapak/chomens_bot/song/MidiConverter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java index caa7495..6329c15 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java @@ -28,6 +28,8 @@ public class MidiConverter implements Converter { String songName = null; + boolean isFirst = true; + ArrayList tempoEvents = new ArrayList<>(); for (Track track : sequence.getTracks()) { final int trackSize = track.size(); @@ -38,8 +40,10 @@ public class MidiConverter implements Converter { if (message instanceof MetaMessage mm) { if (mm.getType() == SET_TEMPO) { tempoEvents.add(event); - } else if (mm.getType() == TRACK_NAME) { + } else if (mm.getType() == TRACK_NAME && isFirst) { songName = new String(mm.getData()) + " (" + name + ")"; // i have put the ` (filename)` just in case the sequence is getting sus (like Track 2 for example) + + isFirst = false; } } }