diff src/melodyTriangle.cpp @ 14:578c1acf1cc4

Octave and amplitude now initialised correctly on birth; added binary app.
author samer
date Mon, 30 Jan 2012 23:31:39 +0000
parents 9e31c0507e65
children 9d7e139cd0a3
line wrap: on
line diff
--- a/src/melodyTriangle.cpp	Mon Jan 30 13:29:53 2012 +0000
+++ b/src/melodyTriangle.cpp	Mon Jan 30 23:31:39 2012 +0000
@@ -150,7 +150,7 @@
 	}
 }
 
-void melodyTriangle::sendStatus(Voice v){
+void melodyTriangle::sendPosition(Voice v){
 	
 	ofxOscMessage m;
 	///track id x y left right top bottom area  
@@ -169,25 +169,26 @@
 	
 	bool sendStart=false;
 	if (voiceGrabbed!=-1){
-		if (mouseX!=(*voices[voiceGrabbed]).posx || mouseY!=(*voices[voiceGrabbed]).posy){
-			//(*voices[voiceGrabbed]).posx=mouseX;
-			//(*voices[voiceGrabbed]).posy=mouseY;
-			if ((*voices[voiceGrabbed]).inTriangle && !isInTriangle(mouseX,mouseY)){
+		Voice *vg=voices[voiceGrabbed];
+		if (mouseX!=vg->posx || mouseY!=vg->posy){
+			//vg->posx=mouseX;
+			//vg->posy=mouseY;
+			if (vg->inTriangle && !isInTriangle(mouseX,mouseY)){
 			    ///death id
 				
-				if (ofDist((*voices[voiceGrabbed]).posx, (*voices[voiceGrabbed]).posy, mouseX, mouseY)
+				if (ofDist(vg->posx, vg->posy, mouseX, mouseY)
 					> BUFFER_ZONE) { 
 				
 					
 					ofxOscMessage m;
 					///track id x y left right top bottom area  
 					m.setAddress( "/death" );
-					m.addIntArg( (*voices[voiceGrabbed]).id );
+					m.addIntArg( vg->id );
 					sender.sendMessage( m );
 				
-					printf("sent /death %i \n",(*voices[voiceGrabbed]).id);
-					(*voices[voiceGrabbed]).posx=mouseX;
-					(*voices[voiceGrabbed]).posy=mouseY;
+					printf("sent /death %i \n",vg->id);
+					vg->posx=mouseX;
+					vg->posy=mouseY;
 				} else {
 					//printf("e");
 					//On Edge
@@ -195,41 +196,43 @@
 				}
 
 			}else{
-				(*voices[voiceGrabbed]).posx=mouseX;
-				(*voices[voiceGrabbed]).posy=mouseY;
-				//(*voices[voiceGrabbed]).posx=(*voices[voiceGrabbed]).posx*0.9+mouseX*0.1;
-				//(*voices[voiceGrabbed]).posy=(*voices[voiceGrabbed]).posy*0.9+mouseY*0.1;
+				vg->posx=mouseX;
+				vg->posy=mouseY;
+				//vg->posx=vg->posx*0.9+mouseX*0.1;
+				//vg->posy=vg->posy*0.9+mouseY*0.1;
 				
 				
 			}
-			if (!(*voices[voiceGrabbed]).inTriangle && isInTriangle(mouseX,mouseY)){
+			if (!vg->inTriangle && isInTriangle(mouseX,mouseY)){
 				//birth id
 				
 				ofxOscMessage m;
 				///track id x y left right top bottom area  
 				m.setAddress( "/birth" );
-				m.addIntArg( (*voices[voiceGrabbed]).id );
+				m.addIntArg( vg->id );
 				sender.sendMessage( m );
 				
-				printf("sent /birth %i \n",(*voices[voiceGrabbed]).id);
+				printf("sent /birth %i \n",vg->id);
+				sendOctave(vg->id,vg->octave);
+				sendAmplitude(vg->id,vg->amplitude);
 				sendStart=true;
 			}
 			
 			
-			//(*voices[voiceGrabbed]).inTriangle = isInTriangle(mouseX,mouseY);
+			//vg->inTriangle = isInTriangle(mouseX,mouseY);
 			
-			(*voices[voiceGrabbed]).inTriangle = isInTriangle((*voices[voiceGrabbed]).posx,(*voices[voiceGrabbed]).posy);
+			vg->inTriangle = isInTriangle(vg->posx,vg->posy);
 			
-			if ((*voices[voiceGrabbed]).inTriangle){
-				sendStatus(*voices[voiceGrabbed]);
+			if (vg->inTriangle){
+				sendPosition(*vg);
 				if (sendStart){
-					if ((*voices[voiceGrabbed]).isActive){
+					if (vg->isActive){
 						ofxOscMessage m;
 						///track id x y left right top bottom area  
 						m.setAddress( "/start" );
-						m.addIntArg( (*voices[voiceGrabbed]).id );
+						m.addIntArg( vg->id );
 						sender.sendMessage( m );
-						printf("sent /start %i \n",(*voices[voiceGrabbed]).id);
+						printf("sent /start %i \n",vg->id);
 					}
 				}
 			}