annotate dsp/tempotracking/TempoTrackV2.h @ 58:d72fcd34d9a7

* Fixes to problems shown up by vamp-plugin-tester. Still not all plugins pass all tests, though
author cannam
date Mon, 23 Mar 2009 16:28:53 +0000
parents 5bec06ecc88a
children e5907ae6de17
rev   line source
cannam@52 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@52 2
cannam@52 3 /*
cannam@52 4 QM DSP Library
cannam@52 5
cannam@52 6 Centre for Digital Music, Queen Mary, University of London.
cannam@52 7 This file copyright 2008-2009 Matthew Davies and QMUL.
cannam@52 8 All rights reserved.
cannam@52 9 */
cannam@52 10
cannam@52 11
cannam@52 12 #ifndef TEMPOTRACKV2_H
cannam@52 13 #define TEMPOTRACKV2_H
cannam@52 14
cannam@52 15 #include <vector>
cannam@52 16
cannam@52 17 using std::vector;
cannam@52 18
cannam@54 19 //!!! Question: how far is this actually sample rate dependent? I
cannam@54 20 // think it does produce plausible results for e.g. 48000 as well as
cannam@54 21 // 44100, but surely the fixed window sizes and comb filtering will
cannam@54 22 // make it prefer double or half time when run at e.g. 96000?
cannam@54 23
cannam@52 24 class TempoTrackV2
cannam@52 25 {
cannam@52 26 public:
cannam@54 27 /**
cannam@54 28 * Construct a tempo tracker that will operate on beat detection
cannam@54 29 * function data calculated from audio at the given sample rate
cannam@54 30 * with the given frame increment.
cannam@54 31 *
cannam@54 32 * Currently the sample rate and increment are used only for the
cannam@54 33 * conversion from beat frame location to bpm in the tempo array.
cannam@54 34 */
cannam@54 35 TempoTrackV2(float sampleRate, size_t dfIncrement);
cannam@52 36 ~TempoTrackV2();
cannam@52 37
cannam@54 38 // Returned beat periods are given in df increment units; tempi in bpm
cannam@52 39 void calculateBeatPeriod(const vector<double> &df,
cannam@53 40 vector<double> &beatPeriod,
cannam@53 41 vector<double> &tempi);
cannam@52 42
cannam@54 43 // Returned beat positions are given in df increment units
cannam@52 44 void calculateBeats(const vector<double> &df,
cannam@52 45 const vector<double> &beatPeriod,
cannam@52 46 vector<double> &beats);
cannam@52 47
cannam@52 48 private:
cannam@52 49 typedef vector<int> i_vec_t;
cannam@52 50 typedef vector<vector<int> > i_mat_t;
cannam@52 51 typedef vector<double> d_vec_t;
cannam@52 52 typedef vector<vector<double> > d_mat_t;
cannam@52 53
cannam@54 54 float m_rate;
cannam@54 55 size_t m_increment;
cannam@54 56
cannam@52 57 void adapt_thresh(d_vec_t &df);
cannam@52 58 double mean_array(const d_vec_t &dfin, int start, int end);
cannam@52 59 void filter_df(d_vec_t &df);
cannam@52 60 void get_rcf(const d_vec_t &dfframe, const d_vec_t &wv, d_vec_t &rcf);
cannam@53 61 void viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv,
cannam@53 62 d_vec_t &bp, d_vec_t &tempi);
cannam@52 63 double get_max_val(const d_vec_t &df);
cannam@52 64 int get_max_ind(const d_vec_t &df);
cannam@52 65 void normalise_vec(d_vec_t &df);
cannam@52 66 };
cannam@52 67
cannam@52 68 #endif