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
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();
}