annotate WindowFunction.cpp @ 57:252d2b03f4a8
Added tag v1.0 for changeset f1c128d0f78c
author |
Chris Cannam |
date |
Thu, 16 Oct 2014 14:22:50 +0100 |
parents |
4cf2d163127b |
children |
|
rev |
line source |
Chris@43
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@43
|
2
|
Chris@43
|
3 /*
|
Chris@43
|
4 Vamp Tempogram Plugin
|
Chris@43
|
5 Carl Bussey, Centre for Digital Music, Queen Mary University of London
|
Chris@43
|
6 Copyright 2014 Queen Mary University of London.
|
Chris@43
|
7
|
Chris@43
|
8 This program is free software; you can redistribute it and/or
|
Chris@43
|
9 modify it under the terms of the GNU General Public License as
|
Chris@43
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@43
|
11 License, or (at your option) any later version. See the file
|
Chris@43
|
12 COPYING included with this distribution for more information.
|
Chris@43
|
13 */
|
c@0
|
14
|
c@0
|
15 #include "WindowFunction.h"
|
c@0
|
16 using std::vector;
|
c@0
|
17
|
c@9
|
18 //static function
|
c@0
|
19 void
|
c@13
|
20 WindowFunction::hanning(float * window, const unsigned int &N, const bool &normalise){
|
c@0
|
21
|
c@0
|
22 float sum = 0;
|
c@20
|
23 for(int i = 0; i < (int)N; i++){
|
c@11
|
24 window[i] = 0.5*(1-cos((float)2*M_PI*i/N));
|
c@11
|
25 sum += window[i];
|
c@0
|
26 }
|
c@0
|
27 if (normalise){
|
c@20
|
28 for(int i = 0; i < (int)N; i++){
|
c@11
|
29 window[i] /= sum;
|
c@0
|
30 }
|
c@0
|
31 }
|
Chris@43
|
32 }
|