Mercurial > hg > screen-ui
view src/Voice.cpp @ 31:417deb31dd4e
Added a switch to control snap-to-true-position behaviour of tokens;
reduced default amplitude of voices.
author | samer |
---|---|
date | Tue, 07 Feb 2012 14:23:32 +0000 |
parents | f4ebb87adec1 |
children | 06a2fdb333ca |
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), octave(0), amplitude(0.5), status(pending), id(id), posx(0), posy(0), truex(-1), truey(-1) {} void Voice::draw(bool highlight){ 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){ 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; }