Chris@126: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@126: Chris@126: /* Chris@126: QM DSP library Chris@126: Centre for Digital Music, Queen Mary, University of London. Chris@126: Chris@126: This program is free software; you can redistribute it and/or Chris@126: modify it under the terms of the GNU General Public License as Chris@126: published by the Free Software Foundation; either version 2 of the Chris@126: License, or (at your option) any later version. See the file Chris@126: COPYING included with this distribution for more information. Chris@126: */ Chris@126: Chris@126: #include "SincWindow.h" Chris@126: Chris@126: #include Chris@126: Chris@126: void Chris@126: SincWindow::init() Chris@126: { Chris@126: if (m_length < 1) { Chris@126: return; Chris@126: } else if (m_length < 2) { Chris@126: m_window.push_back(1); Chris@126: return; Chris@126: } else { Chris@126: Chris@126: int n0 = (m_length % 2 == 0 ? m_length/2 : (m_length - 1)/2); Chris@126: int n1 = (m_length % 2 == 0 ? m_length/2 : (m_length + 1)/2); Chris@126: double m = 2 * M_PI / m_p; Chris@126: Chris@126: for (int i = 0; i < n0; ++i) { Chris@126: double x = ((m_length / 2) - i) * m; Chris@126: m_window.push_back(sin(x) / x); Chris@126: } Chris@126: Chris@126: m_window.push_back(1.0); Chris@126: Chris@126: for (int i = 1; i < n1; ++i) { Chris@126: double x = i * m; Chris@126: m_window.push_back(sin(x) / x); Chris@126: } Chris@126: } Chris@126: } Chris@126: