Mercurial > hg > screen-ui
diff src/Voice.cpp @ 23:460c05dd74d0
Various enhancements and code refactorings:
* added some compiler warnings.
* text display is centred and with settable TrueType font
* removed highlight member from Voice state - value is derived from other data
and passed to Voice::draw()
* Changed voice radius from member to defined constant
* default number of voices is now 4
* adjusted some colours and buffer zone width
* new keyboard commands: reset, quit.
* when keyboard disabled, keys are now passed to server via OSC
* added handlers for various new OSC messages:
- fullscreen, reset, quit, keyboard enable
- notify (voice state) : several sub-messages
* call reset and calibrate on window resize (fits triangle to window)
author | samer |
---|---|
date | Sat, 04 Feb 2012 23:14:38 +0000 |
parents | 4dcc4312b5fa |
children | f4ebb87adec1 |
line wrap: on
line diff
--- a/src/Voice.cpp Thu Feb 02 18:17:24 2012 +0000 +++ b/src/Voice.cpp Sat Feb 04 23:14:38 2012 +0000 @@ -12,38 +12,53 @@ inline static double min(double x,double y) { return (x<y) ? x : y; } Voice::Voice(int id): - radius(12), isActive(true), - inTriangle(false), octave(0), highlight(false), - amplitude(0.6), status(clear), id(id), posx(0), posy(0) {} + isActive(true), inTriangle(false), status(pending), + octave(0), amplitude(0.6), id(id), posx(0), posy(0) {} -void Voice::draw(){ - 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; - } +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); +// } - if (isActive) { r=2*r; g=2*g; b=2*b; } - ofSetColor(100*r,60*g,60*b); ofFill(); - ofCircle(posx, posy, radius); + ofCircle(posx, posy, RADIUS); //ofNoFill(); - //ofCircle(posx, posy, radius); + //ofCircle(posx, posy, RADIUS); if (highlight) { ofSetColor(230, 230, 230); ofNoFill(); - ofCircle(posx, posy, radius); + ofCircle(posx, posy, RADIUS); } else { ofNoFill(); - ofCircle(posx, posy, radius); + 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(); +} +