view src/Voice.cpp @ 38:330f2746fedd tip

Added keys help in a smaller font; changed loadness keyboard controls.
author samer
date Mon, 27 Feb 2012 20:09:10 +0000
parents 06a2fdb333ca
children
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): 
	isActive(true), inTriangle(false), isVisible(true),
	octave(0), amplitude(0.5), status(pending), id(id), 
	posx(0), posy(0), truex(-1), truey(-1) {}

void Voice::draw(bool highlight){
	if (!isVisible) return;
	
	int r,g,b;
	switch (status) {
		case clear:   r=1; g=1; b=0; break;
		default:      r=1; g=0; b=0; break;
	}
	if (isActive) { r=2*r; g=2*g; b=2*b; }

	if (inTriangle && truex>=0) {
		ofSetColor(230,230,230);
		ofLine(posx,posy,truex,truey);
		// ofNoFill();	ofCircle(truex, truey, RADIUS/2-1);
	}
	ofSetColor(100*r,60*g,60*b);
	ofFill();
	ofCircle(posx, posy, RADIUS);
	ofNoFill();
	if (highlight) ofSetColor(230, 230, 230);
	ofCircle(posx, posy, RADIUS);
}

void Voice::draw_alt(bool highlight){
	if (!isVisible) return;

	int r,g,b;
	switch (status) {
		case clear:   r=1; g=1; b=0; break;
		default:      r=1; g=0; b=0; break;
	}
	if (isActive) { r=2*r; g=2*g; b=2*b; }

	if (inTriangle && truex>=0) {
		ofSetColor(230,230,230);
		ofLine(posx,posy,truex,truey);
		ofSetColor(100*r,60*g,60*b);
		ofFill();
		ofCircle(truex, truey, RADIUS);
		ofNoFill();
		if (highlight) ofSetColor(230, 230, 230);
		ofCircle(truex, truey, RADIUS);
	} else {
		ofSetColor(100*r,60*g,60*b);
		ofFill();
		ofCircle(posx, posy, RADIUS);
		ofNoFill();
		if (highlight) ofSetColor(230, 230, 230);
		ofCircle(posx, posy, RADIUS);
	}
}


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