M1KES
YaBB Newbies
Offline
Posts: 19
Re: Help with a grid using a for cycle
Reply #5 - Jan 15th , 2010, 5:29am
well changing it to x + y * width makes it not reproduce any sound when pressed with 2 fingers at a time. I tried doing something similar to what you sugested but i would get stuck and not really know how to handle it.. cause he is constantly checking the position and i cant stop the verification. Here is the entire code if it helps.: import TUIO.*; TuioProcessing tuioClient; import arb.soundcipher.*; Ripple[] rip; // Declare the object array int numRipples = 50; // Max number of ripples int currentRipple = 0; // To keep track color bg = 0; int c1 = 255; // Color array int c2 = 100; color[] c = {color(c1, c2, 0), color(c1, 0, c2), color(c2, c1, 0)}; int col; int which; int rectWidth = 60; int rectHeight = 80; int lastPos = 2; int val = 0; float[] cursors; SoundCipher sc = new SoundCipher(this); void setup() { //background(0); size(600,800); tuioClient = new TuioProcessing(this); smooth(); stroke(255); strokeWeight(3); noFill(); rip = new Ripple[numRipples]; // Create the object for (int i = 0; i < numRipples; i++) { rip[i] = new Ripple(); } } void draw() { background(bg); for (int p = 0; p < numRipples; p++) { rip[p].resize(); // Change the parameters rip[p].display(); // Actually draw 'em } Vector tuioCursorList = tuioClient.getTuioCursors(); for (int i=0;i<tuioCursorList.size();i++) { //println(tuioCursorList.size()); TuioCursor tcur = (TuioCursor)tuioCursorList.elementAt(i); Vector pointList = tcur.getPath(); if (pointList.size()>0) { stroke(0,0,255); TuioPoint start_point = (TuioPoint)pointList.firstElement(); for (int j=0;j<pointList.size();j++) { TuioPoint end_point = (TuioPoint)pointList.elementAt(j); //println(tcur.getCursorID()); if(start_point.getScreenY(height) <= height / 3) { sc.instrument(25); val = 0; which = 0; } else if (start_point.getScreenY(height) >= height / 3 + height /3) { sc.instrument(23); val = 400; which = 1; } else { sc.instrument(12); val = 200; which = 2; } for (int y= 1; y<height; y += 80){ for (int x= 1; x<width; x += 60){ strokeWeight(1); noFill(); //rect(x, y,rectWidth, rectHeight); if(tuioCursorList.size() == 0) { println(tuioCursorList.size()); lastPos = 2; } if (start_point.getScreenX(width) >= x && start_point.getScreenX(width) <= x+rectWidth && start_point.getScreenY(height) >= y && start_point.getScreenY(height) <= y+rectHeight) { if(lastPos != x*y ) { fill(0); //rect(0,0,600,800); fill(255); lastPos = x*y; col = x/20; //rect(x, y,rectWidth, rectHeight); start_point = end_point; //if(tuioCursorList if(tuioCursorList.size() == 1) { sc.playNote(x / 4, y - val, 0.5); //println(y); } if(tuioCursorList.size() == 2) { float[] pitches = { x / 4, x / 4 +4, x / 4 + 7, x / 4+11 }; sc.playChord(pitches, 80, 1); } // pick a color, any color (or the number associateing to that color in the array) rip[currentRipple].xy(x + 30, y + 40, which); // tell the upcoming ripple where it should be made and what color it should be currentRipple++; // advance to the next ripple int the array if (currentRipple >= numRipples) { // Reset if we max out numRipples currentRipple = 0; noFill(); } } } } } } } } } void addTuioObject(TuioObject tobj) { } // called when an object is removed from the scene void removeTuioObject(TuioObject tobj) { } // called when an object is moved void updateTuioObject (TuioObject tobj) { } // called when a cursor is added to the scene void addTuioCursor(TuioCursor tcur) { } // called when a cursor is moved void updateTuioCursor (TuioCursor tcur) { } // called when a cursor is removed from the scene void removeTuioCursor(TuioCursor tcur) { } // called after each message bundle // representing the end of an image frame void refresh(TuioTime bundleTime) { redraw(); } its missing a class but its not important for what i need.