# HG changeset patch # User Adam Stark # Date 1390871264 0 # Node ID ae3ec9b14092524c2709518ceb9423ffe3d42af4 # Parent b387d8327729da0b6e01a1c510c761485ff38e5a Updated README, installation instructions for Python module and added an example.py file to explain how to use the Python module. Also regenerated documentation. diff -r b387d8327729 -r ae3ec9b14092 README.md --- a/README.md Tue Jan 28 00:49:53 2014 +0000 +++ b/README.md Tue Jan 28 01:07:44 2014 +0000 @@ -9,7 +9,7 @@ About BTrack ------------ -BTrack is a causal beat tracking algorithm intended for real-time use. It is implemented in C++ with a wrapper for Python. +BTrack is a causal beat tracking algorithm intended for real-time use. It is implemented in C++ with wrappers for Python and the Vamp plug-in framework. Full details of the working of the algorithm can be found in: diff -r b387d8327729 -r ae3ec9b14092 doc/html/_b_track_8cpp.html --- a/doc/html/_b_track_8cpp.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/_b_track_8cpp.html Tue Jan 28 01:07:44 2014 +0000 @@ -103,7 +103,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/_b_track_8h.html --- a/doc/html/_b_track_8h.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/_b_track_8h.html Tue Jan 28 01:07:44 2014 +0000 @@ -111,7 +111,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/_b_track_8h_source.html --- a/doc/html/_b_track_8h_source.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/_b_track_8h_source.html Tue Jan 28 01:07:44 2014 +0000 @@ -202,7 +202,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/_onset_detection_function_8cpp.html --- a/doc/html/_onset_detection_function_8cpp.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/_onset_detection_function_8cpp.html Tue Jan 28 01:07:44 2014 +0000 @@ -101,7 +101,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/_onset_detection_function_8h.html --- a/doc/html/_onset_detection_function_8h.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/_onset_detection_function_8h.html Tue Jan 28 01:07:44 2014 +0000 @@ -168,7 +168,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/_onset_detection_function_8h_source.html --- a/doc/html/_onset_detection_function_8h_source.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/_onset_detection_function_8h_source.html Tue Jan 28 01:07:44 2014 +0000 @@ -125,80 +125,86 @@
58 {
59 public:
60 
-
67  OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType);
+
66  OnsetDetectionFunction(int hopSize_,int frameSize_);
+
67 
68 
-
70  ~OnsetDetectionFunction();
-
71 
-
78  void initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType);
+
75  OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType_);
+
76 
+
78  ~OnsetDetectionFunction();
79 
-
84  double calculateOnsetDetectionFunctionSample(double *buffer);
-
85 
-
89  void setOnsetDetectionFunctionType(int onsetDetectionFunctionType_);
-
90 
-
91 private:
-
92 
-
94  void performFFT();
-
95 
-
96  //=======================================================================
-
98  double energyEnvelope();
-
99 
-
101  double energyDifference();
-
102 
-
104  double spectralDifference();
+
85  void initialise(int hopSize_,int frameSize_);
+
86 
+
93  void initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType_);
+
94 
+
99  double calculateOnsetDetectionFunctionSample(double *buffer);
+
100 
+
104  void setOnsetDetectionFunctionType(int onsetDetectionFunctionType_);
105 
-
107  double spectralDifferenceHWR();
-
108 
-
110  double phaseDeviation();
-
111 
-
113  double complexSpectralDifference();
+
106 private:
+
107 
+
109  void performFFT();
+
110 
+
111  //=======================================================================
+
113  double energyEnvelope();
114 
-
116  double complexSpectralDifferenceHWR();
+
116  double energyDifference();
117 
-
119  double highFrequencyContent();
+
119  double spectralDifference();
120 
-
122  double highFrequencySpectralDifference();
+
122  double spectralDifferenceHWR();
123 
-
125  double highFrequencySpectralDifferenceHWR();
-
126 
-
127  //=======================================================================
-
129  void calculateRectangularWindow();
-
130 
-
132  void calculateHanningWindow();
-
133 
-
135  void calclulateHammingWindow();
-
136 
-
138  void calculateBlackmanWindow();
-
139 
-
141  void calculateTukeyWindow();
-
142 
-
143  //=======================================================================
-
148  double princarg(double phaseVal);
-
149 
-
150 
-
151  double pi;
-
153  int frameSize;
-
154  int hopSize;
-
155  int onsetDetectionFunctionType;
-
157  fftw_plan p;
-
158  fftw_complex *complexIn;
-
159  fftw_complex *complexOut;
-
161  bool initialised;
-
163  std::vector<double> frame;
-
164  std::vector<double> window;
-
166  double prevEnergySum;
-
168  std::vector<double> magSpec;
-
169  std::vector<double> prevMagSpec;
-
171  std::vector<double> phase;
-
172  std::vector<double> prevPhase;
-
173  std::vector<double> prevPhase2;
-
175 };
-
176 
-
177 
-
178 #endif
+
125  double phaseDeviation();
+
126 
+
128  double complexSpectralDifference();
+
129 
+
131  double complexSpectralDifferenceHWR();
+
132 
+
134  double highFrequencyContent();
+
135 
+
137  double highFrequencySpectralDifference();
+
138 
+
140  double highFrequencySpectralDifferenceHWR();
+
141 
+
142  //=======================================================================
+
144  void calculateRectangularWindow();
+
145 
+
147  void calculateHanningWindow();
+
148 
+
150  void calclulateHammingWindow();
+
151 
+
153  void calculateBlackmanWindow();
+
154 
+
156  void calculateTukeyWindow();
+
157 
+
158  //=======================================================================
+
163  double princarg(double phaseVal);
+
164 
+
165 
+
166  double pi;
+
168  int frameSize;
+
169  int hopSize;
+
170  int onsetDetectionFunctionType;
+
171  int windowType;
+
173  fftw_plan p;
+
174  fftw_complex *complexIn;
+
175  fftw_complex *complexOut;
+
177  bool initialised;
+
179  std::vector<double> frame;
+
180  std::vector<double> window;
+
182  double prevEnergySum;
+
184  std::vector<double> magSpec;
+
185  std::vector<double> prevMagSpec;
+
187  std::vector<double> phase;
+
188  std::vector<double> prevPhase;
+
189  std::vector<double> prevPhase2;
+
191 };
+
192 
+
193 
+
194 #endif
diff -r b387d8327729 -r ae3ec9b14092 doc/html/annotated.html --- a/doc/html/annotated.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/annotated.html Tue Jan 28 01:07:44 2014 +0000 @@ -92,7 +92,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/class_b_track-members.html --- a/doc/html/class_b_track-members.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/class_b_track-members.html Tue Jan 28 01:07:44 2014 +0000 @@ -104,7 +104,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/class_b_track.html --- a/doc/html/class_b_track.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/class_b_track.html Tue Jan 28 01:07:44 2014 +0000 @@ -516,7 +516,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/class_onset_detection_function-members.html --- a/doc/html/class_onset_detection_function-members.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/class_onset_detection_function-members.html Tue Jan 28 01:07:44 2014 +0000 @@ -87,14 +87,16 @@

This is the complete list of members for OnsetDetectionFunction, including all inherited members.

- - + + + +
calculateOnsetDetectionFunctionSample(double *buffer)OnsetDetectionFunction
initialise(int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType)OnsetDetectionFunction
OnsetDetectionFunction(int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType)OnsetDetectionFunction
initialise(int hopSize_, int frameSize_)OnsetDetectionFunction
initialise(int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)OnsetDetectionFunction
OnsetDetectionFunction(int hopSize_, int frameSize_)OnsetDetectionFunction
OnsetDetectionFunction(int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)OnsetDetectionFunction
setOnsetDetectionFunctionType(int onsetDetectionFunctionType_)OnsetDetectionFunction
~OnsetDetectionFunction()OnsetDetectionFunction
diff -r b387d8327729 -r ae3ec9b14092 doc/html/class_onset_detection_function.html --- a/doc/html/class_onset_detection_function.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/class_onset_detection_function.html Tue Jan 28 01:07:44 2014 +0000 @@ -91,12 +91,16 @@ - - + + + + - - + + + + @@ -105,7 +109,41 @@

Detailed Description

A class for calculating onset detection functions.

Constructor & Destructor Documentation

- + +
+
+

Public Member Functions

 OnsetDetectionFunction (int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType)
 
 OnsetDetectionFunction (int hopSize_, int frameSize_)
 
 OnsetDetectionFunction (int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)
 
 ~OnsetDetectionFunction ()
 
void initialise (int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType)
 
void initialise (int hopSize_, int frameSize_)
 
void initialise (int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)
 
double calculateOnsetDetectionFunctionSample (double *buffer)
 
void setOnsetDetectionFunctionType (int onsetDetectionFunctionType_)
+ + + + + + + + + + + + + + + + + +
OnsetDetectionFunction::OnsetDetectionFunction (int hopSize_,
int frameSize_ 
)
+
+

Constructor that defaults the onset detection function type to ComplexSpectralDifferenceHWR and the window type to HanningWindow

+
Parameters
+ + + +
hopSize_the hop size in audio samples
frameSize_the frame size in audio samples
+
+
+ +
+ +
@@ -131,7 +169,7 @@ - + @@ -194,7 +232,41 @@ - + +
+
+
int windowType windowType_ 
+ + + + + + + + + + + + + + + + + +
void OnsetDetectionFunction::initialise (int hopSize_,
int frameSize_ 
)
+
+

Initialisation function for only updating hop size and frame size (and not window type or onset detection function type

+
Parameters
+ + + +
hopSize_the hop size in audio samples
frameSize_the frame size in audio samples
+
+
+ +
+
+
@@ -220,7 +292,7 @@ - + @@ -272,7 +344,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/classes.html --- a/doc/html/classes.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/classes.html Tue Jan 28 01:07:44 2014 +0000 @@ -96,7 +96,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html --- a/doc/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html Tue Jan 28 01:07:44 2014 +0000 @@ -99,7 +99,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/files.html --- a/doc/html/files.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/files.html Tue Jan 28 01:07:44 2014 +0000 @@ -94,7 +94,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/functions.html --- a/doc/html/functions.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/functions.html Tue Jan 28 01:07:44 2014 +0000 @@ -114,10 +114,10 @@ : BTrack
  • initialise() -: OnsetDetectionFunction +: OnsetDetectionFunction
  • OnsetDetectionFunction() -: OnsetDetectionFunction +: OnsetDetectionFunction
  • processAudioFrame() : BTrack @@ -141,7 +141,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/functions_func.html --- a/doc/html/functions_func.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/functions_func.html Tue Jan 28 01:07:44 2014 +0000 @@ -114,10 +114,10 @@ : BTrack
  • initialise() -: OnsetDetectionFunction +: OnsetDetectionFunction
  • OnsetDetectionFunction() -: OnsetDetectionFunction +: OnsetDetectionFunction
  • processAudioFrame() : BTrack @@ -141,7 +141,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/globals.html --- a/doc/html/globals.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/globals.html Tue Jan 28 01:07:44 2014 +0000 @@ -95,7 +95,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/globals_enum.html --- a/doc/html/globals_enum.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/globals_enum.html Tue Jan 28 01:07:44 2014 +0000 @@ -95,7 +95,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/index.html --- a/doc/html/index.html Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/index.html Tue Jan 28 01:07:44 2014 +0000 @@ -120,7 +120,7 @@ diff -r b387d8327729 -r ae3ec9b14092 doc/html/search/all_69.js --- a/doc/html/search/all_69.js Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/search/all_69.js Tue Jan 28 01:07:44 2014 +0000 @@ -1,4 +1,4 @@ var searchData= [ - ['initialise',['initialise',['../class_onset_detection_function.html#a654ed22782f6dc62e8347df44c90fbeb',1,'OnsetDetectionFunction']]] + ['initialise',['initialise',['../class_onset_detection_function.html#ab3379d150c375e4a7e525f326ce5a2e6',1,'OnsetDetectionFunction::initialise(int hopSize_, int frameSize_)'],['../class_onset_detection_function.html#a4f9e1352bfdcd032bdd8193cc72489ba',1,'OnsetDetectionFunction::initialise(int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)']]] ]; diff -r b387d8327729 -r ae3ec9b14092 doc/html/search/all_6f.js --- a/doc/html/search/all_6f.js Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/search/all_6f.js Tue Jan 28 01:07:44 2014 +0000 @@ -1,6 +1,6 @@ var searchData= [ - ['onsetdetectionfunction',['OnsetDetectionFunction',['../class_onset_detection_function.html',1,'OnsetDetectionFunction'],['../class_onset_detection_function.html#a7b4e4ab1b0be5f57682c52141eb959d6',1,'OnsetDetectionFunction::OnsetDetectionFunction()']]], + ['onsetdetectionfunction',['OnsetDetectionFunction',['../class_onset_detection_function.html',1,'OnsetDetectionFunction'],['../class_onset_detection_function.html#a1af5db39698d413cbb892b3a6de7aee5',1,'OnsetDetectionFunction::OnsetDetectionFunction(int hopSize_, int frameSize_)'],['../class_onset_detection_function.html#ad2c23f2d1ac346da8289712df173b190',1,'OnsetDetectionFunction::OnsetDetectionFunction(int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)']]], ['onsetdetectionfunction_2ecpp',['OnsetDetectionFunction.cpp',['../_onset_detection_function_8cpp.html',1,'']]], ['onsetdetectionfunction_2eh',['OnsetDetectionFunction.h',['../_onset_detection_function_8h.html',1,'']]], ['onsetdetectionfunctiontype',['OnsetDetectionFunctionType',['../_onset_detection_function_8h.html#a36dbf81d14d771e0712d0316ec06612b',1,'OnsetDetectionFunction.h']]] diff -r b387d8327729 -r ae3ec9b14092 doc/html/search/functions_69.js --- a/doc/html/search/functions_69.js Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/search/functions_69.js Tue Jan 28 01:07:44 2014 +0000 @@ -1,4 +1,4 @@ var searchData= [ - ['initialise',['initialise',['../class_onset_detection_function.html#a654ed22782f6dc62e8347df44c90fbeb',1,'OnsetDetectionFunction']]] + ['initialise',['initialise',['../class_onset_detection_function.html#ab3379d150c375e4a7e525f326ce5a2e6',1,'OnsetDetectionFunction::initialise(int hopSize_, int frameSize_)'],['../class_onset_detection_function.html#a4f9e1352bfdcd032bdd8193cc72489ba',1,'OnsetDetectionFunction::initialise(int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)']]] ]; diff -r b387d8327729 -r ae3ec9b14092 doc/html/search/functions_6f.js --- a/doc/html/search/functions_6f.js Tue Jan 28 00:49:53 2014 +0000 +++ b/doc/html/search/functions_6f.js Tue Jan 28 01:07:44 2014 +0000 @@ -1,4 +1,4 @@ var searchData= [ - ['onsetdetectionfunction',['OnsetDetectionFunction',['../class_onset_detection_function.html#a7b4e4ab1b0be5f57682c52141eb959d6',1,'OnsetDetectionFunction']]] + ['onsetdetectionfunction',['OnsetDetectionFunction',['../class_onset_detection_function.html#a1af5db39698d413cbb892b3a6de7aee5',1,'OnsetDetectionFunction::OnsetDetectionFunction(int hopSize_, int frameSize_)'],['../class_onset_detection_function.html#ad2c23f2d1ac346da8289712df173b190',1,'OnsetDetectionFunction::OnsetDetectionFunction(int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)']]] ]; diff -r b387d8327729 -r ae3ec9b14092 modules-and-plug-ins/python-module/INSTALL.md --- a/modules-and-plug-ins/python-module/INSTALL.md Tue Jan 28 00:49:53 2014 +0000 +++ b/modules-and-plug-ins/python-module/INSTALL.md Tue Jan 28 01:07:44 2014 +0000 @@ -15,3 +15,9 @@ python setup.py install You may need to prefix the second command with 'sudo', depending upon your system configuration. + + +Usage +----- + +See the example.py script for basic usage of the Python module. \ No newline at end of file diff -r b387d8327729 -r ae3ec9b14092 modules-and-plug-ins/python-module/example.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules-and-plug-ins/python-module/example.py Tue Jan 28 01:07:44 2014 +0000 @@ -0,0 +1,28 @@ +# need scikits audiolab for reading audio files +from scikits.audiolab import wavread + +# need to import btrack, our beat tracker +import btrack + +# set the path to an audio file on your machine +audioFilePath = "/Users/adamstark/Documents/Audio/Databases/Hainsworth/audio/001.wav" + +# read the audio file +audioData, fs, enc = wavread(audioFilePath) # extract audio from file + +# convert to mono if need be +if (audioData[0].size == 2): + print "converting to mono" + data = np.average(data,axis=1) + +# ========================================== +# Usage A: track beats from audio +beats = btrack.trackBeats(audioData) + +# ========================================== +# Usage B: extract the onset detection function +onsetDF = btrack.calculateOnsetDF(audioData) + +# ========================================== +# Usage C: track beats from the onset detection function (calculated in Usage B) +ODFbeats = btrack.trackBeatsFromOnsetDF(onsetDF)
  • int windowType windowType_