Mercurial > hg > beatroot-vamp
changeset 13:0d4048bfadbb
Fixes to beat insertion in Agent. We get plausible results now, but there's probably quite a lot still to do.
author | Chris Cannam |
---|---|
date | Thu, 06 Oct 2011 18:37:50 +0100 |
parents | 59520cd6abac |
children | f1252b6a7cf5 |
files | Agent.cpp AgentList.h BeatRootVampPlugin.cpp Event.h |
diffstat | 4 files changed, 12 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Agent.cpp Thu Oct 06 15:21:03 2011 +0100 +++ b/Agent.cpp Thu Oct 06 18:37:50 2011 +0100 @@ -75,21 +75,19 @@ double prevBeat = 0, nextBeat, currentInterval, beats; EventList::iterator ei = events.begin(); if (ei != events.end()) { - ++ei; - prevBeat = ei->time; - --ei; + EventList::iterator ni = ei; + prevBeat = (++ni)->time; } - for ( ; ei != events.end(); ++ei) { - ++ei; - nextBeat = ei->time; - --ei; // so as to insert before nextBeat + for ( ; ei != events.end(); ) { + EventList::iterator ni = ei; + nextBeat = (++ni)->time; beats = nearbyint((nextBeat - prevBeat) / beatInterval - 0.01); //prefer slow currentInterval = (nextBeat - prevBeat) / beats; for ( ; (nextBeat > start) && (beats > 1.5); beats--) { prevBeat += currentInterval; - events.insert(ei, BeatTracker::newBeat(prevBeat, 0)); - ++ei; + events.insert(ni, BeatTracker::newBeat(prevBeat, 0)); } prevBeat = nextBeat; + ei = ni; } } // fillBeats()
--- a/AgentList.h Thu Oct 06 15:21:03 2011 +0100 +++ b/AgentList.h Thu Oct 06 18:37:50 2011 +0100 @@ -19,6 +19,7 @@ #include "Agent.h" #include "Event.h" +#include <vector> #include <algorithm> #ifdef DEBUG_BEATROOT
--- a/BeatRootVampPlugin.cpp Thu Oct 06 15:21:03 2011 +0100 +++ b/BeatRootVampPlugin.cpp Thu Oct 06 18:37:50 2011 +0100 @@ -217,8 +217,8 @@ FeatureSet fs; - for (int i = 0; i < el.size(); ++i) { - f.timestamp = Vamp::RealTime::frame2RealTime(el[i].time, m_inputSampleRate); + for (EventList::const_iterator i = el.begin(); i != el.end(); ++i) { + f.timestamp = Vamp::RealTime::fromSeconds(i->time); fs[0].push_back(f); }
--- a/Event.h Thu Oct 06 15:21:03 2011 +0100 +++ b/Event.h Thu Oct 06 18:37:50 2011 +0100 @@ -16,7 +16,7 @@ #ifndef _EVENT_H_ #define _EVENT_H_ -#include <vector> +#include <list> struct Event { double time; @@ -34,7 +34,7 @@ } }; -typedef std::vector<Event> EventList; +typedef std::list<Event> EventList; #endif