Thank you.
Here is the code:
import processing.serial.*;
import ddf.minim.*;
//import processing.video.*;
Minim minim;
AudioPlayer player;
Serial myPort;
String val = null;
void setup() {
minim = new Minim(this);
size(640, 480);
String portName = Serial.list()[2];
myPort = new Serial(this, portName, 9600);
myPort.clear();
myPort.bufferUntil('\n');
player = minim.loadFile("groove.mp3");
}
void serialEvent (Serial myPort) {
while (myPort.available() > 0) {
val=myPort.readStringUntil('\n');
if (val != null) {
val = val.trim(); // let's remove whitespace characters
if (val.equals("L")) {
if (player.isPlaying() == true) {
player.pause();
println("in the Loud if statement");
}
}
//} else {
if (player.isPlaying() == false) {
player.play();
println("in the Quiet if statement");
//println(val);
}
}
}
}
}
void draw() {
background(0);
println(val);
}