To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / BeatTracker.h @ 23:633ec097fa56

History | View | Annotate | Download (3 KB)

1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2

    
3
/*
4
  Vamp feature extraction plugin for the BeatRoot beat tracker.
5

6
  Centre for Digital Music, Queen Mary, University of London.
7
  This file copyright 2011 Simon Dixon, Chris Cannam and QMUL.
8
    
9
  This program is free software; you can redistribute it and/or
10
  modify it under the terms of the GNU General Public License as
11
  published by the Free Software Foundation; either version 2 of the
12
  License, or (at your option) any later version.  See the file
13
  COPYING included with this distribution for more information.
14
*/
15

    
16
#ifndef _BEAT_TRACKER_H_
17
#define _BEAT_TRACKER_H_
18

    
19
#include "Event.h"
20
#include "Agent.h"
21
#include "AgentList.h"
22
#include "Induction.h"
23

    
24
using std::vector;
25

    
26
class BeatTracker
27
{
28
protected:
29
    /** beat data encoded as a list of Events */
30
    EventList beats;
31
        
32
    /** a list of onset events for passing to the tempo induction and beat tracking methods */
33
    EventList onsetList;
34
        
35
    /** the times of onsets (in seconds) */
36
    vector<double> onsets;
37

    
38
public:
39
    /** Constructor:
40
     *  @param b The list of beats
41
     */
42
    BeatTracker(EventList b) {
43
        beats = b;
44
    } // BeatTracker constructor
45

    
46
    /** Creates a new Event object representing a beat.
47
     *  @param time The time of the beat in seconds
48
     *  @param beatNum The index of the beat
49
     *  @return The Event object representing the beat
50
     */
51
    static Event newBeat(double time, int beatNum) {
52
        return Event(time, beatNum, 0);
53
    } // newBeat()
54

    
55
    /** Perform beat tracking.
56
     *  @param events The onsets or peaks in a feature list
57
     *  @return The list of beats, or an empty list if beat tracking fails
58
     */
59
    static EventList beatTrack(AgentParameters params, EventList events) {
60
        return beatTrack(params, events, EventList());
61
    }
62
        
63
    /** Perform beat tracking.
64
     *  @param events The onsets or peaks in a feature list
65
     *  @param beats The initial beats which are given, if any
66
     *  @return The list of beats, or an empty list if beat tracking fails
67
     */
68
    static EventList beatTrack(AgentParameters params,
69
                               EventList events, EventList beats);
70
        
71
        
72
    // Various get and set methods
73
        
74
    /** @return the list of beats */
75
    EventList getBeats() {
76
        return beats;
77
    } // getBeats()
78

    
79
    /** @return the array of onset times */
80
    vector<double> getOnsets() {
81
        return onsets;
82
    } // getOnsets()
83

    
84
    /** Sets the onset times as a list of Events, for use by the beat tracking methods. 
85
     *  @param on The times of onsets in seconds
86
     */
87
    void setOnsetList(EventList on) {
88
        onsetList = on;
89
    } // setOnsetList()
90

    
91
    /** Sets the array of onset times, for displaying MIDI or audio input data.
92
     *  @param on The times of onsets in seconds
93
     */
94
    void setOnsets(vector<double> on) {
95
        onsets = on;
96
    } // setOnsets()
97

    
98
    /** Sets the list of beats.
99
     * @param b The list of beats
100
     */
101
    void setBeats(EventList b) {
102
        beats = b;
103
    } // setBeats()
104

    
105
}; // class BeatTrackDisplay
106

    
107

    
108
#endif
109