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 & HelpSound,  Music Libraries › a lot of sound events...
Page Index Toggle Pages: 1
a lot of sound events... (Read 737 times)
a lot of sound events...
Aug 10th, 2006, 1:34pm
 
hello,

what i would like to do: whenever an element reaches the bottom of the window, the same sound should start playing, but it should only play as long, until the next element triggers the next (same) sound.

when i just use play() the sound is not stopped whenever it is played again in the same channel. when i try to use stop() just before, then the animation is really slowed down by this.

is there any solution to this ?

lia.-

......................................

import krister.Ess.*;
AudioChannel myChannel;

int num = 20;
Elements[] el = new Elements[num];

void setup(){
 size(400,300);
 background(255);
 // Ess
 Ess.start(this);
 myChannel=new AudioChannel("fips.aif");

 for(int i=0; i<num; i++){
   el[i] = new Elements();
 }
}

void draw(){
 background(255);
 for(int i=0; i<num; i++){
   el[i].updateElements();
 }
}

class Elements{
 float x = random(width);
 float y = random(height);

 void updateElements(){
   ellipse(x,y, 3, 3);
   if(y<height){
     y += random(0.1,1);
   }
   else{
     y = 0;
     myChannel.play();
   }
 }
}

Page Index Toggle Pages: 1