Using Minim to create 3 playlists to play based on input from arduino

edited March 2017 in Library Questions
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
import processing.serial.*;

Serial myPort;
int val;
Minim minim;

void setup() {
      size(512, 200, P3D);
      minim = new Minim(this);

      chrisPlaylist = new AudioPlayer [2];
      yeemunPlaylist = new AudioPlayer [3];
      foodPlaylist = new AudioPlayer [3];
      musicPlaylist = new AudioPlayer [3];

      String portName = Serial.list()[0];
      myPort = new Serial(this, portName, 9600);

      chrisPlaylist[0] = minim.loadFile("C15.aiff"); 
      chrisPlaylist[1] = minim.loadFile("C15a.aiff");

      yeemunPlaylist[0] = minim.loadFile("Y7.aiff"); 
      yeemunPlaylist[1] = minim.loadFile("Y30.aiff"); 
      yeemunPlaylist[2] = minim.loadFile("MY15a.aiff");

      foodPlaylist[0] = minim.loadFile("F7.aiff");
      foodPlaylist[1] = minim.loadFile("F15.aiff");
      foodPlaylist[2] = minim.loadFile("F30.aiff");

      musicPlaylist[0] = minim.loadFile("M7.aiff");
      musicPlaylist[1] = minim.loadFile("M15.aiff");
      musicPlaylist[2] = minim.loadFile("M30.aiff");

}

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

  if ( myPort.available() > 0) 
  {  
    val = myPort.readStringUntil('\n');        
    if (val != null) {
      String[] values = split(trim(val), ',');
      if (values.length == 4) {
          println(values[1]+"#"+values[2]+"#"+values[3]+"#");

        if (values[1].equals("Yee Mun")) {
          if ((values[2].equals("Nothing"))&&(values[3].equals("Nothing"))) {
            println("yeemunPlaylist");
            yeemunPlaylist.play();
          } else yeemunPlaylist.pause();

        if (values[1].equals("Chris")) {
          if ((values[2].equals("Nothing"))&&(values[3].equals("Nothing"))) {
            println("chrisPlaylist");
            chrisPlaylist.play();
          } else chrisPlaylist.pause();

        if (values[1].equals("Food")) {
          if ((values[2].equals("Nothing"))&&(values[3].equals("Nothing"))) {
            println("foodPlaylist");
            foodPlaylist.play();
          } else foodPlaylist.pause();

        if (values[1].equals("Music")) {
          if ((values[2].equals("Nothing"))&&(values[3].equals("Nothing"))) {
            println("musicPlaylist");
            musicPlaylist.play();
          } else musicPlaylist.pause();

  }

 void stop(){
      minim.stop();
    }

Answers

Sign In or Register to comment.