Processing Forum
import pitaru.sonia_v2_9.*;import processing.serial.*;import codeanticode.gsvideo.*;
// cam and movie
GSMovie morbida1;GSMovie morbida2;GSMovie morbida3;
// music stuffSample bgMusic;Sample snd1;Sample snd2;Sample snd3;
//-------------------------- Declaring arduino stuffSerial port;// sensor stufffloat sensor_A = 0.0;
//-------------------------- Declaring classes
//Morbidia morbidia1;
//-------------------- VOID SETUP -----------------------
void setup(){//size(720,480,P2D);//size(720,480,P3D);size(320,240,P3D);frameRate(25);morbida1 = new GSMovie(this, "morbida_final.mov");morbida2 = new GSMovie(this, "morbidaMad_final2.mov");morbida3 = new GSMovie(this, "morbidaShy_final2.mov");morbida1.frameRate(25);morbida2.frameRate(25);morbida3.frameRate(25);morbida1.loop();morbida2.play();morbida3.play();println(Serial.list());port = new Serial(this, Serial.list()[0],9600);//port = new Serial(this, "/dev/tty.usbmodem411", 9600);port.bufferUntil('\n');Sonia.start(this);bgMusic = new Sample("underwaterk.wav");snd1 = new Sample("snd_madA.wav");snd2 = new Sample("snd_madA1.wav");snd3 = new Sample("snd_madA.wav");bgMusic.repeat();LiveInput.start();}
// --------------------- VOID MOVIE EVENT ---------------------
void movieEvent (GSMovie morbida){morbida.read();//morbida2.read();// morbida3.read();}
// -------------------- VOID DRAW -----------------------
void draw(){image(morbida1,0,0, width, height);float frame_loc = map(morbida1.frame(), 0,150, 0,125);float level = LiveInput.getLevel();level = map(level,0,1,0,100);//println(level);
int vol_Limit = 5;if(level>vol_Limit){snd1.play();//println(morbida2.length());if(snd1.isPlaying()){morbida1.stop();image(morbida2,0,0,width,height);sensor_A = map(sensor_A, 0, 255, 0.1, 0.3);snd1.setRate(sensor_A*88200);// println(brightness);delay(1000);}//------- END IF}//------- END DRAW}
void serialEvent(Serial port){sensor_A = float(port.readStringUntil('\n'));}void stop(){Sonia.stop();super.stop();}