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 @ 36:937432fc2898

History | View | Annotate | Download (3.34 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
     *  @param unfilledReturn Pointer to list in which to return 
58
     *     un-interpolated beats, or NULL
59
     *  @return The list of beats, or an empty list if beat tracking fails
60
     */
61
    static EventList beatTrack(AgentParameters params, EventList events,
62
                               EventList *unfilledReturn) {
63
        return beatTrack(params, events, EventList(), unfilledReturn);
64
    }
65
        
66
    /** Perform beat tracking.
67
     *  @param events The onsets or peaks in a feature list
68
     *  @param beats The initial beats which are given, if any
69
     *  @param unfilledReturn Pointer to list in which to return
70
     *     un-interpolated beats, or NULL
71
     *  @return The list of beats, or an empty list if beat tracking fails
72
     */
73
    static EventList beatTrack(AgentParameters params,
74
                               EventList events, EventList beats,
75
                               EventList *unfilledReturn);
76
        
77
        
78
    // Various get and set methods
79
        
80
    /** @return the list of beats */
81
    EventList getBeats() {
82
        return beats;
83
    } // getBeats()
84

    
85
    /** @return the array of onset times */
86
    vector<double> getOnsets() {
87
        return onsets;
88
    } // getOnsets()
89

    
90
    /** Sets the onset times as a list of Events, for use by the beat tracking methods. 
91
     *  @param on The times of onsets in seconds
92
     */
93
    void setOnsetList(EventList on) {
94
        onsetList = on;
95
    } // setOnsetList()
96

    
97
    /** Sets the array of onset times, for displaying MIDI or audio input data.
98
     *  @param on The times of onsets in seconds
99
     */
100
    void setOnsets(vector<double> on) {
101
        onsets = on;
102
    } // setOnsets()
103

    
104
    /** Sets the list of beats.
105
     * @param b The list of beats
106
     */
107
    void setBeats(EventList b) {
108
        beats = b;
109
    } // setBeats()
110

    
111
}; // class BeatTrackDisplay
112

    
113

    
114
#endif
115