annotate 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 |
rev |
line source |
hekeus@6
|
1 /*
|
hekeus@6
|
2 * Voice.cpp
|
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
|
hekeus@6
|
10 #include "Voice.h"
|
hekeus@6
|
11
|
samer@13
|
12 inline static double min(double x,double y) { return (x<y) ? x : y; }
|
samer@13
|
13
|
hekeus@6
|
14 Voice::Voice(int id, int x, int y){
|
hekeus@6
|
15 this->id=id;
|
hekeus@6
|
16 posx=x;
|
hekeus@6
|
17 posy=y;
|
hekeus@6
|
18 isActive=true;
|
samer@10
|
19 radius=12;
|
hekeus@6
|
20 inTriangle=false;
|
hekeus@6
|
21 octave=0;
|
hekeus@6
|
22 highlight=false;
|
samer@13
|
23 amplitude=0.6;
|
hekeus@6
|
24 }
|
hekeus@6
|
25
|
hekeus@6
|
26 void Voice::draw(){
|
samer@10
|
27 ofSetColor(200,0,0);
|
hekeus@6
|
28
|
hekeus@6
|
29 if (isActive){
|
hekeus@6
|
30 ofFill();
|
samer@10
|
31 } else {
|
hekeus@6
|
32 ofNoFill();
|
hekeus@6
|
33 }
|
hekeus@6
|
34 ofCircle(posx, posy, radius);
|
samer@12
|
35 if (highlight) ofSetColor(255, 192, 192);
|
samer@10
|
36 ofNoFill();
|
samer@10
|
37 ofCircle(posx, posy, radius);
|
hekeus@6
|
38 }
|
hekeus@6
|
39
|
samer@13
|
40 double Voice::louder() { return amplitude=min(1,amplitude*1.125); }
|
samer@13
|
41 double Voice::quieter() { return amplitude/=1.125; }
|
hekeus@6
|
42
|