add an unused lyrics in midi
This commit is contained in:
parent
020bd62643
commit
ed8c89bcb2
2 changed files with 15 additions and 6 deletions
|
@ -5,15 +5,13 @@ import land.chipmunk.chayapak.chomens_bot.Bot;
|
|||
import javax.sound.midi.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
// Author: hhhzzzsss
|
||||
public class MidiConverter implements Converter {
|
||||
public static final int TEXT = 0x01;
|
||||
public static final int TRACK_NAME = 0x03;
|
||||
public static final int LYRICS = 0x05;
|
||||
public static final int SET_INSTRUMENT = 0xC0;
|
||||
public static final int SET_TEMPO = 0x51;
|
||||
public static final int NOTE_ON = 0x90;
|
||||
|
@ -26,6 +24,8 @@ public class MidiConverter implements Converter {
|
|||
}
|
||||
|
||||
public static Song getSong(Sequence sequence, String name, Bot bot) {
|
||||
final Map<Long, String> lyrics = new HashMap<>();
|
||||
|
||||
long tpq = sequence.getResolution();
|
||||
|
||||
String songName = null;
|
||||
|
@ -55,6 +55,10 @@ public class MidiConverter implements Converter {
|
|||
} else if (mm.getType() == TEXT) {
|
||||
text.append(new String(mm.getData()));
|
||||
text.append('\n');
|
||||
} else if (mm.getType() == LYRICS) {
|
||||
final String lyric = new String(mm.getMessage());
|
||||
|
||||
lyrics.put(event.getTick(), lyric);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +134,10 @@ public class MidiConverter implements Converter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lyrics.get(event.getTick()) != null) {
|
||||
song.lyrics.put(microTime / 1000L, lyrics.get(event.getTick()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ package land.chipmunk.chayapak.chomens_bot.song;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.*;
|
||||
|
||||
// Author: hhhzzzsss & _ChipMC_ but i changed most of the stuff
|
||||
public class Song {
|
||||
|
@ -18,6 +17,8 @@ public class Song {
|
|||
public long time = 0; // Time since start of song
|
||||
public long loopPosition = 200; // Milliseconds into the song to start looping
|
||||
|
||||
public final Map<Long, String> lyrics = new HashMap<>();
|
||||
|
||||
public String songName;
|
||||
public String songAuthor;
|
||||
public String songOriginalAuthor;
|
||||
|
|
Loading…
Reference in a new issue