song player file pitch thing

This commit is contained in:
Chayapak 2023-08-27 20:51:04 +07:00
parent 0923cbfc4d
commit 623c569c99

View file

@ -1,6 +1,7 @@
package com.github.hhhzzzsss.songplayer.conversion; package com.github.hhhzzzsss.songplayer.conversion;
import com.github.hhhzzzsss.songplayer.Util; import com.github.hhhzzzsss.songplayer.Util;
import com.github.hhhzzzsss.songplayer.playing.SongHandler;
import com.github.hhhzzzsss.songplayer.song.Note; import com.github.hhhzzzsss.songplayer.song.Note;
import com.github.hhhzzzsss.songplayer.song.Song; import com.github.hhhzzzsss.songplayer.song.Song;
@ -52,7 +53,7 @@ public class SPConverter {
int noteId = buffer.getShort(); int noteId = buffer.getShort();
if (noteId >= 0 && noteId < 400) { if (noteId >= 0 && noteId < 400) {
time += getVarLong(buffer); time += getVarLong(buffer);
song.add(new Note(noteId, time)); song.add(new Note(noteId + SongHandler.getInstance().pitch, time));
} }
else if ((noteId & 0xFFFF) == 0xFFFF) { else if ((noteId & 0xFFFF) == 0xFFFF) {
break; break;
@ -82,7 +83,7 @@ public class SPConverter {
song.sort(); song.sort();
long prevTime = 0; long prevTime = 0;
for (Note note : song.notes) { for (Note note : song.notes) {
writeShort(os, note.noteId); writeShort(os, note.noteId + SongHandler.getInstance().pitch);
writeVarLong(os, note.time - prevTime); writeVarLong(os, note.time - prevTime);
prevTime = note.time; prevTime = note.time;
} }