comparison BeatTracker.cpp @ 23:633ec097fa56

Expose the processing parameters Simon suggests
author Chris Cannam
date Tue, 03 Sep 2013 17:32:09 +0100
parents 47e1917c88fc
children 937432fc2898
comparison
equal deleted inserted replaced
22:6afcb5edd7ab 23:633ec097fa56
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #include "BeatTracker.h" 16 #include "BeatTracker.h"
17 17
18 EventList BeatTracker::beatTrack(EventList events, EventList beats) 18 EventList BeatTracker::beatTrack(AgentParameters params,
19 EventList events, EventList beats)
19 { 20 {
20 AgentList agents; 21 AgentList agents;
21 int count = 0; 22 int count = 0;
22 double beatTime = -1; 23 double beatTime = -1;
23 if (!beats.empty()) { 24 if (!beats.empty()) {
26 --itr; 27 --itr;
27 beatTime = itr->time; 28 beatTime = itr->time;
28 } 29 }
29 if (count > 0) { // tempo given by mean of initial beats 30 if (count > 0) { // tempo given by mean of initial beats
30 double ioi = (beatTime - beats.begin()->time) / count; 31 double ioi = (beatTime - beats.begin()->time) / count;
31 agents.push_back(new Agent(ioi)); 32 agents.push_back(new Agent(params, ioi));
32 } else // tempo not given; use tempo induction 33 } else // tempo not given; use tempo induction
33 agents = Induction::beatInduction(events); 34 agents = Induction::beatInduction(params, events);
34 if (!beats.empty()) 35 if (!beats.empty())
35 for (AgentList::iterator itr = agents.begin(); itr != agents.end(); 36 for (AgentList::iterator itr = agents.begin(); itr != agents.end();
36 ++itr) { 37 ++itr) {
37 (*itr)->beatTime = beatTime; 38 (*itr)->beatTime = beatTime;
38 (*itr)->beatCount = count; 39 (*itr)->beatCount = count;
39 (*itr)->events = beats; 40 (*itr)->events = beats;
40 } 41 }
41 agents.beatTrack(events, -1); 42 agents.beatTrack(events, params, -1);
42 Agent *best = agents.bestAgent(); 43 Agent *best = agents.bestAgent();
43 EventList results; 44 EventList results;
44 if (best) { 45 if (best) {
45 best->fillBeats(beatTime); 46 best->fillBeats(beatTime);
46 results = best->events; 47 results = best->events;