Ardour  9.0-pre0-582-g084a23a80d
DownBeat.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  QM DSP Library
5 
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2008-2009 Matthew Davies 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 DOWNBEAT_H
17 #define DOWNBEAT_H
18 
19 #include <vector>
20 #include <cstddef>
21 
23 
24 using std::vector;
25 
26 class FFTReal;
27 
38 class DownBeat
39 {
40 public:
51  DownBeat(float originalSampleRate,
52  size_t decimationFactor,
53  size_t dfIncrement);
55 
56  void setBeatsPerBar(int bpb);
57 
72  void findDownBeats(const float *audio, // downsampled
73  size_t audioLength, // after downsampling
74  const vector<double> &beats,
75  vector<int> &downbeats);
76 
86  void getBeatSD(vector<double> &beatsd) const;
87 
97  void pushAudioBlock(const float *audio);
98 
102  const float *getBufferedAudio(size_t &length) const;
103 
108 
109 private:
110  typedef vector<int> i_vec_t;
111  typedef vector<vector<int> > i_mat_t;
112  typedef vector<double> d_vec_t;
113  typedef vector<vector<double> > d_mat_t;
114 
116  double measureSpecDiff(d_vec_t oldspec, d_vec_t newspec);
117 
118  int m_bpb;
119  float m_rate;
120  size_t m_factor;
121  size_t m_increment;
124  float *m_buffer;
125  float *m_decbuf;
126  size_t m_bufsiz;
127  size_t m_buffill;
129  double *m_beatframe;
131  double *m_fftRealOut;
132  double *m_fftImagOut;
134 };
135 
136 #endif
double * m_beatframe
Definition: DownBeat.h:129
double * m_fftRealOut
Definition: DownBeat.h:131
FFTReal * m_fft
Definition: DownBeat.h:130
int m_bpb
Definition: DownBeat.h:118
DownBeat(float originalSampleRate, size_t decimationFactor, size_t dfIncrement)
float m_rate
Definition: DownBeat.h:119
vector< double > d_vec_t
Definition: DownBeat.h:112
float * m_decbuf
Definition: DownBeat.h:125
Decimator * m_decimator1
Definition: DownBeat.h:122
size_t m_increment
Definition: DownBeat.h:121
double * m_fftImagOut
Definition: DownBeat.h:132
size_t m_buffill
Definition: DownBeat.h:127
float * m_buffer
Definition: DownBeat.h:124
void pushAudioBlock(const float *audio)
void getBeatSD(vector< double > &beatsd) const
Decimator * m_decimator2
Definition: DownBeat.h:123
vector< vector< double > > d_mat_t
Definition: DownBeat.h:113
vector< vector< int > > i_mat_t
Definition: DownBeat.h:111
void makeDecimators()
size_t m_beatframesize
Definition: DownBeat.h:128
vector< int > i_vec_t
Definition: DownBeat.h:110
void findDownBeats(const float *audio, size_t audioLength, const vector< double > &beats, vector< int > &downbeats)
const float * getBufferedAudio(size_t &length) const
size_t m_factor
Definition: DownBeat.h:120
size_t m_bufsiz
Definition: DownBeat.h:126
void setBeatsPerBar(int bpb)
d_vec_t m_beatsd
Definition: DownBeat.h:133
double measureSpecDiff(d_vec_t oldspec, d_vec_t newspec)
void resetAudioBuffer()
Definition: FFT.h:53
PBD::PropertyDescriptor< timecnt_t > length