# HG changeset patch # User samer # Date 1328024980 0 # Node ID 9a414ea6880da61fbca9f4ff32a18147feeb0bb2 # Parent 21eb7b7a5dc009c7565f07585d800aeb37f5331f Added colour coding of voice status. diff -r 21eb7b7a5dc0 -r 9a414ea6880d release/MelodyTriangle.app.tar.gz Binary file release/MelodyTriangle.app.tar.gz has changed diff -r 21eb7b7a5dc0 -r 9a414ea6880d src/Voice.cpp --- a/src/Voice.cpp Tue Jan 31 12:52:42 2012 +0000 +++ b/src/Voice.cpp Tue Jan 31 15:49:40 2012 +0000 @@ -21,20 +21,35 @@ octave=0; highlight=false; amplitude=0.6; + status=clear; } void Voice::draw(){ - ofSetColor(200,0,0); + int r,g,b; + switch (status) { + case clear: r=1; g=0; b=0; break; + default: r=1; g=1; b=0; break; +// case pending: r=1; g=1; b=0; break; +// case waiting: r=1; g=0; b=0; break; +// case moved: r=1; g=0; b=1; break; +// default: r=0; g=1; b=0; + } - if (isActive){ - ofFill(); + if (isActive) { r=2*r; g=2*g; b=2*b; } + ofSetColor(100*r,40*g,60*b); + ofFill(); + ofCircle(posx, posy, radius); + //ofNoFill(); + //ofCircle(posx, posy, radius); + + if (highlight) { + ofSetColor(230, 230, 230); + ofNoFill(); + ofCircle(posx, posy, radius); } else { ofNoFill(); + ofCircle(posx, posy, radius); } - ofCircle(posx, posy, radius); - if (highlight) ofSetColor(255, 192, 192); - ofNoFill(); - ofCircle(posx, posy, radius); } double Voice::louder() { return amplitude=min(1,amplitude*1.125); } diff -r 21eb7b7a5dc0 -r 9a414ea6880d src/Voice.h --- a/src/Voice.h Tue Jan 31 12:52:42 2012 +0000 +++ b/src/Voice.h Tue Jan 31 15:49:40 2012 +0000 @@ -12,6 +12,13 @@ Voice(int id, int x, int y); Voice() {}; + enum status { + clear, + pending, + waiting, + moved + }; + bool isInVoice(int x, int y) { return (ofDist(x, y, posx, posy)<=radius); }; double louder(); double quieter(); @@ -25,4 +32,5 @@ int octave; bool highlight; double amplitude; + enum status status; }; diff -r 21eb7b7a5dc0 -r 9a414ea6880d src/melodyTriangle.cpp --- a/src/melodyTriangle.cpp Tue Jan 31 12:52:42 2012 +0000 +++ b/src/melodyTriangle.cpp Tue Jan 31 15:49:40 2012 +0000 @@ -20,19 +20,31 @@ //voices=*Voice[numVoices]; sender.setup( host,port ); receiver.setup( receivePort ); - + + { + ofxOscMessage m; + m.setAddress( "/reply_to" ); + m.addIntArg( receivePort ); + sender.sendMessage( m ); + printf("sent /reply_to %i\n",receivePort); + } } //-------------------------------------------------------------- void melodyTriangle::setup(){ - //voices = new Voice[NUMVOICES]; - ofSetCircleResolution(100); ofBackground(0,0,0); ofSetWindowTitle("Melody Triangle"); + // if vertical sync is off, we can go a bit fast... + // this caps the framerate at 40fps. + ofSetFrameRate(40); + ofEnableSmoothing(); + + // Set up triange coordinates. + // NB. whatever happens here, the triangle must be + // isosceles and left-right symmetric around x=x1. + // Otherwise the clipping won't work triangleHeight=ofGetHeight()*0.75; - ofSetFrameRate(40); // if vertical sync is off, we can go a bit fast... this caps the framerate at 60fps. - ofEnableSmoothing(); x1=ofGetWidth()/2; y1=(ofGetHeight()-triangleHeight)/2; x2=ofGetWidth()/2-triangleHeight/sqrt(3); @@ -109,26 +121,41 @@ // get the next message ofxOscMessage m; receiver.getNextMessage( &m ); - string msg_string; - msg_string = m.getAddress(); - msg_string += ": "; - for ( int i=0; i=0 && idstatus=Voice::clear; + else if (st=="pending") v->status=Voice::pending; + else if (st=="requested") v->status=Voice::waiting; + else cout << "** unrecognised voice status: " << st << ".\n"; + } else { + cout << "** voice id "<posx=mouseX; vg->posy=mouseY; vg->inTriangle=false; + vg->status=Voice::clear; } else { // otherwise, we move to clipped point constrained=true; @@ -239,6 +267,7 @@ if (vg->inTriangle){ sendPosition(*vg); + vg->status=Voice::moved; if (sendStart && vg->isActive){ ofxOscMessage m; ///track id x y left right top bottom area