We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
https://forum.processing.org/two/discussion/comment/91924/#Comment_91924
Please edit your post, select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.
Also, is this a question or are you sharing some code?
Previous question related to minim and multiple files: https://forum.processing.org/two/discussion/comment/91684/#Comment_91684
The next arduino/Processing code could also be useful in your case: https://forum.processing.org/two/discussion/16618/processing-with-arduino-void-serialevent#Item_1
KF
sorry about the formatting. my first post
@dackdel -- Are you sharing your work as a demonstration ("Share Your Work" section), or do you have a problem / question -- in which case, what is your question?
My question was how do I get multiple triggers or combinations of values from arduino come in and trigger different playlists. So if the values from arduino are Chris, YeeMun, Food, Music, YM and Nothing as strings from the arduino so i am reading them and splitting them up so that I know whats being sent. And based on the combination of those inputs it plays different playlists (a group of .aiff files) in the order that the playlist was made.
Two relevant posts:
https://forum.processing.org/two/discussion/16618/processing-with-arduino-void-serialevent#Item_1
https://forum.processing.org/two/discussion/comment/88115/#Comment_88115
Kf