Performance optimizing for chart reading and playing of larger note charts

This commit is contained in:
Joshua Sigona 2021-10-20 13:53:14 +09:00
parent 4938f4a016
commit c131aade15
3 changed files with 27 additions and 15 deletions

View File

@ -159,7 +159,8 @@ public class Canvas extends JPanel implements AudioSpectrumListener{
} }
} }
g.setColor(NOTE_COLOR); g.setColor(NOTE_COLOR);
int noteCounter = 0; int noteCounter = LLSIG.noteCounter[i];
//System.out.println("Starting from "+noteCounter);
while (lane.noteExists(noteCounter)) { while (lane.noteExists(noteCounter)) {
Note n = lane.getNote(noteCounter); Note n = lane.getNote(noteCounter);
if (n.active||n.active2) { if (n.active||n.active2) {
@ -189,10 +190,8 @@ public class Canvas extends JPanel implements AudioSpectrumListener{
drawNote(g,MIDDLE_X-Math.cos(Math.toRadians(22.5*i))*(CLAMPED_PLAYTIME_RATIO*NOTE_DISTANCE)-NOTE_SIZE/2,MIDDLE_Y+Math.sin(Math.toRadians(22.5*i))*(CLAMPED_PLAYTIME_RATIO*NOTE_DISTANCE)-NOTE_SIZE/2,Math.min(CLAMPED_PLAYTIME_RATIO/2+0.5,1),Math.min(CLAMPED_PLAYTIME_RATIO/2+0.5,1),false); drawNote(g,MIDDLE_X-Math.cos(Math.toRadians(22.5*i))*(CLAMPED_PLAYTIME_RATIO*NOTE_DISTANCE)-NOTE_SIZE/2,MIDDLE_Y+Math.sin(Math.toRadians(22.5*i))*(CLAMPED_PLAYTIME_RATIO*NOTE_DISTANCE)-NOTE_SIZE/2,Math.min(CLAMPED_PLAYTIME_RATIO/2+0.5,1),Math.min(CLAMPED_PLAYTIME_RATIO/2+0.5,1),false);
} }
} }
if ((n.active2)&&n.getEndFrame()-LLSIG.game.musicPlayer.getPlayPosition()>LLSIG.game.NOTE_SPEED) { if ((n.active||n.active2)&&n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition()>LLSIG.game.NOTE_SPEED) {
break; //System.out.println("Lane "+i+": Stopping at note "+noteCounter);
} else
if ((n.active)&&n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition()>LLSIG.game.NOTE_SPEED) {
break; break;
} }
noteCounter++; noteCounter++;
@ -210,7 +209,7 @@ public class Canvas extends JPanel implements AudioSpectrumListener{
if (multiple) { if (multiple) {
Color drawCol = g.getColor(); Color drawCol = g.getColor();
g.setColor(multiple_col?Color.RED:Color.BLUE); g.setColor(multiple_col?Color.RED:Color.BLUE);
g.fillRoundRect((int)x,(int)(y+(ysize*NOTE_SIZE)/2),(int)(xsize*NOTE_SIZE), 8, 4, 24); g.fillRect((int)x,(int)(y+(ysize*NOTE_SIZE)/2),(int)(xsize*NOTE_SIZE), 8);
g.setColor(drawCol); g.setColor(drawCol);
} }
} }

View File

@ -40,6 +40,9 @@ public class LLSIG implements KeyListener,MouseWheelListener{
public static double beatDelay = ((1/((double)bpm/60))*1000); public static double beatDelay = ((1/((double)bpm/60))*1000);
public static boolean lastHold = false; //A toggle. Decides primary/secondary color marking. public static boolean lastHold = false; //A toggle. Decides primary/secondary color marking.
public static int[] noteCounter = new int[9];
public static List<Long> beats = new ArrayList<Long>(); public static List<Long> beats = new ArrayList<Long>();
int NOTE_SPEED = 750; //The note speed determines how early you see the note. So lowering this number increases the speed. int NOTE_SPEED = 750; //The note speed determines how early you see the note. So lowering this number increases the speed.
@ -175,7 +178,7 @@ public class LLSIG implements KeyListener,MouseWheelListener{
if (PLAYING) { if (PLAYING) {
for (int i=0;i<9;i++) { for (int i=0;i<9;i++) {
Lane l =lanes.get(i); Lane l =lanes.get(i);
l.markMissedNotes(); l.markMissedNotes(i);
/*if (!EDITMODE) { /*if (!EDITMODE) {
l.clearOutInactiveNotes(); l.clearOutInactiveNotes();
}*/ }*/
@ -476,13 +479,19 @@ public class LLSIG implements KeyListener,MouseWheelListener{
} else } else
if (PLAYING&&!EDITMODE&&!EDITOR) { if (PLAYING&&!EDITMODE&&!EDITOR) {
Lane l = lanes.get(lane); Lane l = lanes.get(lane);
if (l.noteExists()) { if (!l.keyPressed) {
Note n = l.getNote(); if (l.noteExists()) {
double diff = n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition(); Note n = l.getNote();
if (n.active&&diff<=BAD_TIMING_WINDOW) { double diff = n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition();
judgeNote(l, diff, false); if (n.active&&diff<=BAD_TIMING_WINDOW) {
n.active=false; judgeNote(l, diff, false);
n.active=false;
if (n.getNoteType()!=NoteType.HOLD) {
noteCounter[lane]++;
}
}
} }
l.keyPressed=true;
} }
} }
keyState[lane]=true; keyState[lane]=true;
@ -619,8 +628,10 @@ public class LLSIG implements KeyListener,MouseWheelListener{
if (n.getNoteType()==NoteType.HOLD&&n.active2&&!n.active) { if (n.getNoteType()==NoteType.HOLD&&n.active2&&!n.active) {
judgeNote(l, diff2, true); judgeNote(l, diff2, true);
n.active2=false; n.active2=false;
LLSIG.noteCounter[lane]++;
} }
} }
l.keyPressed=false;
} }
keyState[lane]=false; keyState[lane]=false;
} }

View File

@ -117,14 +117,15 @@ public class Lane{
} }
addQueue.clear(); addQueue.clear();
} }
public void markMissedNotes() { public void markMissedNotes(int laneNumber) {
if (LLSIG.game.PLAYING) { if (LLSIG.game.PLAYING) {
int noteCounter=0; int noteCounter=LLSIG.noteCounter[laneNumber];
while (noteExists(noteCounter)) { while (noteExists(noteCounter)) {
Note note = getNote(noteCounter); Note note = getNote(noteCounter);
double diff = note.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition(); double diff = note.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition();
double diff2 = note.getEndFrame()-LLSIG.game.musicPlayer.getPlayPosition(); double diff2 = note.getEndFrame()-LLSIG.game.musicPlayer.getPlayPosition();
if (note.getNoteType()==NoteType.HOLD&&note.active2&&!note.active&&diff2<-LLSIG.BAD_TIMING_WINDOW) { if (note.getNoteType()==NoteType.HOLD&&note.active2&&!note.active&&diff2<-LLSIG.BAD_TIMING_WINDOW) {
LLSIG.noteCounter[laneNumber]++;
note.active2=false; note.active2=false;
lastRating = TimingRating.MISS; lastRating = TimingRating.MISS;
lastNote = LLSIG.game.musicPlayer.getPlayPosition(); lastNote = LLSIG.game.musicPlayer.getPlayPosition();
@ -133,6 +134,7 @@ public class Lane{
LLSIG.LAST_MISS=LLSIG.game.musicPlayer.getPlayPosition(); LLSIG.LAST_MISS=LLSIG.game.musicPlayer.getPlayPosition();
} }
if (note.active&&diff<-LLSIG.BAD_TIMING_WINDOW) { if (note.active&&diff<-LLSIG.BAD_TIMING_WINDOW) {
LLSIG.noteCounter[laneNumber]++;
note.active=false; note.active=false;
if (note.getNoteType()==NoteType.HOLD) { if (note.getNoteType()==NoteType.HOLD) {
note.active2=false; //Count as a double miss, since we missed the first part. note.active2=false; //Count as a double miss, since we missed the first part.