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: #ifndef SINC_WINDOW_H c@351: #define SINC_WINDOW_H c@351: c@351: #include c@351: c@351: class SincWindow c@351: { c@351: public: c@351: /** c@351: * Construct a windower of the given length, containing the values c@351: * of sinc(x) with x=0 in the middle, i.e. at sample (length-1)/2 c@351: * for odd or (length/2)+1 for even length, such that the distance c@351: * from -pi to pi (the nearest zero crossings either side of the c@351: * peak) is p samples. c@351: */ c@351: SincWindow(int length, double p) : m_length(length), m_p(p) { init(); } c@351: c@351: int getLength() const { c@351: return m_length; c@351: } c@351: c@351: const double *getWindow() const { c@351: return m_window.data(); c@351: } c@351: c@351: void cut(double *src) const { c@351: cut(src, src); c@351: } c@351: c@351: void cut(const double *src, double *dst) const { c@351: for (int i = 0; i < m_length; ++i) { c@351: dst[i] = src[i] * m_window[i]; c@351: } c@351: } c@351: c@351: private: c@351: int m_length; c@351: double m_p; c@351: std::vector m_window; c@351: c@351: void init(); c@351: }; c@351: c@351: #endif