Mercurial > hg > screen-ui
diff src/Voice.cpp @ 25:f4ebb87adec1
Added code to keep track of true position of voices in information space;
Two voice drawing methods display both true position target position while dragging;
string to Voice::status code no longer required;
refactored OSC message sending code;
added keys to control subdivision ratio for period and shift controls.
author | samer |
---|---|
date | Sun, 05 Feb 2012 18:13:30 +0000 |
parents | 460c05dd74d0 |
children | 417deb31dd4e |
line wrap: on
line diff
--- a/src/Voice.cpp Sat Feb 04 23:15:02 2012 +0000 +++ b/src/Voice.cpp Sun Feb 05 18:13:30 2012 +0000 @@ -12,53 +12,58 @@ inline static double min(double x,double y) { return (x<y) ? x : y; } Voice::Voice(int id): - isActive(true), inTriangle(false), status(pending), - octave(0), amplitude(0.6), id(id), posx(0), posy(0) {} + isActive(true), inTriangle(false), octave(0), amplitude(0.6), + status(pending), id(id), posx(0), posy(0), truex(-1), truey(-1) {} void Voice::draw(bool highlight){ -// if (inTriangle) { - int r,g,b; - switch (status) { - case clear: r=1; g=1; b=0; break; - default: r=1; g=0; 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) { r=2*r; g=2*g; b=2*b; } - ofSetColor(100*r,60*g,60*b); -// } else { -// if (isActive) ofSetColor(128,128,128); -// else ofSetColor(64,64,64); -// } - + int r,g,b; + switch (status) { + case clear: r=1; g=1; b=0; break; + default: r=1; g=0; b=0; break; + } + if (isActive) { r=2*r; g=2*g; b=2*b; } + + if (inTriangle && truex>=0) { + ofSetColor(230,230,230); + ofLine(posx,posy,truex,truey); + // ofNoFill(); ofCircle(truex, truey, RADIUS/2-1); + } + ofSetColor(100*r,60*g,60*b); ofFill(); ofCircle(posx, posy, RADIUS); - //ofNoFill(); - //ofCircle(posx, posy, RADIUS); - - if (highlight) { - ofSetColor(230, 230, 230); + ofNoFill(); + if (highlight) ofSetColor(230, 230, 230); + ofCircle(posx, posy, RADIUS); + +} + +void Voice::draw_alt(bool highlight){ + int r,g,b; + switch (status) { + case clear: r=1; g=1; b=0; break; + default: r=1; g=0; b=0; break; + } + if (isActive) { r=2*r; g=2*g; b=2*b; } + + if (inTriangle && truex>=0) { + ofSetColor(230,230,230); + ofLine(posx,posy,truex,truey); + ofSetColor(100*r,60*g,60*b); + ofFill(); + ofCircle(truex, truey, RADIUS); ofNoFill(); + if (highlight) ofSetColor(230, 230, 230); + ofCircle(truex, truey, RADIUS); + } else { + ofSetColor(100*r,60*g,60*b); + ofFill(); ofCircle(posx, posy, RADIUS); - } else { ofNoFill(); + if (highlight) ofSetColor(230, 230, 230); ofCircle(posx, posy, RADIUS); } } + double Voice::louder() { return amplitude=min(1,amplitude*1.0625); } double Voice::quieter() { return amplitude/=1.0625; } - -enum Voice::status Voice::stringToStatus(string s) throw(bad_status) { - if (s=="received") return clear; - else if (s=="pending") return pending; - else if (s=="requested") return waiting; - else throw bad_status(s); -} - -const char *Voice::bad_status::what() const throw() { - return ("Unrecognised voice status: "+str+".").c_str(); -} -