Hotfix for reading song data for FT.

master
sigonasr2 4 years ago
parent a1c5618b12
commit ade1efb5b5
  1. BIN
      image.png
  2. 25
      src/main/java/com/example/demo/Controller.java

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

@ -240,6 +240,7 @@ public class Controller {
float lowestMatching = Integer.MAX_VALUE; float lowestMatching = Integer.MAX_VALUE;
SongData matchingSong = null; SongData matchingSong = null;
//There are 2304 pixels total. Once 2188 match, we'll call it good. //There are 2304 pixels total. Once 2188 match, we'll call it good.
if (MyRobot.FUTURETONE) {
for (SongData song : DemoApplication.songs) { for (SongData song : DemoApplication.songs) {
float matching = 0; float matching = 0;
for (int y=0;y<288;y++) { for (int y=0;y<288;y++) {
@ -262,6 +263,30 @@ public class Controller {
}*/ }*/
} }
} else {
for (SongData song : DemoApplication.FTsongs) {
float matching = 0;
for (int y=0;y<288;y++) {
for (int x=0;x<8;x++) {
Color p2 = song.data[(y*8)+x];
Color p1 = new Color(img.getRGB(x+352, y+288));
matching+=ImageUtils.distanceToColor(p2,p1);
}
}
if (matching<lowestMatching) {
lowestMatching=matching;
matchingSong = song;
}
/*try {
PrintStream out = new PrintStream(System.out, true, "UTF-8");
out.println("Comparing to "+song.song+": "+matching);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}*/
}
}
//System.out.println("Lowest: "+lowestMatching); //System.out.println("Lowest: "+lowestMatching);
return matchingSong.song; return matchingSong.song;
} }

Loading…
Cancel
Save