changeset 49:0eeda0223db3

final docs used in big bang fair
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Wed, 16 Mar 2011 14:42:17 +0000
parents f33398343f18
children f4c6999ecfe9
files HeresyBigBangDone/Header.pde HeresyBigBangDone/IO.pde of/testApp.cpp of/testApp.h
diffstat 4 files changed, 111 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/HeresyBigBangDone/Header.pde	Fri Mar 04 19:05:05 2011 +0000
+++ b/HeresyBigBangDone/Header.pde	Wed Mar 16 14:42:17 2011 +0000
@@ -3,7 +3,7 @@
 import maxlink.*;
 
 OscP5 oscP5return;
-NetAddress ableton = new NetAddress("169.254.49.68", 12345); // OSC to ableton
+NetAddress ableton = new NetAddress("localhost", 12345); // OSC to ableton
 MaxLink link = new MaxLink(this, "midiCom");
 import processing.opengl.*;
 int imageWidth = 1000;
--- a/HeresyBigBangDone/IO.pde	Fri Mar 04 19:05:05 2011 +0000
+++ b/HeresyBigBangDone/IO.pde	Wed Mar 16 14:42:17 2011 +0000
@@ -374,12 +374,22 @@
         int thirdValue = theOscMessage.get(3).intValue(); //velocity
         int fourthValue = theOscMessage.get(4).intValue(); //channel
         if (secondValue == 1){
+            if (firstValue != 0 && fourthValue == 1){
             noteOnArray[firstValue] = true;
-            writeNote(firstValue, thirdValue, fourthValue);       
+            writeNote(firstValue-1, thirdValue, fourthValue);
+            }      
+           else {
+             noteOnArray[firstValue] = true;
+             writeNote(firstValue, thirdValue, fourthValue);
+           }
+        }
+        else if (firstValue != 0 && fourthValue == 1){
+            noteOnArray[firstValue] = false;
+            writeNote(firstValue-=1, 0, fourthValue); 
         }
         else{
-            noteOnArray[firstValue] = false;
-            finishNote(firstValue, fourthValue); 
+          noteOnArray[firstValue] = false;
+            writeNote(firstValue, 0, fourthValue); 
         }
     }
     if(theOscMessage.checkAddrPattern("/chord")==true) {
--- a/of/testApp.cpp	Fri Mar 04 19:05:05 2011 +0000
+++ b/of/testApp.cpp	Wed Mar 16 14:42:17 2011 +0000
@@ -17,7 +17,7 @@
 //	Davy.loadImage("images/davy.jpg");
    ofEnableSmoothing();
    ofSetBackgroundAuto(false);
-   ofBackground(238,238,224);
+   ofBackground(255,255,255);
   // 	ofEnableAlphaBlending();
    ofSetLineWidth(12);
 
@@ -35,6 +35,7 @@
 //	sender.setup( HOST, PORT );
 	stopSender.setup( STOPHOST, STOPPORT );
 	heresySender.setup(HERESY_HOST, HERESY_PORT);
+	mophoSender.setup(STOPHOST, MOPHO_PORT);
 	
 	
 	maxTorsoValues[0] = 0;
@@ -61,7 +62,11 @@
 
 void testApp::getCoordinates(int userID){
 	//tracked = user.getTrackedUser(i);
+	if (userID < 0 && userID > 7)
+	    cout << "PROBLEM IN NUMBER FOR getCoordinates";
+    
 	ofxTrackedUser* tracked = user.getTrackedUser(userID);
+
 	
 
 	double timeNow = ofGetElapsedTimeMillis();
@@ -99,6 +104,9 @@
 		torso[userID][2] = tracked->left_upper_torso.end.z;
 		
 		sendStopMessageForUser(userID);
+		userInfoString[userID] = "stopped";
+		
+		//tracked->delete!!
 
 	}
 	ofSetColor(0x00FF00);
@@ -166,10 +174,9 @@
 	else 
 		pitch = 15;
 
-
 	
 	
-	if (userID < 3){
+	if (userID < NUMBER_OF_USERS){
 		double leftHand, rightHand,  leftHandX, rightHandX,  leftHandY, rightHandY;
 		leftHand = leftHandPosition[userID][0]/leftMaximum[0];//i.e x [position
 		rightHand = rightHandPosition[userID][0]/rightMaximum[0];//same for right
@@ -187,8 +194,16 @@
 		int controlChangeRight = (int) min((double)127,max((double)0,(rightHand*127)));
 		
 		int controlChangeLeftY = (int)((double)127 - min((double)127,max((double)0,(leftHandY*127))));
-		int controlChangeRightY = (int)((double)127 - min((double)127,max((double)0,(rightHandY*127))));		
+		int controlChangeRightY = (int)((double)127 - min((double)127,max((double)0,(rightHandY*127))));	
 		
+		if (userID > 0){ //hackoo
+		bool checkNotSame1 = checkSameUserAs(userID, userID + 1 % NUMBER_OF_USERS);
+		bool checkNotSame2 = checkSameUserAs(userID, userID + 2 % NUMBER_OF_USERS);
+		
+			checkingSameUser[userID] = checkSameUserAs(userID, userID + 1 % NUMBER_OF_USERS) ||  checkSameUserAs(userID, userID + 2 % NUMBER_OF_USERS);
+		}
+		
+				
 		ControlChangeData[userID][0] = controlChangeLeft ;
 		ControlChangeData[userID][1] = controlChangeLeftY ;
 		ControlChangeData[userID][2] = controlChangeRight ;	
@@ -209,16 +224,23 @@
 		userInfoString[userID] += " , ";
 		userInfoString[userID] += ofToString(controlChangeRightY, 0);			
 		
+		if (userID == 0){
+			sendControlChangeDataToAbleton(userID);
+		}
+		else{
 		sendControlChangeDataToMax(userID);
+		}
 		
 	if (pitch != pitchPlaying[userID]){
 		//then we have a change
 		//send note off
 		sendNoteMessageToHeresy(pitchPlaying[userID], 0, 0, userID);
 		printf("note OFF user %i pitch %i \n ", userID+1, pitchPlaying[userID]);
-		sendNoteMessageToHeresy(pitch, 1, 127, userID);// int channel){
-		
-		pitchPlaying[userID] = pitch;
+
+		//if (!checkingSameUser[userID]){
+			sendNoteMessageToHeresy(pitch, 1, 127, userID);// int channel){
+			pitchPlaying[userID] = pitch;
+		//}
 		
 		//now get send control change for the hands XXX TO DO
 		/*
@@ -296,6 +318,15 @@
 }
 
 
+bool testApp::checkSameUserAs(int userID, int checkID){
+	bool check = false;
+	
+	if (rightHandPosition[userID][0] == rightHandPosition[checkID][0] && leftHandPosition[userID][0] == leftHandPosition[checkID][0])
+		check = true;
+	
+	return check;
+
+}
 
 
 
@@ -329,9 +360,23 @@
 
 }
 
+void testApp::sendControlChangeDataToAbleton(int userID){
+	int channel = userID+1;
+	
+	ofxOscMessage m;
+	m.setAddress( "/controlChangeData" );
+	m.addIntArg( channel );
+	m.addIntArg( ControlChangeData[userID][0] );
+	m.addIntArg( ControlChangeData[userID][1] );
+	m.addIntArg( ControlChangeData[userID][2] );
+	m.addIntArg( ControlChangeData[userID][3] );
+	mophoSender.sendMessage( m );
+	
+}
+
 //--------------------------------------------------------------
 void testApp::draw(){
-		ofBackground(238,238,224);
+		ofBackground(255,255,255);
 	
 	// draw depth and rgb images
 	//depth.draw();
@@ -347,8 +392,12 @@
 	stringstream info;
 	info << "number of tracked users: " << user.getNumTrackedUsers() << endl;
 	
+	//string numString = "num tracked users is ";
+	//numString += ofToString(user.getNumTrackedUsers());
+	//franklinBook.drawString(numString, 60, 60);
+	
 	// draw the neck positions of each user
-	for(int i = 0; i < user.getNumTrackedUsers(); ++i) {
+	for(int i = 0; i < user.getNumTrackedUsers(); ++i) {//
 		
 		ofxTrackedUser* tracked = user.getTrackedUser(i);
 		
@@ -356,8 +405,11 @@
 
 		//andrews code
 			int userID = i;
-
-			if (userID < 6){
+//			printf("user %i \n", userID);
+			int tmpID = userID;
+			userID = userID % NUMBER_OF_USERS;//hack
+			
+			if (userID < NUMBER_OF_USERS){// && !checkingSameUser[userID]
 			
 				getCoordinates(userID);
 				
@@ -365,6 +417,7 @@
 				if (userPresent[userID]){
 		//		sendDataViaOSC(userID);
 				sendInformationToHeresy(userID);
+					
 				
 				ofSetColor(0x000000);
 				outputString = "Us ";
@@ -410,24 +463,28 @@
 					franklinBook.drawString(outputString, 100,720+userID*160);
 				
 					
-				ofSetColor(0,0,255);
-				ofCircle(tracked->neck.begin.x, tracked->neck.begin.y , 40);
+			//	ofSetColor(0,0,255);
+			//	ofCircle(tracked->neck.begin.x, tracked->neck.begin.y , 40);
 	
 					
 					
 					ofSetColor(255,255,255);
-					float scalingFactor = 0.75;
+					float scalingFactor = 0.75 * 1500 / tracked->neck.begin.z ;
 					switch (userID){
-							
+							//x was - anubis.width*scalingFactor /2
+							//y was - anubis.height*scalingFactor /2
 						case 0:
-					anubis.draw(tracked->neck.begin.x- anubis.width*scalingFactor /2,tracked->neck.begin.y - anubis.height*scalingFactor /2, anubis.width*scalingFactor, anubis.height*scalingFactor  );		
+					anubis.draw(tracked->neck.begin.x - anubis.width*scalingFactor /2,tracked->neck.begin.y - anubis.height*scalingFactor /4, anubis.width*scalingFactor, anubis.height*scalingFactor  );		
 							break;
 						case 1:
-					secondUserImage.draw(tracked->neck.begin.x- secondUserImage.width*scalingFactor /2,tracked->neck.begin.y - secondUserImage.height*scalingFactor /2, secondUserImage.width*scalingFactor, secondUserImage.height*scalingFactor );			
+					secondUserImage.draw(tracked->neck.begin.x- secondUserImage.width*scalingFactor /2,tracked->neck.begin.y - secondUserImage.height*scalingFactor /4, secondUserImage.width*scalingFactor, secondUserImage.height*scalingFactor );			
 							break;
 						case 2:
-							thirdUserImage.draw(tracked->neck.begin.x- thirdUserImage.width*scalingFactor /2,tracked->neck.begin.y - thirdUserImage.height*scalingFactor /2, thirdUserImage.width*scalingFactor, thirdUserImage.height*scalingFactor );			
-							break;		
+							thirdUserImage.draw(tracked->neck.begin.x- thirdUserImage.width*scalingFactor /2,tracked->neck.begin.y - thirdUserImage.height*scalingFactor /4, thirdUserImage.width*scalingFactor, thirdUserImage.height*scalingFactor );			
+							break;	
+						default:
+							drawAcidSmiley(userID);
+							break;
 							
 					}//end switch user image
 					
@@ -461,7 +518,7 @@
 			}
 		ofSetColor(0,0,0);
 		for (int userNumber = 0;userNumber < 3;userNumber++){
-		franklinBook.drawString(userInfoString[userNumber], 600, (userNumber*60)+60);
+		franklinBook.drawString(userInfoString[userNumber], 660, (userNumber*60)+60);
 		}
 		
 	}
@@ -477,12 +534,16 @@
 
 //--------------------------------------------------------------
 void testApp::keyPressed(int key){
-	ofSetColor(238,238,224);
-	ofRect(0,0,ofGetWidth(),ofGetHeight());
-//	drawIt =!drawIt;
-  ofToggleFullscreen();
-	
-	//sendDataViaOSC(0);
+//	if (key=='r')
+//		ofxUserGenerator::setup(context, depth);
+//	else {
+		ofSetColor(238,238,224);
+		ofRect(0,0,ofGetWidth(),ofGetHeight());
+		//	drawIt =!drawIt;
+		ofToggleFullscreen();
+		
+		//sendDataViaOSC(0);
+//	}
 }
 
 //--------------------------------------------------------------
--- a/of/testApp.h	Fri Mar 04 19:05:05 2011 +0000
+++ b/of/testApp.h	Wed Mar 16 14:42:17 2011 +0000
@@ -7,13 +7,15 @@
 #include "ofMain.h"
 #include "ofxOpenNI.h"
 #include "ofxOsc.h"
-#define NUMBER_OF_USERS 6
+#define NUMBER_OF_USERS 3
 
 #define STOPPORT 12343
 #define STOPHOST "localhost"
 
 #define HERESY_PORT 12346
-#define HERESY_HOST "169.254.51.147"//JOE's address??
+#define HERESY_HOST "localhost"//JOE's address??
+
+#define MOPHO_PORT 12342
 
 //#define HOST "169.254.51.147"//Was Tim's ADDRESS - not used any more - use Joe's heresy_host below 
 //#define PORT 12344
@@ -56,7 +58,8 @@
 	
 	int ControlChangeData[NUMBER_OF_USERS][4];//userId, leftX, leftR, rightX, right Y
 	void sendControlChangeDataToMax(int userID);
-		
+	void sendControlChangeDataToAbleton(int userID);
+	
 	void checkTorsoMaxima(int id);
 	int typeOfFaceToUse[NUMBER_OF_USERS];
 	double lastRecordedTime[NUMBER_OF_USERS];//x,y,and z of the head
@@ -73,9 +76,12 @@
 	double minMaxValues[NUMBER_OF_USERS][2];
 	ofTrueTypeFont franklinBook;
 	string outputString;
-	ofxOscSender sender, stopSender, heresySender;
+	ofxOscSender sender, stopSender, heresySender, mophoSender;
 	
 	string userInfoString[3];
 	
+	bool checkSameUserAs(int userID, int checkID);
+	bool checkingSameUser[NUMBER_OF_USERS];
+	
 };
 #endif