changeset 7:c6f38cba266d

Cleaned up redundant code
author Geogaddi\David <d.m.ronan@qmul.ac.uk>
date Wed, 22 Jul 2015 15:14:58 +0100
parents 5690cbc028bf
children fdc592312a96
files .hgignore Source/AudioSourceFeatureExtractor.cpp Source/AudioSourceFeatureExtractor.h
diffstat 3 files changed, 46 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Wed Jul 22 14:59:50 2015 +0100
+++ b/.hgignore	Wed Jul 22 15:14:58 2015 +0100
@@ -387,4 +387,5 @@
 Source\AudioReader.h.orig
 Source\AudioSourceFeatureExtractor.cpp.orig
 Source\AudioSourceFeatureExtractor.h.orig
-Source\FFTW.h.orig
\ No newline at end of file
+Source\FFTW.h.orig
+Builds\VisualStudio2013\FeatureExtractionTool.opensdf
\ No newline at end of file
--- a/Source/AudioSourceFeatureExtractor.cpp	Wed Jul 22 14:59:50 2015 +0100
+++ b/Source/AudioSourceFeatureExtractor.cpp	Wed Jul 22 15:14:58 2015 +0100
@@ -15,6 +15,7 @@
 #include <algorithm>
 #include <string>
 #include <vector>
+#include <memory>
 
 //#include <windows.h>
 
@@ -363,38 +364,38 @@
 	}
 }
 
-void AudioSourceFeatureExtractor::ConvolveFunction(float* & z, float* x, float* y, size_t& lenz, size_t lenx, size_t leny)
-{
-	// computes cross-correlation of two vectors, takes 2 vectors of the same length and computes 2*length-1 lags
-
-	//float *zptr, s, *xp, *yp;
-	//size_t n_lo, n_hi;
-
-	//lenz = lenx + leny - 1;
-
-	//z = new float[lenz];
-
-	//zptr = z;
-
-	//for (size_t i = 0; i < lenz; i++)
-	//{
-	//	s = 0.0;
-	//	n_lo = 0 > (i - leny + 1) ? 0 : (i - leny + 1);
-	//	n_hi = (lenx - 1) < i ? (lenx - 1) : i;
-	//	xp = &x[0] + n_lo;
-	//	yp = &y[0] + i - n_lo;
-
-	//	for (size_t n = n_lo; n <= n_hi; n++)
-	//	{
-	//		s += *xp * *yp;
-	//		xp++;
-	//		yp--;
-	//	}
-
-	//	*zptr = s;
-	//	zptr++;
-	//}
-}
+//void AudioSourceFeatureExtractor::ConvolveFunction(float* & z, float* x, float* y, size_t& lenz, size_t lenx, size_t leny)
+//{
+//	// computes cross-correlation of two vectors, takes 2 vectors of the same length and computes 2*length-1 lags
+//
+//	//float *zptr, s, *xp, *yp;
+//	//size_t n_lo, n_hi;
+//
+//	//lenz = lenx + leny - 1;
+//
+//	//z = new float[lenz];
+//
+//	//zptr = z;
+//
+//	//for (size_t i = 0; i < lenz; i++)
+//	//{
+//	//	s = 0.0;
+//	//	n_lo = 0 > (i - leny + 1) ? 0 : (i - leny + 1);
+//	//	n_hi = (lenx - 1) < i ? (lenx - 1) : i;
+//	//	xp = &x[0] + n_lo;
+//	//	yp = &y[0] + i - n_lo;
+//
+//	//	for (size_t n = n_lo; n <= n_hi; n++)
+//	//	{
+//	//		s += *xp * *yp;
+//	//		xp++;
+//	//		yp--;
+//	//	}
+//
+//	//	*zptr = s;
+//	//	zptr++;
+//	//}
+//}
 
 void AudioSourceFeatureExtractor::XCorr(float*& output, float* input1, float* input2, size_t& outputlen, size_t inputlen, size_t maxLag = 0)
 {
@@ -459,6 +460,7 @@
 		maxLag = static_cast<size_t>(inputlen) - 1;
 	}
 
+	
 	output = new float[2 * maxLag + 1];
 	outputlen = 2 * maxLag + 1;
 
--- a/Source/AudioSourceFeatureExtractor.h	Wed Jul 22 14:59:50 2015 +0100
+++ b/Source/AudioSourceFeatureExtractor.h	Wed Jul 22 15:14:58 2015 +0100
@@ -20,6 +20,7 @@
 #define MAGNITUDESIZE 512
 #define FFTSIZE 1024
 #define PI 3.14159265359
+#include <memory>
 
 class AudioSourceFeatureExtractor
 {
@@ -43,20 +44,12 @@
 
 	float EstimatePerdiodicity(float* data, size_t numSamples);
 
-	void ConvolveFunction(float* &z, float *x, float *y, size_t &lenz, size_t lenx, size_t leny);
-
-	void DownSampler(float* data, float* &out,  size_t lenIn, size_t &lenOut, float currentSampleRate, float futureSampleRate);
-
 	void EnvelopeCurve(float* data, float* &out, size_t dataLen, float sampleRate);
 
-	void Normalise(float* data, float* &out, size_t len);
-
-	void XCorr(float *&output, float* input1, float* input2, size_t &outputlen, size_t  input1len, size_t  maxLag);
+	void XCorr(std::vector<float> *&output, float* input1, float* input2, size_t &outputlen, size_t  input1len, size_t  maxLag);
 
 	float EntropyOfEnergy(float* data, size_t numSamples);
 
-	void PDF_getResampleKrnl(std::vector<float> freqVec, float fsProc, int nfft, int nBin, std::vector<float> &outLogFreqVec, std::vector<std::vector<float>> &outKrnl);
-
 	float Log2(float n);
 
 	int Sign(float x);
@@ -65,6 +58,14 @@
 
 	std::vector<float> LogSpace(float min, float max, int n);
 
+	//void Normalise(float* data, float* &out, size_t len);
+
+	//void ConvolveFunction(float* &z, float *x, float *y, size_t &lenz, size_t lenx, size_t leny);
+
+	//void DownSampler(float* data, float* &out,  size_t lenIn, size_t &lenOut, float currentSampleRate, float futureSampleRate);
+
+	//void PDF_getResampleKrnl(std::vector<float> freqVec, float fsProc, int nfft, int nBin, std::vector<float> &outLogFreqVec, std::vector<std::vector<float>> &outKrnl);
+
 	size_t m_iWriteIdx;
 	size_t m_iFlucIdx;
 	float  m_fSampleRate;