Mercurial > hg > beatroot-vamp
comparison BeatTracker.cpp @ 17:47e1917c88fc
Add file previously forgotten in commit... doh. And .cat file.
author | Chris Cannam |
---|---|
date | Fri, 14 Oct 2011 09:59:53 +0100 |
parents | |
children | 633ec097fa56 |
comparison
equal
deleted
inserted
replaced
16:33d0b18b2509 | 17:47e1917c88fc |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Vamp feature extraction plugin for the BeatRoot beat tracker. | |
5 | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2011 Simon Dixon, Chris Cannam and QMUL. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #include "BeatTracker.h" | |
17 | |
18 EventList BeatTracker::beatTrack(EventList events, EventList beats) | |
19 { | |
20 AgentList agents; | |
21 int count = 0; | |
22 double beatTime = -1; | |
23 if (!beats.empty()) { | |
24 count = beats.size() - 1; | |
25 EventList::iterator itr = beats.end(); | |
26 --itr; | |
27 beatTime = itr->time; | |
28 } | |
29 if (count > 0) { // tempo given by mean of initial beats | |
30 double ioi = (beatTime - beats.begin()->time) / count; | |
31 agents.push_back(new Agent(ioi)); | |
32 } else // tempo not given; use tempo induction | |
33 agents = Induction::beatInduction(events); | |
34 if (!beats.empty()) | |
35 for (AgentList::iterator itr = agents.begin(); itr != agents.end(); | |
36 ++itr) { | |
37 (*itr)->beatTime = beatTime; | |
38 (*itr)->beatCount = count; | |
39 (*itr)->events = beats; | |
40 } | |
41 agents.beatTrack(events, -1); | |
42 Agent *best = agents.bestAgent(); | |
43 EventList results; | |
44 if (best) { | |
45 best->fillBeats(beatTime); | |
46 results = best->events; | |
47 } | |
48 for (AgentList::iterator ai = agents.begin(); ai != agents.end(); ++ai) { | |
49 delete *ai; | |
50 } | |
51 return results; | |
52 } // beatTrack()/1 | |
53 | |
54 |