comparison BeatRootProcessor.h @ 6:02d388f98c23

Introduce a number of new classes derived from the Java
author Chris Cannam
date Tue, 27 Sep 2011 18:37:01 +0100
parents 2150607d4726
children f04f87b5e643
comparison
equal deleted inserted replaced
5:2150607d4726 6:02d388f98c23
15 15
16 #ifndef _BEATROOT_PROCESSOR_H_ 16 #ifndef _BEATROOT_PROCESSOR_H_
17 #define _BEATROOT_PROCESSOR_H_ 17 #define _BEATROOT_PROCESSOR_H_
18 18
19 #include "Peaks.h" 19 #include "Peaks.h"
20 #include "Event.h"
21 #include "BeatTracker.h"
20 22
21 #include <vector> 23 #include <vector>
22 #include <cmath> 24 #include <cmath>
23 25
24 using std::vector; 26 using std::vector;
86 /** The estimated onset times from peak-picking the onset 88 /** The estimated onset times from peak-picking the onset
87 * detection function(s). */ 89 * detection function(s). */
88 vector<double> onsets; 90 vector<double> onsets;
89 91
90 /** The estimated onset times and their saliences. */ 92 /** The estimated onset times and their saliences. */
91 //!!!EventList onsetList; 93 EventList onsetList;
92 vector<double> onsetList; //!!! corresponding to keyDown member of events in list
93 94
94 /** Total number of audio frames if known, or -1 for live or compressed input. */ 95 /** Total number of audio frames if known, or -1 for live or compressed input. */
95 int totalFrames; 96 int totalFrames;
96 97
97 /** Flag for enabling or disabling debugging output */ 98 /** Flag for enabling or disabling debugging output */
285 Peaks::normalise(spectralFlux); 286 Peaks::normalise(spectralFlux);
286 vector<int> peaks = Peaks::findPeaks(spectralFlux, (int)lrint(0.06 / hop), 0.35, 0.84, true); 287 vector<int> peaks = Peaks::findPeaks(spectralFlux, (int)lrint(0.06 / hop), 0.35, 0.84, true);
287 onsets.clear(); 288 onsets.clear();
288 onsets.resize(peaks.size(), 0); 289 onsets.resize(peaks.size(), 0);
289 vector<int>::iterator it = peaks.begin(); 290 vector<int>::iterator it = peaks.begin();
290 onsetList = new EventList(); 291 onsetList.clear();
291 double minSalience = Peaks.min(spectralFlux); 292 double minSalience = Peaks::min(spectralFlux);
292 for (int i = 0; i < onsets.length; i++) { 293 for (int i = 0; i < onsets.size(); i++) {
293 int index = *it; 294 int index = *it;
294 ++it; 295 ++it;
295 onsets[i] = index * hop; 296 onsets[i] = index * hop;
296 Event e = BeatTrackDisplay.newBeat(onsets[i], 0); 297 Event e = BeatTracker::newBeat(onsets[i], 0);
297 // if (debug) 298 // if (debug)
298 // System.err.printf("Onset: %8.3f %8.3f %8.3f\n", 299 // System.err.printf("Onset: %8.3f %8.3f %8.3f\n",
299 // onsets[i], energy[index], slope[index]); 300 // onsets[i], energy[index], slope[index]);
300 // e.salience = slope[index]; // or combination of energy + slope?? 301 // e.salience = slope[index]; // or combination of energy + slope??
301 // Note that salience must be non-negative or the beat tracking system fails! 302 // Note that salience must be non-negative or the beat tracking system fails!
302 e.salience = spectralFlux[index] - minSalience; 303 e.salience = spectralFlux[index] - minSalience;
303 onsetList.add(e); 304 onsetList.push_back(e);
304 } 305 }
305 306
306 //!!! This onsetList is then fed in to BeatTrackDisplay::beatTrack 307 //!!! This onsetList is then fed in to BeatTrackDisplay::beatTrack
307 308
308 } // processFile() 309 } // processFile()