Mercurial > hg > screen-ui
annotate src/Voice.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 |
rev | line source |
---|---|
hekeus@6 | 1 /* |
hekeus@6 | 2 * Voice.h |
hekeus@6 | 3 * MelodyTriangle |
hekeus@6 | 4 * |
hekeus@6 | 5 * Created by Henrik Ekeus on 12/01/2012. |
hekeus@6 | 6 * Copyright 2012 Queen Mary University of London. All rights reserved. |
hekeus@6 | 7 * |
hekeus@6 | 8 */ |
hekeus@6 | 9 #include "ofMain.h" |
samer@23 | 10 #define RADIUS 12 |
samer@23 | 11 |
hekeus@6 | 12 class Voice { |
hekeus@6 | 13 public: |
samer@22 | 14 Voice(int id); |
hekeus@6 | 15 |
samer@18 | 16 enum status { |
samer@18 | 17 clear, |
samer@18 | 18 pending, |
samer@18 | 19 waiting, |
samer@18 | 20 moved |
samer@18 | 21 }; |
samer@23 | 22 |
samer@23 | 23 class bad_status : public std::exception { |
samer@23 | 24 string str; |
samer@23 | 25 public: |
samer@23 | 26 bad_status(string s): str(s) {} |
samer@23 | 27 ~bad_status() throw() {} |
samer@23 | 28 const char *what() const throw(); |
samer@23 | 29 }; |
samer@23 | 30 |
samer@23 | 31 static status stringToStatus(string str) throw(bad_status); |
samer@23 | 32 bool isInVoice(int x, int y) { return (ofDist(x, y, posx, posy)<=RADIUS); }; |
samer@23 | 33 //void setPos(int x, int y) { posx=x; posy=y; status=pending; } |
samer@13 | 34 double louder(); |
samer@13 | 35 double quieter(); |
samer@23 | 36 void draw(bool highlight); |
hekeus@6 | 37 |
hekeus@6 | 38 int id; |
hekeus@6 | 39 int posx,posy; |
hekeus@6 | 40 bool isActive; |
hekeus@6 | 41 bool inTriangle; |
hekeus@6 | 42 int octave; |
samer@13 | 43 double amplitude; |
samer@18 | 44 enum status status; |
hekeus@6 | 45 }; |