annotate base/SincWindow.cpp @ 209:ccd2019190bf msvc

Some MSVC fixes, including (temporarily, probably) renaming the FFT source file to avoid getting it mixed up with the Vamp SDK one in our object dir
author Chris Cannam
date Thu, 01 Feb 2018 16:34:08 +0000
parents 7669b3aa3bc9
children fdaa63607c15
rev   line source
Chris@126 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@126 2
Chris@126 3 /*
Chris@126 4 QM DSP library
Chris@126 5 Centre for Digital Music, Queen Mary, University of London.
Chris@126 6
Chris@126 7 This program is free software; you can redistribute it and/or
Chris@126 8 modify it under the terms of the GNU General Public License as
Chris@126 9 published by the Free Software Foundation; either version 2 of the
Chris@126 10 License, or (at your option) any later version. See the file
Chris@126 11 COPYING included with this distribution for more information.
Chris@126 12 */
Chris@126 13
Chris@126 14 #include "SincWindow.h"
Chris@126 15
Chris@126 16 #include <cmath>
Chris@126 17
Chris@126 18 void
Chris@126 19 SincWindow::init()
Chris@126 20 {
Chris@126 21 if (m_length < 1) {
Chris@126 22 return;
Chris@126 23 } else if (m_length < 2) {
Chris@126 24 m_window.push_back(1);
Chris@126 25 return;
Chris@126 26 } else {
Chris@126 27
Chris@126 28 int n0 = (m_length % 2 == 0 ? m_length/2 : (m_length - 1)/2);
Chris@126 29 int n1 = (m_length % 2 == 0 ? m_length/2 : (m_length + 1)/2);
Chris@126 30 double m = 2 * M_PI / m_p;
Chris@126 31
Chris@126 32 for (int i = 0; i < n0; ++i) {
Chris@126 33 double x = ((m_length / 2) - i) * m;
Chris@126 34 m_window.push_back(sin(x) / x);
Chris@126 35 }
Chris@126 36
Chris@126 37 m_window.push_back(1.0);
Chris@126 38
Chris@126 39 for (int i = 1; i < n1; ++i) {
Chris@126 40 double x = i * m;
Chris@126 41 m_window.push_back(sin(x) / x);
Chris@126 42 }
Chris@126 43 }
Chris@126 44 }
Chris@126 45