annotate src/melodyTriangle.h @ 36:f973f0cc743b

Merge.
author samer
date Wed, 15 Feb 2012 12:26:10 +0000
parents 06a2fdb333ca
children 260cc4f4d70a
rev   line source
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@30 35 // private methods
samer@30 36 Voice *get_voice(int id) throw(bad_voice_id);
samer@30 37 void voiceKeypress(Voice *v, int key);
samer@22 38
samer@30 39 void sendReplyTo();
samer@30 40 void sendCalibrate();
samer@30 41 void sendPosition(Voice *v);
samer@30 42 void sendPeriod(int id, int num, int den);
samer@30 43 void sendShift(int id, int num, int den);
samer@30 44 void sendOctave(int id, int oct);
samer@30 45 void sendAmplitude(int id, float amp);
samer@30 46 void send(const char *msg);
samer@30 47 void send(const char *msg, int a);
samer@32 48 void send(const char *msg, int a, int b);
samer@32 49 void send(const char *msg, int a, int b, int c);
samer@30 50 void handleMessage(ofxOscMessage &m);
samer@23 51
samer@30 52 bool clipToTriangle(int *cx, int *cy);
samer@30 53 void fitTriangleIn(int w, int h);
samer@30 54 void reset();
samer@30 55
samer@30 56 void setKeyboardEnable(bool en);
samer@22 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@30 75 int display_frames;
samer@30 76 int ratio;
samer@30 77 int tempoIndex;
samer@30 78 string display_msg;
samer@30 79 ofTrueTypeFont display_font;
hekeus@6 80 };