Chris@6: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@6: Chris@6: /* Chris@6: Vamp feature extraction plugin for the BeatRoot beat tracker. Chris@6: Chris@6: Centre for Digital Music, Queen Mary, University of London. Chris@6: This file copyright 2011 Simon Dixon, Chris Cannam and QMUL. Chris@6: Chris@6: This program is free software; you can redistribute it and/or Chris@6: modify it under the terms of the GNU General Public License as Chris@6: published by the Free Software Foundation; either version 2 of the Chris@6: License, or (at your option) any later version. See the file Chris@6: COPYING included with this distribution for more information. Chris@6: */ Chris@6: Chris@6: #ifndef _BEAT_TRACKER_H_ Chris@6: #define _BEAT_TRACKER_H_ Chris@6: Chris@6: #include "Event.h" Chris@6: #include "Agent.h" Chris@8: #include "AgentList.h" Chris@7: #include "Induction.h" Chris@6: Chris@6: using std::vector; Chris@6: Chris@6: class BeatTracker Chris@6: { Chris@6: protected: Chris@6: /** beat data encoded as a list of Events */ Chris@6: EventList beats; Chris@6: Chris@6: /** a list of onset events for passing to the tempo induction and beat tracking methods */ Chris@6: EventList onsetList; Chris@6: Chris@6: /** the times of onsets (in seconds) */ Chris@6: vector onsets; Chris@6: Chris@6: public: Chris@6: /** Constructor: Chris@6: * @param b The list of beats Chris@6: */ Chris@6: BeatTracker(EventList b) { Chris@6: beats = b; Chris@6: } // BeatTracker constructor Chris@6: Chris@6: /** Creates a new Event object representing a beat. Chris@6: * @param time The time of the beat in seconds Chris@6: * @param beatNum The index of the beat Chris@6: * @return The Event object representing the beat Chris@6: */ Chris@6: static Event newBeat(double time, int beatNum) { Chris@6: return Event(time, beatNum, 0); Chris@6: } // newBeat() Chris@6: Chris@6: /** Perform beat tracking. Chris@6: * @param events The onsets or peaks in a feature list Chris@36: * @param unfilledReturn Pointer to list in which to return Chris@36: * un-interpolated beats, or NULL Chris@6: * @return The list of beats, or an empty list if beat tracking fails Chris@6: */ Chris@36: static EventList beatTrack(AgentParameters params, EventList events, Chris@36: EventList *unfilledReturn) { Chris@36: return beatTrack(params, events, EventList(), unfilledReturn); Chris@6: } Chris@6: Chris@6: /** Perform beat tracking. Chris@6: * @param events The onsets or peaks in a feature list Chris@6: * @param beats The initial beats which are given, if any Chris@36: * @param unfilledReturn Pointer to list in which to return Chris@36: * un-interpolated beats, or NULL Chris@6: * @return The list of beats, or an empty list if beat tracking fails Chris@6: */ Chris@23: static EventList beatTrack(AgentParameters params, Chris@36: EventList events, EventList beats, Chris@36: EventList *unfilledReturn); Chris@6: Chris@6: Chris@6: // Various get and set methods Chris@6: Chris@6: /** @return the list of beats */ Chris@6: EventList getBeats() { Chris@6: return beats; Chris@6: } // getBeats() Chris@6: Chris@6: /** @return the array of onset times */ Chris@6: vector getOnsets() { Chris@6: return onsets; Chris@6: } // getOnsets() Chris@6: Chris@6: /** Sets the onset times as a list of Events, for use by the beat tracking methods. Chris@6: * @param on The times of onsets in seconds Chris@6: */ Chris@6: void setOnsetList(EventList on) { Chris@6: onsetList = on; Chris@6: } // setOnsetList() Chris@6: Chris@6: /** Sets the array of onset times, for displaying MIDI or audio input data. Chris@6: * @param on The times of onsets in seconds Chris@6: */ Chris@6: void setOnsets(vector on) { Chris@6: onsets = on; Chris@6: } // setOnsets() Chris@6: Chris@6: /** Sets the list of beats. Chris@6: * @param b The list of beats Chris@6: */ Chris@6: void setBeats(EventList b) { Chris@6: beats = b; Chris@6: } // setBeats() Chris@6: Chris@6: }; // class BeatTrackDisplay Chris@6: Chris@6: Chris@6: #endif Chris@6: