comparison src/Voice.cpp @ 13:9e31c0507e65

Added amplitude control (keys '*' and '/').
author samer
date Mon, 30 Jan 2012 13:29:53 +0000
parents 317637282293
children 9a414ea6880d
comparison
equal deleted inserted replaced
12:317637282293 13:9e31c0507e65
7 * 7 *
8 */ 8 */
9 9
10 #include "Voice.h" 10 #include "Voice.h"
11 11
12 inline static double min(double x,double y) { return (x<y) ? x : y; }
13
12 Voice::Voice(int id, int x, int y){ 14 Voice::Voice(int id, int x, int y){
13 this->id=id; 15 this->id=id;
14 posx=x; 16 posx=x;
15 posy=y; 17 posy=y;
16 isActive=true; 18 isActive=true;
17 radius=12; 19 radius=12;
18 inTriangle=false; 20 inTriangle=false;
19 octave=0; 21 octave=0;
20 highlight=false; 22 highlight=false;
23 amplitude=0.6;
21 } 24 }
22
23 Voice::Voice(){}
24 25
25 void Voice::draw(){ 26 void Voice::draw(){
26 ofSetColor(200,0,0); 27 ofSetColor(200,0,0);
27 28
28 if (isActive){ 29 if (isActive){
34 if (highlight) ofSetColor(255, 192, 192); 35 if (highlight) ofSetColor(255, 192, 192);
35 ofNoFill(); 36 ofNoFill();
36 ofCircle(posx, posy, radius); 37 ofCircle(posx, posy, radius);
37 } 38 }
38 39
39 bool Voice::isInVoice(int x, int y){ 40 double Voice::louder() { return amplitude=min(1,amplitude*1.125); }
40 if (ofDist(x, y, posx, posy)<=radius){ 41 double Voice::quieter() { return amplitude/=1.125; }
41 return true;
42 }else {
43 return false;
44 }
45 42
46 }
47