Hotfix for reading song data for FT.

master
sigonasr2 4 years ago
parent a1c5618b12
commit ade1efb5b5
  1. BIN
      image.png
  2. 61
      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,27 +240,52 @@ public class Controller {
float lowestMatching = Integer.MAX_VALUE;
SongData matchingSong = null;
//There are 2304 pixels total. Once 2188 match, we'll call it good.
for (SongData song : DemoApplication.songs) {
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 (MyRobot.FUTURETONE) {
for (SongData song : DemoApplication.songs) {
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();
}*/
}
if (matching<lowestMatching) {
lowestMatching=matching;
matchingSong = song;
} 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();
}*/
}
/*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);
return matchingSong.song;

Loading…
Cancel
Save