Adding more teams?

edited January 2016 in Library Questions

The hole point of my code is to read score from the Excel ark, everytime i press P, then compare the numbers, to see which team is the team with the highest score.

Each team has as their own track, and the team with the highest score, it is their song to be played.

But I can't figure out how to add more than 2 teams. Any help would be appreciated.

My code looks like this:

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

Minim minim;

AudioPlayer team1;
AudioPlayer team2;

WaveformRenderer waveform;
XlsReader reader;

int team1_player;
int team2_player;

int team1_point = 0;
int team2_point = 0;

int team1_isPlaying = 0;
int team2_isPlaying = 0;

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

  minim = new Minim(this);
  team1 = minim.loadFile("groove.mp3", 2048);
  team2 = minim.loadFile("marcus_kellis_theme.mp3", 2048);

  waveform = new WaveformRenderer();
  // see the example Recordable >> addListener for more about this
  team1.addListener(waveform);
  team2.addListener(waveform);
}

void draw()
{
  background(0);
  // see waveform.pde for an explanation of how this works
  waveform.draw();
}

void keyPressed() {
  if ( key == 'p' ) {
    reader = new XlsReader( this, "workbook.xls" );
    team1_point = reader.getInt( 2, 0 ) ;
    team2_point = reader.getInt( 2, 1 ) ;

    if (team1_isPlaying == 0 && team1_point < team2_point)  {
      team1_isPlaying = 1;
      team2_isPlaying = 0;
      team2.rewind();
      team2.pause();
      team1.loop();
    } else if (team2_isPlaying == 0 && team2_point < team1_point) {
      team1_isPlaying = 0;
      team2_isPlaying = 1;
      team1.rewind();
      team1.pause();
      team2.loop();
    }
  }
}

void stop()
{
  // always close Minim audio classes when you are done with them
  team1.close();
  team2.close();
  // always stop Minim before exiting.
  minim.stop();

  super.stop();
}

Answers

Sign In or Register to comment.