comparison WindowFunction.cpp @ 11:09fb76606b2b

* Removed many unnecessary heap allocations with objects
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Wed, 13 Aug 2014 10:45:46 +0100
parents be59b4a73f49
children 7680cc4c0073
comparison
equal deleted inserted replaced
9:be59b4a73f49 11:09fb76606b2b
9 #include "WindowFunction.h" 9 #include "WindowFunction.h"
10 using std::vector; 10 using std::vector;
11 11
12 //static function 12 //static function
13 void 13 void
14 WindowFunction::hanning(float *signal, const unsigned int N, const bool normalise){ 14 WindowFunction::hanning(float *window, const unsigned int N, const bool normalise){
15 15
16 float sum = 0; 16 float sum = 0;
17 for(int i = 0; i < N; i++){ 17 for(int i = 0; i < N; i++){
18 sum += signal[i] = 0.5*(1-cos((float)2*M_PI*i/N)); 18 window[i] = 0.5*(1-cos((float)2*M_PI*i/N));
19 sum += window[i];
19 } 20 }
20 if (normalise){ 21 if (normalise){
21 for(int i = 0; i < N; i++){ 22 for(int i = 0; i < N; i++){
22 signal[i] /= sum; 23 window[i] /= sum;
23 } 24 }
24 } 25 }
25 } 26 }