Revision 13:0d4048bfadbb
| Agent.cpp | ||
|---|---|---|
| 75 | 75 |
double prevBeat = 0, nextBeat, currentInterval, beats; |
| 76 | 76 |
EventList::iterator ei = events.begin(); |
| 77 | 77 |
if (ei != events.end()) {
|
| 78 |
++ei; |
|
| 79 |
prevBeat = ei->time; |
|
| 80 |
--ei; |
|
| 78 |
EventList::iterator ni = ei; |
|
| 79 |
prevBeat = (++ni)->time; |
|
| 81 | 80 |
} |
| 82 |
for ( ; ei != events.end(); ++ei) {
|
|
| 83 |
++ei; |
|
| 84 |
nextBeat = ei->time; |
|
| 85 |
--ei; // so as to insert before nextBeat |
|
| 81 |
for ( ; ei != events.end(); ) {
|
|
| 82 |
EventList::iterator ni = ei; |
|
| 83 |
nextBeat = (++ni)->time; |
|
| 86 | 84 |
beats = nearbyint((nextBeat - prevBeat) / beatInterval - 0.01); //prefer slow |
| 87 | 85 |
currentInterval = (nextBeat - prevBeat) / beats; |
| 88 | 86 |
for ( ; (nextBeat > start) && (beats > 1.5); beats--) {
|
| 89 | 87 |
prevBeat += currentInterval; |
| 90 |
events.insert(ei, BeatTracker::newBeat(prevBeat, 0)); |
|
| 91 |
++ei; |
|
| 88 |
events.insert(ni, BeatTracker::newBeat(prevBeat, 0)); |
|
| 92 | 89 |
} |
| 93 | 90 |
prevBeat = nextBeat; |
| 91 |
ei = ni; |
|
| 94 | 92 |
} |
| 95 | 93 |
} // fillBeats() |
| AgentList.h | ||
|---|---|---|
| 19 | 19 |
#include "Agent.h" |
| 20 | 20 |
#include "Event.h" |
| 21 | 21 |
|
| 22 |
#include <vector> |
|
| 22 | 23 |
#include <algorithm> |
| 23 | 24 |
|
| 24 | 25 |
#ifdef DEBUG_BEATROOT |
| BeatRootVampPlugin.cpp | ||
|---|---|---|
| 217 | 217 |
|
| 218 | 218 |
FeatureSet fs; |
| 219 | 219 |
|
| 220 |
for (int i = 0; i < el.size(); ++i) {
|
|
| 221 |
f.timestamp = Vamp::RealTime::frame2RealTime(el[i].time, m_inputSampleRate);
|
|
| 220 |
for (EventList::const_iterator i = el.begin(); i != el.end(); ++i) {
|
|
| 221 |
f.timestamp = Vamp::RealTime::fromSeconds(i->time);
|
|
| 222 | 222 |
fs[0].push_back(f); |
| 223 | 223 |
} |
| 224 | 224 |
|
| Event.h | ||
|---|---|---|
| 16 | 16 |
#ifndef _EVENT_H_ |
| 17 | 17 |
#define _EVENT_H_ |
| 18 | 18 |
|
| 19 |
#include <vector>
|
|
| 19 |
#include <list>
|
|
| 20 | 20 |
|
| 21 | 21 |
struct Event {
|
| 22 | 22 |
double time; |
| ... | ... | |
| 34 | 34 |
} |
| 35 | 35 |
}; |
| 36 | 36 |
|
| 37 |
typedef std::vector<Event> EventList;
|
|
| 37 |
typedef std::list<Event> EventList;
|
|
| 38 | 38 |
|
| 39 | 39 |
#endif |
| 40 | 40 |
|
Also available in: Unified diff