view WindowFunction.cpp @ 4:597f033fa7a2

* Some cleaning and rearranging to prepare for band processing implementation
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Tue, 05 Aug 2014 15:56:59 +0100
parents 31d2a7e07786
children 21147df9cb2d
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"
#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;
        }
    }
}