We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › move an image after 2 sounds have played
Page Index Toggle Pages: 1
move an image after 2 sounds have played (Read 175 times)
move an image after 2 sounds have played
Feb 23rd, 2009, 9:17am
 
hello, i have a 1250x300 in a 250x300 display area. there are one to two short audio clips on the stage. i want it so that after the sounds have been clicked on and done playing, it moves 250px to the left, which then a new section with a different image is displayed and new sounds are placed on the stage as well. is this possible to put new sounds and sections of the large image onto stage, or would it be easier to break up the images? also, i am a new user to minim...is there a better sound library? please help! thank you in advance!


//using AudioSample

import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
//Audiotriggerer triggerer;
//AudioInput input;
AudioSample[] gSongArray = new AudioSample[8];
PFont font;
PImage comic;


void setup(){
 size(250, 300);
 smooth();
 fill(0);
 font = loadFont("SansSerif-48.vlw");
 textFont(font, 12);
 minim = new Minim(this);
// input = minim.getLineIn();
 comic = loadImage("data/emiliostrip.jpg");
}

void draw(){
 background(0);
 image(comic,0,0);

//this code doesn't work
 if ((mouseX > 75) && (mouseX < 200) && (mouseY < 100)  ){
  //translate(500,0);
   image(comic,500,0);
 }
}

//if all sounds have been pressed, move image 250px left (-250).


void mousePressed(){ //this executes once. if placed in draw, it will loop over and over
 //sniff
 if ((mouseX > 75) && (mouseX < 200) && (mouseY < 100)  ){
   //red
   gSongArray[0] = minim.loadSample("data/dogsniff.wav");
   gSongArray[0].trigger();
 }
 //yum
else if ((mouseX > 75) && (mouseX < 200) && (mouseY > 100) && (mouseY < 250)){
   gSongArray[1] = minim.loadSample("data/eat.wav");
   gSongArray[1].trigger();
 }
 //eat
 else if ((mouseX > 350) && (mouseX < 450) && (mouseY > 100) &&(mouseY < 200)){
   gSongArray[2] = minim.loadSample("data/peter.wav");
   gSongArray[2].trigger();
 }
 //eat sniff
 else if ((mouseX > 300) && (mouseX < 350) && (mouseY > 100) &&(mouseY < 200)){
   gSongArray[3] = minim.loadSample("data/sniff.wav");
   gSongArray[3].trigger();
 }
 //sniff
 else if ((mouseX > 75) && (mouseX < 200) && (mouseY > 300) &&(mouseY < 400)){
   gSongArray[4] = minim.loadSample("data/dogsniff.wav");
   gSongArray[4].trigger();
 }
 //pooshoe
 else if ((mouseX > 300) && (mouseX < 350) && (mouseY > 460) &&(mouseY < 540)){
   gSongArray[5] = minim.loadSample("data/SQUISH11.WAV");
   gSongArray[5].trigger();
 }
 //running
 else if ((mouseX > 250) && (mouseX < 340) && (mouseY > 560) &&(mouseY < 650)){
   gSongArray[6] = minim.loadSample("data/hanbar04.wav");
   gSongArray[6].trigger();
 }
 //running water
 else if ((mouseX > 170) && (mouseX < 310) && (mouseY > 685) &&(mouseY < 770)){
   gSongArray[7] = minim.loadSample("data/waterunning.mp3");
   gSongArray[7].trigger();
 }  
}

void stop(){
 for (int xIndex = 0; xIndex < gSongArray.length; xIndex ++){
   gSongArray[xIndex].close();
 }
 // the Audiotriggerer you got from Minim.loadSample()
 // the AudioInput you got from Minim.getLineIn()
 //input.close();  //?
 minim.stop();
 // this calls the stop method that
 // you are overriding by defining your own
 // it must be called so that your application
 // can do all the cleanup it would normally do
 super.stop();
}


Page Index Toggle Pages: 1