From 6cb824897572509ecfa0abb79db6f04d2eef1c27 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Mon, 25 Sep 2023 09:45:06 +0700 Subject: [PATCH] TEXT !! --- .../chayapak/chomens_bot/song/MidiConverter.java | 11 ++++++++++- 1 file changed, 10 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 c10a4ed..3dceca6 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 @@ -11,6 +11,7 @@ import java.util.HashMap; // Author: hhhzzzsss public class MidiConverter implements Converter { + public static final int TEXT = 0x01; public static final int TRACK_NAME = 0x03; public static final int SET_INSTRUMENT = 0xC0; public static final int SET_TEMPO = 0x51; @@ -28,6 +29,8 @@ public class MidiConverter implements Converter { String songName = null; + final StringBuilder text = new StringBuilder(); + boolean isFirst = true; ArrayList tempoEvents = new ArrayList<>(); @@ -48,12 +51,18 @@ public class MidiConverter implements Converter { isFirst = false; } + } else if (mm.getType() == TEXT) { + text.append(new String(mm.getData())); + text.append('\n'); } } } } - final Song song = new Song(name, bot, songName, null, null, null, false); + String stringText = text.toString(); + if (stringText.endsWith("\n")) stringText = stringText.substring(0, stringText.length() - 1); + + final Song song = new Song(name, bot, songName, null, null, stringText, false); tempoEvents.sort(Comparator.comparingLong(MidiEvent::getTick));