view src/Voice.cpp @ 19:055d7524bae4

Adjusted colours, reduced buffer zone.
author samer
date Tue, 31 Jan 2012 23:44:01 +0000
parents 9a414ea6880d
children 4dcc4312b5fa
line wrap: on
line source
/*
 *  Voice.cpp
 *  MelodyTriangle
 *
 *  Created by Henrik Ekeus on 12/01/2012.
 *  Copyright 2012 Queen Mary University of London. All rights reserved.
 *
 */

#include "Voice.h"

inline static double min(double x,double y) { return (x<y) ? x : y; }

Voice::Voice(int id, int x, int y){
	this->id=id;
	posx=x;
	posy=y;
	isActive=true;
	radius=12;
	inTriangle=false;
	octave=0;
	highlight=false;
	amplitude=0.6;
	status=clear;
}

void Voice::draw(){
	int r,g,b;
	switch (status) {
		case clear:   r=1; g=0; b=0; break;
		default:      r=1; g=1; b=0; break;
//		case pending: r=1; g=1; b=0; break;
//		case waiting: r=1; g=0; b=0; break;
//		case moved:   r=1; g=0; b=1; break;
//		default:      r=0; g=1; b=0;
	}
	
	if (isActive) { r=2*r; g=2*g; b=2*b; }
	ofSetColor(100*r,60*g,60*b);
	ofFill();
	ofCircle(posx, posy, radius);
	//ofNoFill();
	//ofCircle(posx, posy, radius);
	
	if (highlight) {
		ofSetColor(230, 230, 230);
		ofNoFill();
		ofCircle(posx, posy, radius);
	} else {
		ofNoFill();
		ofCircle(posx, posy, radius);
	}
}

double Voice::louder()  { return amplitude=min(1,amplitude*1.125); }
double Voice::quieter() { return amplitude/=1.125; }