comparison src/melodyTriangle.h @ 30:9e8c19c90986

Added visual confirmation on keyboard enable/disable.
author samer
date Mon, 06 Feb 2012 11:50:03 +0000
parents f4ebb87adec1
children 417deb31dd4e
comparison
equal deleted inserted replaced
29:10afc9afb79d 30:9e8c19c90986
4 4
5 #define MAX_VOICES 10 5 #define MAX_VOICES 10
6 6
7 class melodyTriangle : public ofBaseApp{ 7 class melodyTriangle : public ofBaseApp{
8 8
9 public:
10 ~melodyTriangle();
11 melodyTriangle(const char *host, int port, int numVoices,
12 bool enableKeys, int voiceIdOffset, int receivePort);
13
14 void setup();
15 void update();
16 void draw();
17
18 void keyPressed(int key);
19 void keyReleased(int key);
20 void mouseMoved(int x, int y );
21 void mouseDragged(int x, int y, int button);
22 void mousePressed(int x, int y, int button);
23 void mouseReleased(int x, int y, int button);
24 void windowResized(int w, int h);
25
26 private:
27 class bad_voice_id : public std::exception {
28 int id;
9 public: 29 public:
10 ~melodyTriangle(); 30 bad_voice_id(int id): id(id) {}
11 melodyTriangle(const char *host, int port, int numVoices, 31 ~bad_voice_id() throw() {}
12 bool enableKeys, int voiceIdOffset, int receivePort); 32 const char *what() const throw();
33 };
13 34
14 void setup(); 35 // private methods
15 void update(); 36 Voice *get_voice(int id) throw(bad_voice_id);
16 void draw(); 37 void voiceKeypress(Voice *v, int key);
17
18 void keyPressed(int key);
19 void keyReleased(int key);
20 void mouseMoved(int x, int y );
21 void mouseDragged(int x, int y, int button);
22 void mousePressed(int x, int y, int button);
23 void mouseReleased(int x, int y, int button);
24 void windowResized(int w, int h);
25 38
26 private: 39 void sendReplyTo();
27 class bad_voice_id : public std::exception { 40 void sendCalibrate();
28 int id; 41 void sendPosition(Voice *v);
29 public: 42 void sendPeriod(int id, int num, int den);
30 bad_voice_id(int id): id(id) {} 43 void sendShift(int id, int num, int den);
31 ~bad_voice_id() throw() {} 44 void sendOctave(int id, int oct);
32 const char *what() const throw(); 45 void sendAmplitude(int id, float amp);
33 }; 46 void send(const char *msg);
34 47 void send(const char *msg, int a);
35 // private methods 48 void handleMessage(ofxOscMessage &m);
36 Voice *get_voice(int id) throw(bad_voice_id);
37 void voiceKeypress(Voice *v, int key);
38 49
39 void sendReplyTo(); 50 bool clipToTriangle(int *cx, int *cy);
40 void sendCalibrate(); 51 void fitTriangleIn(int w, int h);
41 void sendPosition(Voice *v); 52 void reset();
42 void sendPeriod(int id, int num, int den); 53
43 void sendShift(int id, int num, int den); 54 void setKeyboardEnable(bool en);
44 void sendOctave(int id, int oct);
45 void sendAmplitude(int id, float amp);
46 void send(const char *msg);
47 void send(const char *msg, int a);
48 void handleMessage(ofxOscMessage &m);
49
50 bool clipToTriangle(int *cx, int *cy);
51 void fitTriangleIn(int w, int h);
52 void reset();
53 55
54 // Immutable after construction and setup 56 // Immutable after construction and setup
55 ofxOscSender sender; 57 ofxOscSender sender;
56 ofxOscReceiver receiver; 58 ofxOscReceiver receiver;
57 int receivePort; // for sending /reply_to message 59 int receivePort; // for sending /reply_to message
58 int numVoices; 60 int numVoices;
59
60 // somewhat mutable (on window resize)
61 int x1,y1,x2,y2,x3,y3; // Triangle Coords
62 int DX13, DY13, SQLEN13; // to optimise clipping
63 61
64 // mutable state 62 // somewhat mutable (on window resize)
65 Voice *voices[MAX_VOICES]; 63 int x1,y1,x2,y2,x3,y3; // Triangle Coords
66 Voice *voiceGrabbed; 64 int DX13, DY13, SQLEN13; // to optimise clipping
67 bool constrained; 65
68 bool enableKeys; 66 // mutable state
69 int display_frames; 67 Voice *voices[MAX_VOICES];
70 int ratio; 68 Voice *voiceGrabbed;
71 int tempoIndex; 69 bool constrained;
72 string display_msg; 70 bool enableKeys;
73 ofTrueTypeFont display_font; 71 bool allowExit;
72 int display_frames;
73 int ratio;
74 int tempoIndex;
75 string display_msg;
76 ofTrueTypeFont display_font;
74 }; 77 };