Mercurial > hg > screen-ui
diff src/melodyTriangle.h @ 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/melodyTriangle.h Thu Feb 02 18:17:24 2012 +0000 +++ b/src/melodyTriangle.h Sat Feb 04 23:14:38 2012 +0000 @@ -1,18 +1,15 @@ - - #include "ofMain.h" +#include "ofxOsc.h" #include "Voice.h" -#include "ofxOsc.h" - #define MAX_VOICES 10 - class melodyTriangle : public ofBaseApp{ public: - melodyTriangle(const char *host, int port, int numVoices, bool enableKeys, int voiceIdOffset, int receivePort); ~melodyTriangle(); + melodyTriangle(const char *host, int port, int numVoices, + bool enableKeys, int voiceIdOffset, int receivePort); void setup(); void update(); @@ -27,10 +24,22 @@ void windowResized(int w, int h); private: + class bad_voice_id : public std::exception { + int id; + public: + bad_voice_id(int id): id(id) {} + ~bad_voice_id() throw() {} + const char *what() const throw(); + }; + // private methods + Voice *get_voice(int id) throw(bad_voice_id); + + void voiceKeypress(Voice *v, int key); void sendReplyTo(); void sendCalibrate(); - void sendPosition(Voice v); + void sendDeath(int id); + void sendPosition(Voice *v); void sendPeriod(int id, int num, int den); void sendShift(int id, int num, int den); void sendOctave(int id, int oct); @@ -38,23 +47,24 @@ bool clipToTriangle(int *cx, int *cy); void fitTriangleIn(int w, int h); void handleMessage(ofxOscMessage &m); + void reset(); // Immutable after construction and setup ofxOscSender sender; ofxOscReceiver receiver; int receivePort; // for sending /reply_to message int numVoices; - bool enableKeys; // somewhat mutable (on window resize) int x1,y1,x2,y2,x3,y3; // Triangle Coords int DX13, DY13, SQLEN13; // to optimise clipping // mutable state - Voice *voices[MAX_VOICES]; - int voiceGrabbed; + Voice *voices[MAX_VOICES]; + int voiceGrabbed; + bool constrained; + bool enableKeys; + int display_frames; + string display_msg; ofTrueTypeFont display_font; - string display_msg; - int display_frames; - bool constrained; };