Comparing ints and checking value every 5 second.

edited October 2015 in Library Questions

Hi.

I'm working on this project, where I have to import the numbers from an excel sheet, and checking which team has the highest score.

I've managed to import numbers from excel sheet and add them together. I am now in doubt about how to make sure that the check excel sheet every five seconds, and how to compare the different scores for the teams.

The goal is, that every team has different song, and the team with the highest score got to play their song.

import ddf.minim.*;
import de.bezier.data.*;

private int lastMillis = 0;

Minim minim;

AudioPlayer player1;
AudioPlayer player2;
AudioPlayer player3;
AudioPlayer player4;
AudioPlayer player5;

XlsReader reader;

int current_cell;

int team = 5;
int poster = 20;

int team1 = 0;
int team2 = 0;
int team3 = 0;
int team4 = 0;
int team5 = 0;

void setup ()
{
  size(512, 200, P3D);

  // we pass this to Minim so that it can load files from the data directory
  minim = new Minim(this);

  // loadFile will look in all the same places as loadImage does.
  // this means you can find files that are in the data folder and the 
  // sketch folder. you can also pass an absolute path, or a URL.
  player1 = minim.loadFile("marcus_kellis_theme.mp3");
  player2 = minim.loadFile("Fatbros.mp3");
  player3 = minim.loadFile("I_don't_mind.mp3");
  player4 = minim.loadFile("Unison.mp3");
  player5 = minim.loadFile("Wonder.mp3");

  reader = new XlsReader( this, "workbook.xls" );    // assumes file to be in the data folder
  for (int i = 0; i < team; i = i+1) {
    for (int j = 0; j < poster; j = j+1) {
      current_cell = (reader.getInt( j+1, i+1 ) );
      if (i == 0) {
          team1 = team1 + current_cell;
      }
      if (i == 1) {
          team2 = team2 + current_cell;
      }
      if (i == 2) {
          team3 = team3 + current_cell;
      }
      if (i == 3) {
          team4 = team4 + current_cell;
      }
      if (i == 4) {
          team5 = team5 + current_cell;
      }
    }
  }
  println(team1);
  println(team2);
  println(team3);
  println(team4);
  println(team5);
}

void draw()
{
  background(0);
  stroke(255);


  // draw the waveforms
  // the values returned by left.get() and right.get() will be between -1 and 1,
  // so we need to scale them up to see the waveform
  // note that if the file is MONO, left.get() and right.get() will return the same value
  for(int i = 0; i < player1.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player1.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player1.bufferSize(), 0, width );
    line( x1, 50 + player1.left.get(i)*50, x2, 50 + player1.left.get(i+1)*50 );
    line( x1, 150 + player1.right.get(i)*50, x2, 150 + player1.right.get(i+1)*50 );
  }
}

Answers

Sign In or Register to comment.