comparison Agent.cpp @ 15:887c629502a9

refactor: pull method implementations into .cpp files
author Chris Cannam
date Wed, 12 Oct 2011 10:55:52 +0100
parents 0d4048bfadbb
children 33d0b18b2509
comparison
equal deleted inserted replaced
14:f1252b6a7cf5 15:887c629502a9
28 28
29 double Agent::innerMargin = 0.0; 29 double Agent::innerMargin = 0.0;
30 double Agent::correctionFactor = 0.0; 30 double Agent::correctionFactor = 0.0;
31 double Agent::expiryTime = 0.0; 31 double Agent::expiryTime = 0.0;
32 double Agent::decayFactor = 0.0; 32 double Agent::decayFactor = 0.0;
33
34 void Agent::accept(Event e, double err, int beats) {
35 beatTime = e.time;
36 events.push_back(e);
37 if (fabs(initialBeatInterval - beatInterval -
38 err / correctionFactor) < MAX_CHANGE * initialBeatInterval)
39 beatInterval += err / correctionFactor;// Adjust tempo
40 beatCount += beats;
41 double conFactor = 1.0 - CONF_FACTOR * err /
42 (err>0? postMargin: -preMargin);
43 if (decayFactor > 0) {
44 double memFactor = 1. - 1. / threshold((double)beatCount,1,decayFactor);
45 phaseScore = memFactor * phaseScore +
46 (1.0 - memFactor) * conFactor * e.salience;
47 } else
48 phaseScore += conFactor * e.salience;
49
50 #ifdef DEBUG_BEATROOT
51 std::cerr << "Ag#" << idNumber << ": " << beatInterval << std::endl;
52 std::cerr << " Beat" << beatCount << " Time=" << beatTime
53 << " Score=" << tempoScore << ":P" << phaseScore << ":"
54 << topScoreTime << std::endl;
55 #endif
56 } // accept()
33 57
34 bool Agent::considerAsBeat(Event e, AgentList &a) { 58 bool Agent::considerAsBeat(Event e, AgentList &a) {
35 double err; 59 double err;
36 if (beatTime < 0) { // first event 60 if (beatTime < 0) { // first event
37 #ifdef DEBUG_BEATROOT 61 #ifdef DEBUG_BEATROOT