We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey guys, I have a big problem. Tonight before midnight i have to submit a processing code. I have to submit it in a zipped folder together with a written reflection. When the folder is not zipped, everything works just fine, but when i zip the folder and try to run my program i get an error message saying the audio files cant be found. I have checked the data folder and all the mp3 files are present there.
import ddf.minim.*;
import processing.serial.*;
Serial myPort;
int val;
Minim minim;
AudioPlayer E2;
AudioPlayer A;
AudioPlayer D;
AudioPlayer G;
AudioPlayer B;
AudioPlayer E;
boolean E2snaarB = false;
boolean AsnaarB = false; // these booleans make it possible to press 2 or more keys at once
boolean DsnaarB = false;
boolean GsnaarB = false;
boolean BsnaarB = false;
boolean EsnaarB = false;
void setup(){
size(displayWidth, displayHeight);
smooth();
background(255, 255, 180);
noStroke();
frameRate(30);
minim = new Minim(this); //Creating new class for sound output
E2 = minim.loadFile("E2.mp3"); //Loading in the soundfiles for each string. They were dowloaded from:
A = minim.loadFile("A.mp3"); //https://www.freesound.org/people/Kyster/packs/7398/
D = minim.loadFile("D.mp3");
G = minim.loadFile("G.mp3");
B = minim.loadFile("B.mp3");
E = minim.loadFile("E.mp3");
//The part below is commented out because it only works when an arduino is connected.
//If there is no arduino connected and this is not commented out, the program will not work
//String portName = Serial.list()[0];
//myPort = new Serial(this, portName, 9600); //creating a new class for arduino input
}
// Creating a different void for each string named afetr the notes they represent.
// The colors of the circles represent the color code used by string manufacturer 'D'addario'
void E2snaar(){
fill(120, 60,30);
ellipse(0, -300, 15, 15);
}
void Asnaar(){
fill(255, 0, 0);
ellipse(0, -250, 15, 15);
}
void Dsnaar(){
fill(0);
ellipse(0, -200, 15, 15);
}
void Gsnaar (){
fill(0,220,0);
ellipse(0,-150,15,15);
}
void Bsnaar (){
fill(190,0,255);
ellipse(0, -100,15,15);
}
void Esnaar(){
fill(240, 240, 240);
ellipse(0, -50, 15, 15);
}
float v=0;
void draw(){
smooth();
translate(width/2, height/2); // Rotate around the middle
rotate(radians(v=v+1)); // Move the circles around at the same speed
// The part below is commented out, because it only works when the arduino is connected.
// Is no arduino is connected it gives an error
// if (myPort.available() > 0){ //Detect wether the button is pressed or not
// val = myPort.read();
// }
// if(val == 1){ //If the button is pressed, draw the circle and play the corresponding note
// E2snaar();
// E2.rewind();
// E2.play();
// }
if (E2snaarB == true){
E2snaar();
E2.rewind();
E2.play();
}
if (AsnaarB == true){ // If the boolean is true, draw the ellipses
Asnaar();
A.rewind();
A.play();
}
if (DsnaarB == true){
Dsnaar();
D.rewind();
D.play();
}
if (GsnaarB == true){
Gsnaar();
G.rewind();
G.play();
}
if (BsnaarB == true){
Bsnaar();
B.rewind();
B.play();
}
if (EsnaarB == true){
Esnaar();
E.rewind();
E.play();
}
fill(255, 255, 180); //'Cleaning' the circles with other ellipses following the colored ones in the background color
ellipse(200, -225, 20, 20);
ellipse(200, -150, 20, 20);
ellipse(200, -25, 20, 20);
ellipse(142, 50, 20, 20);
ellipse(87, 50, 20, 20);
ellipse(12, 50, 20, 20);
}
// if key pressed - booleans true
void keyPressed(){
if(key == 'w') E2snaarB = true;
if(key == 'e') AsnaarB = true;
if(key == 'r') DsnaarB = true;
if(key == 't') GsnaarB = true;
if(key == 'y') BsnaarB = true;
if(key == 'u') EsnaarB = true;
}
// if key released - booleans false
void keyReleased(){
if(key == 'w') E2snaarB = false;
if(key == 'e') AsnaarB = false;
if(key == 'r') DsnaarB = false;
if(key == 't') GsnaarB = false;
if(key == 'y') BsnaarB = false;
if(key == 'u') EsnaarB = false;
}
Answers
Compressed files need to be decompressed 1st before use! :-&