view 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
line wrap: on
line source
//
//  WindowFunction.cpp
//  Tempogram
//
//  Created by Carl Bussey on 26/06/2014.
//  Copyright (c) 2014 Carl Bussey. All rights reserved.
//

#include "WindowFunction.h"
using std::vector;

//static function
void
WindowFunction::hanning(float *window, const unsigned int N, const bool normalise){
    
    float sum = 0;
    for(int i = 0; i < N; i++){
        window[i] = 0.5*(1-cos((float)2*M_PI*i/N));
        sum += window[i];
    }
    if (normalise){
        for(int i = 0; i < N; i++){
            window[i] /= sum;
        }
    }
}