annotate WindowFunction.cpp @ 1:3fd1a41b089b
* Now displaying some output. Needs testing to see if bugs are present.
author |
Carl Bussey <c.bussey@se10.qmul.ac.uk> |
date |
Wed, 09 Jul 2014 10:26:51 +0100 |
parents |
31d2a7e07786 |
children |
21147df9cb2d |
rev |
line source |
c@0
|
1 //
|
c@0
|
2 // WindowFunction.cpp
|
c@0
|
3 // Tempogram
|
c@0
|
4 //
|
c@0
|
5 // Created by Carl Bussey on 26/06/2014.
|
c@0
|
6 // Copyright (c) 2014 Carl Bussey. All rights reserved.
|
c@0
|
7 //
|
c@0
|
8
|
c@0
|
9 #include "WindowFunction.h"
|
c@0
|
10 #include <cmath>
|
c@0
|
11 #include <vector>
|
c@0
|
12 #include <iostream>
|
c@0
|
13 using std::vector;
|
c@0
|
14
|
c@0
|
15 void
|
c@0
|
16 WindowFunction::hanning(float *signal, const unsigned int N, const bool normalise){
|
c@0
|
17
|
c@0
|
18 float sum = 0;
|
c@0
|
19 for(int i = 0; i < N; i++){
|
c@0
|
20 signal[i] = 0.5*(1-cos((float)2*M_PI*i/N));
|
c@0
|
21 sum += signal[i];
|
c@0
|
22 }
|
c@0
|
23 if (normalise){
|
c@0
|
24 for(int i = 0; i < N; i++){
|
c@0
|
25 signal[i] /= sum;
|
c@0
|
26 }
|
c@0
|
27 }
|
c@0
|
28 } |