Mercurial > hg > screen-ui
view src/melodyTriangle.h @ 25:f4ebb87adec1
Added code to keep track of true position of voices in information space;
Two voice drawing methods display both true position target position while dragging;
string to Voice::status code no longer required;
refactored OSC message sending code;
added keys to control subdivision ratio for period and shift controls.
author | samer |
---|---|
date | Sun, 05 Feb 2012 18:13:30 +0000 |
parents | 460c05dd74d0 |
children | 9e8c19c90986 |
line wrap: on
line source
#include "ofMain.h" #include "ofxOsc.h" #include "Voice.h" #define MAX_VOICES 10 class melodyTriangle : public ofBaseApp{ public: ~melodyTriangle(); melodyTriangle(const char *host, int port, int numVoices, bool enableKeys, int voiceIdOffset, int receivePort); void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); 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 sendPeriod(int id, int num, int den); void sendShift(int id, int num, int den); void sendOctave(int id, int oct); void sendAmplitude(int id, float amp); void send(const char *msg); void send(const char *msg, int a); void handleMessage(ofxOscMessage &m); bool clipToTriangle(int *cx, int *cy); void fitTriangleIn(int w, int h); void reset(); // Immutable after construction and setup ofxOscSender sender; ofxOscReceiver receiver; int receivePort; // for sending /reply_to message int numVoices; // 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]; Voice *voiceGrabbed; bool constrained; bool enableKeys; int display_frames; int ratio; int tempoIndex; string display_msg; ofTrueTypeFont display_font; };