annotate base/SincWindow.cpp @ 515:08bcc06c38ec tip master

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