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 › Stopsound, no looping how! :-(
Page Index Toggle Pages: 1
Stopsound, no looping? how?! :-( (Read 1384 times)
Stopsound, no looping? how?! :-(
May 17th, 2010, 5:28am
 
Hi,
we (2 design-students which never used processing before) are trying to find out how to get the sound playing only once per section. Thx a lot for your help Smiley
Here is our code:

import hypermedia.video.*;
boolean sperre=false;

import arb.soundcipher.*;

SoundCipher sc = new SoundCipher(this);





OpenCV opencv;

int w = 1024;
int h = 768;
int threshold = 80;
float[] pitches = {60, 64, 67, 127}; // c major 7th



void setup() {



 size( 1024,768);
 opencv = new OpenCV( this );
 opencv.capture(w,h);
}



void draw() {

 background(0);
 opencv.read();
 opencv.absDiff();
 opencv.threshold(threshold);
 image( opencv.image(OpenCV.GRAY), 0, 0 );



 Blob[] blobs = opencv.blobs( 100, w*h/3, 20, true );




 for( int i=0; i<blobs.length; i++ ) {

   Point centroid = blobs[i].centroid;
   Point[] points = blobs[i].points;


   if(centroid.x>=0  && centroid.x<=128){
 
     sc.playNote(60, 100, 4);//pitch, lautst√§rke,dauer

   }
      if(centroid.x>=129  && centroid.x<=256){
     sc.playNote(61, 100, 4);//pitch, lautst√§rke,dauer
   }
          if(centroid.x>=257  && centroid.x<=384){
     sc.playNote(62, 100, 4);//pitch, lautst√§rke,dauer
   }
              if(centroid.x>=385  && centroid.x<=512){
     sc.playNote(63, 100, 4);//pitch, lautst√§rke,dauer
   }
                  if(centroid.x>=513  && centroid.x<=640){
     sc.playNote(64, 100, 4);//pitch, lautst√§rke,dauer
   }
                      if(centroid.x>=641  && centroid.x<=768){
     sc.playNote(65, 100, 4);//pitch, lautst√§rke,dauer
   }
                        if(centroid.x>=769  && centroid.x<=896){
     sc.playNote(66, 100, 4);//pitch, lautst√§rke,dauer
   }
                          if(centroid.x>=897  && centroid.x<=1024){
     sc.playNote(67, 100, 4);//pitch, lautst√§rke,dauer
   }

 }

 opencv.remember(OpenCV.SOURCE);  



}


public void stop() {
 opencv.stop();
 super.stop();
}




Re: Stopsound, no looping? how?! :-(
Reply #1 - May 17th, 2010, 10:34pm
 
lessee, I don't know soundcipher, but it looks like all your note durations are 4 seconds, eh?
playNote(double pitch, double dynamic, double duration)

looks like you could use sc.stop()  to stop everything , right before you create the next note.

I don't see a way in soundcipher to stop a particular note, if that's what you mean...  Looks like you have to specify the duration when you instantiate it.  Sad

err, I hope that helps! Smiley
Page Index Toggle Pages: 1