annotate BeatTracker.h @ 37:1f175ae200a6 tip

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