Gunar Kroeger / Mbed OS AcusticLocator
Revision:
0:61544337ff5e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Crosscorrel.cpp	Thu May 03 20:39:50 2018 +0000
@@ -0,0 +1,37 @@
+#include "Crosscorrel.h"
+#include "mbed.h"
+
+Crosscorrel::Crosscorrel()
+{
+	this->tau = 50;
+}
+
+float Crosscorrel::GetMax(SignalBuf &buf, unsigned chA, unsigned chB)
+{
+	float max = 0;
+	for(int j = -tau; j <= tau; j++)
+	{
+		float correl = 0;
+		
+		for(unsigned t = 0; t < buf.size(); t++)
+		{
+			correl += buf[t][chA] * GetValue(buf, t+j, chB);
+		}
+		printf("%i\n", int(correl));
+		max = correl > max ? correl : max;
+	}
+	return max;
+}
+
+Crosscorrel::~Crosscorrel()
+{
+
+}
+
+float Crosscorrel::GetValue(SignalBuf &buf, int index, unsigned ch)
+{
+	if(index < 0 || index >= buf.size())
+		return 0;
+	
+	return buf[index][ch];
+}
\ No newline at end of file