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