1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
6
Centre for Digital Music, Queen Mary, University of London.
7
This file copyright 2008-2009 Matthew Davies and QMUL.
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.
17
#ifndef TEMPOTRACKV2_H
18
#define TEMPOTRACKV2_H
22
#include <stddef.h> //resolves size_t compile error on Ubuntu 11.10
27
//!!! Question: how far is this actually sample rate dependent? I
28
// think it does produce plausible results for e.g. 48000 as well as
29
// 44100, but surely the fixed window sizes and comb filtering will
30
// make it prefer double or half time when run at e.g. 96000?
36
* Construct a tempo tracker that will operate on beat detection
37
* function data calculated from audio at the given sample rate
38
* with the given frame increment.
40
* Currently the sample rate and increment are used only for the
41
* conversion from beat frame location to bpm in the tempo array.
43
TempoTrackV2(float sampleRate, size_t dfIncrement);
46
// Returned beat periods are given in df increment units; tempi in bpm
47
void calculateBeatPeriod(const vector<double> &df,
48
vector<double> &beatPeriod,
49
vector<double> &tempi);
51
// Returned beat positions are given in df increment units
52
void calculateBeats(const vector<double> &df,
53
const vector<double> &beatPeriod,
54
vector<double> &beats);
57
typedef vector<int> i_vec_t;
58
typedef vector<vector<int> > i_mat_t;
59
typedef vector<double> d_vec_t;
60
typedef vector<vector<double> > d_mat_t;
65
void adapt_thresh(d_vec_t &df);
66
double mean_array(const d_vec_t &dfin, int start, int end);
67
void filter_df(d_vec_t &df);
68
void get_rcf(const d_vec_t &dfframe, const d_vec_t &wv, d_vec_t &rcf);
69
void viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv,
70
d_vec_t &bp, d_vec_t &tempi);
71
double get_max_val(const d_vec_t &df);
72
int get_max_ind(const d_vec_t &df);
73
void normalise_vec(d_vec_t &df);