Revision 18:55969570044e

View differences:

Agent.cpp
102 102
    EventList::iterator ei = events.begin();
103 103
    if (ei != events.end()) {
104 104
        EventList::iterator ni = ei;
105
	prevBeat = (++ni)->time;
105
        if (++ni != events.end()) {
106
            prevBeat = ni->time;
107
        }
106 108
    }
107 109
    while (ei != events.end()) {
108 110
        EventList::iterator ni = ei;
109
        ++ni;
110
        if (ni == events.end()) break;
111
        if (ni == events.end() ||
112
            ++ni == events.end()) {
113
            break;
114
        }
111 115
	nextBeat = ni->time;
112 116
	beats = nearbyint((nextBeat - prevBeat) / beatInterval - 0.01); //prefer slow
113 117
	currentInterval = (nextBeat - prevBeat) / beats;
Peaks.cpp
58 58
    vector<int> peaks;
59 59
    int maxp = 0;
60 60
    int mid = 0;
61
    if (data.empty()) return peaks;
61 62
    int end = data.size();
62 63
    double av = data[0];
63 64
    while (mid < end) {
Peaks.h
75 75
    static void getSlope(const vector<double> &data, double hop, int n,
76 76
			 vector<double> &slope);
77 77

  
78
    static double min(const vector<double> &arr) { return arr[imin(arr)]; }
79
    static double max(const vector<double> &arr) { return arr[imax(arr)]; }
78
    static double min(const vector<double> &arr) {
79
        if (arr.empty()) return 0;
80
        return arr[imin(arr)];
81
    }
82
    static double max(const vector<double> &arr) {
83
        if (arr.empty()) return 0;
84
        return arr[imax(arr)];
85
    }
80 86

  
81 87
    static int imin(const vector<double> &arr);
82 88
    static int imax(const vector<double> &arr);

Also available in: Unified diff