diff WindowFunction.cpp @ 0:31d2a7e07786

Moved all to folder "tempogram".
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Mon, 07 Jul 2014 10:08:14 +0100
parents
children 21147df9cb2d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WindowFunction.cpp	Mon Jul 07 10:08:14 2014 +0100
@@ -0,0 +1,28 @@
+//
+//  WindowFunction.cpp
+//  Tempogram
+//
+//  Created by Carl Bussey on 26/06/2014.
+//  Copyright (c) 2014 Carl Bussey. All rights reserved.
+//
+
+#include "WindowFunction.h"
+#include <cmath>
+#include <vector>
+#include <iostream>
+using std::vector;
+
+void
+WindowFunction::hanning(float *signal, const unsigned int N, const bool normalise){
+    
+    float sum = 0;
+    for(int i = 0; i < N; i++){
+        signal[i] = 0.5*(1-cos((float)2*M_PI*i/N));
+        sum += signal[i];
+    }
+    if (normalise){
+        for(int i = 0; i < N; i++){
+            signal[i] /= sum;
+        }
+    }
+}
\ No newline at end of file