-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeatTracker.h
115 lines (91 loc) · 3.34 KB
/
BeatTracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Vamp feature extraction plugin for the BeatRoot beat tracker.
Centre for Digital Music, Queen Mary, University of London.
This file copyright 2011 Simon Dixon, Chris Cannam and QMUL.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#ifndef _BEAT_TRACKER_H_
#define _BEAT_TRACKER_H_
#include "Event.h"
#include "Agent.h"
#include "AgentList.h"
#include "Induction.h"
using std::vector;
class BeatTracker
{
protected:
/** beat data encoded as a list of Events */
EventList beats;
/** a list of onset events for passing to the tempo induction and beat tracking methods */
EventList onsetList;
/** the times of onsets (in seconds) */
vector<double> onsets;
public:
/** Constructor:
* @param b The list of beats
*/
BeatTracker(EventList b) {
beats = b;
} // BeatTracker constructor
/** Creates a new Event object representing a beat.
* @param time The time of the beat in seconds
* @param beatNum The index of the beat
* @return The Event object representing the beat
*/
static Event newBeat(double time, int beatNum) {
return Event(time, beatNum, 0);
} // newBeat()
/** Perform beat tracking.
* @param events The onsets or peaks in a feature list
* @param unfilledReturn Pointer to list in which to return
* un-interpolated beats, or NULL
* @return The list of beats, or an empty list if beat tracking fails
*/
static EventList beatTrack(AgentParameters params, EventList events,
EventList *unfilledReturn) {
return beatTrack(params, events, EventList(), unfilledReturn);
}
/** Perform beat tracking.
* @param events The onsets or peaks in a feature list
* @param beats The initial beats which are given, if any
* @param unfilledReturn Pointer to list in which to return
* un-interpolated beats, or NULL
* @return The list of beats, or an empty list if beat tracking fails
*/
static EventList beatTrack(AgentParameters params,
EventList events, EventList beats,
EventList *unfilledReturn);
// Various get and set methods
/** @return the list of beats */
EventList getBeats() {
return beats;
} // getBeats()
/** @return the array of onset times */
vector<double> getOnsets() {
return onsets;
} // getOnsets()
/** Sets the onset times as a list of Events, for use by the beat tracking methods.
* @param on The times of onsets in seconds
*/
void setOnsetList(EventList on) {
onsetList = on;
} // setOnsetList()
/** Sets the array of onset times, for displaying MIDI or audio input data.
* @param on The times of onsets in seconds
*/
void setOnsets(vector<double> on) {
onsets = on;
} // setOnsets()
/** Sets the list of beats.
* @param b The list of beats
*/
void setBeats(EventList b) {
beats = b;
} // setBeats()
}; // class BeatTrackDisplay
#endif