diff BeatRootProcessor.h @ 4:c06cf6f7cb04

Bring in Peaks code from BeatRoot
author Chris Cannam
date Mon, 19 Sep 2011 15:48:26 +0100
parents a821f49c42f0
children 2150607d4726
line wrap: on
line diff
--- a/BeatRootProcessor.h	Mon Jun 20 16:32:11 2011 +0100
+++ b/BeatRootProcessor.h	Mon Sep 19 15:48:26 2011 +0100
@@ -16,6 +16,8 @@
 #ifndef _BEATROOT_PROCESSOR_H_
 #define _BEATROOT_PROCESSOR_H_
 
+#include "Peaks.h"
+
 #include <vector>
 #include <cmath>
 
@@ -53,7 +55,7 @@
     double ltAverage;
 
     /** Spectral flux onset detection function, indexed by frame. */
-    vector<int> spectralFlux;
+    vector<double> spectralFlux;
 	
     /** A mapping function for mapping FFT bins to final frequency bins.
      *  The mapping is linear (1-1) until the resolution reaches 2 points per
@@ -277,18 +279,19 @@
 //		double[] slope = new double[energy.length];
 //		double hop = hopTime / energyOversampleFactor;
 //		Peaks.getSlope(energy, hop, 15, slope);
-//		LinkedList<Integer> peaks = Peaks.findPeaks(slope, (int)lrint(0.06 / hop), 10);
+//		vector<Integer> peaks = Peaks.findPeaks(slope, (int)lrint(0.06 / hop), 10);
 		
         double hop = hopTime;
-        Peaks.normalise(spectralFlux);
-        LinkedList<Integer> peaks = Peaks.findPeaks(spectralFlux, (int)lrint(0.06 / hop), 0.35, 0.84, true);
+        Peaks::normalise(spectralFlux);
+        vector<int> peaks = Peaks::findPeaks(spectralFlux, (int)lrint(0.06 / hop), 0.35, 0.84, true);
         onsets = new double[peaks.size()];
         double[] y2 = new double[onsets.length];
-        Iterator<Integer> it = peaks.iterator();
+        vector<int>::iterator it = peaks.begin();
         onsetList = new EventList();
         double minSalience = Peaks.min(spectralFlux);
         for (int i = 0; i < onsets.length; i++) {
-            int index = it.next();
+            int index = *it;
+            ++it;
             onsets[i] = index * hop;
             y2[i] = spectralFlux[index];
             Event e = BeatTrackDisplay.newBeat(onsets[i], 0);