annotate BeatTracker.cpp @ 27:c587469da70b

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