hekeus@6
|
1 #include "ofMain.h"
|
samer@23
|
2 #include "ofxOsc.h"
|
hekeus@6
|
3 #include "Voice.h"
|
hekeus@6
|
4
|
samer@22
|
5 #define MAX_VOICES 10
|
hekeus@6
|
6
|
hekeus@6
|
7 class melodyTriangle : public ofBaseApp{
|
hekeus@6
|
8
|
samer@30
|
9 public:
|
samer@30
|
10 ~melodyTriangle();
|
samer@30
|
11 melodyTriangle(const char *host, int port, int numVoices,
|
samer@30
|
12 bool enableKeys, int voiceIdOffset, int receivePort);
|
samer@30
|
13
|
samer@30
|
14 void setup();
|
samer@30
|
15 void update();
|
samer@30
|
16 void draw();
|
samer@30
|
17
|
samer@30
|
18 void keyPressed(int key);
|
samer@30
|
19 void keyReleased(int key);
|
samer@30
|
20 void mouseMoved(int x, int y );
|
samer@30
|
21 void mouseDragged(int x, int y, int button);
|
samer@30
|
22 void mousePressed(int x, int y, int button);
|
samer@30
|
23 void mouseReleased(int x, int y, int button);
|
samer@30
|
24 void windowResized(int w, int h);
|
samer@30
|
25
|
samer@30
|
26 private:
|
samer@30
|
27 class bad_voice_id : public std::exception {
|
samer@30
|
28 int id;
|
hekeus@6
|
29 public:
|
samer@30
|
30 bad_voice_id(int id): id(id) {}
|
samer@30
|
31 ~bad_voice_id() throw() {}
|
samer@30
|
32 const char *what() const throw();
|
samer@30
|
33 };
|
samer@22
|
34
|
samer@37
|
35 // static methods
|
samer@37
|
36 ofxOscMessage msgReplyTo();
|
samer@37
|
37 ofxOscMessage msgCalibrate();
|
samer@37
|
38 static ofxOscMessage msgPosition(Voice *v);
|
samer@37
|
39 static ofxOscMessage msgPeriod(int id, int num, int den);
|
samer@37
|
40 static ofxOscMessage msgShift(int id, int num, int den);
|
samer@37
|
41 static ofxOscMessage msgOctave(int id, int oct);
|
samer@37
|
42 static ofxOscMessage msgAmplitude(int id, float amp);
|
samer@37
|
43 static ofxOscMessage msg(const char *msg);
|
samer@37
|
44 static ofxOscMessage msg(const char *msg, int a);
|
samer@37
|
45 static ofxOscMessage msg(const char *msg, int a, int b);
|
samer@37
|
46 static ofxOscMessage msg(const char *msg, int a, int b, int c);
|
samer@37
|
47
|
samer@30
|
48 // private methods
|
samer@37
|
49 void handleMessage(ofxOscMessage &m);
|
samer@30
|
50 Voice *get_voice(int id) throw(bad_voice_id);
|
samer@30
|
51 void voiceKeypress(Voice *v, int key);
|
samer@37
|
52 void setKeyboardEnable(bool en);
|
samer@30
|
53 bool clipToTriangle(int *cx, int *cy);
|
samer@30
|
54 void fitTriangleIn(int w, int h);
|
samer@30
|
55 void reset();
|
samer@38
|
56 string help_string(bool global);
|
samer@30
|
57
|
samer@30
|
58 // Immutable after construction and setup
|
samer@30
|
59 ofxOscSender sender;
|
samer@30
|
60 ofxOscReceiver receiver;
|
samer@30
|
61 int receivePort; // for sending /reply_to message
|
samer@30
|
62 int numVoices;
|
hekeus@6
|
63
|
samer@30
|
64 // somewhat mutable (on window resize)
|
samer@30
|
65 int x1,y1,x2,y2,x3,y3; // Triangle Coords
|
samer@30
|
66 int DX13, DY13, SQLEN13; // to optimise clipping
|
samer@30
|
67
|
samer@30
|
68 // mutable state
|
samer@30
|
69 Voice *voices[MAX_VOICES];
|
samer@30
|
70 Voice *voiceGrabbed;
|
samer@30
|
71 bool constrained;
|
samer@30
|
72 bool enableKeys;
|
samer@30
|
73 bool allowExit;
|
samer@31
|
74 bool snapTruePos;
|
samer@37
|
75 bool randInit;
|
samer@30
|
76 int ratio;
|
samer@30
|
77 int tempoIndex;
|
samer@38
|
78 int display_frames;
|
samer@30
|
79 string display_msg;
|
samer@38
|
80 ofTrueTypeFont *display_font;
|
samer@38
|
81 ofTrueTypeFont help_font;
|
samer@38
|
82 ofTrueTypeFont main_font;
|
hekeus@6
|
83 };
|