qm-dsp
1.8
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 QM DSP library 00005 Centre for Digital Music, Queen Mary, University of London. 00006 00007 This program is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License as 00009 published by the Free Software Foundation; either version 2 of the 00010 License, or (at your option) any later version. See the file 00011 COPYING included with this distribution for more information. 00012 */ 00013 00014 #ifndef SINC_WINDOW_H 00015 #define SINC_WINDOW_H 00016 00017 #include <vector> 00018 00023 class SincWindow 00024 { 00025 public: 00033 SincWindow(int length, double p) : m_length(length), m_p(p) { init(); } 00034 00035 int getLength() const { 00036 return m_length; 00037 } 00038 00039 const double *getWindow() const { 00040 return m_window.data(); 00041 } 00042 00043 void cut(double *src) const { 00044 cut(src, src); 00045 } 00046 00047 void cut(const double *src, double *dst) const { 00048 for (int i = 0; i < m_length; ++i) { 00049 dst[i] = src[i] * m_window[i]; 00050 } 00051 } 00052 00053 private: 00054 int m_length; 00055 double m_p; 00056 std::vector<double> m_window; 00057 00058 void init(); 00059 }; 00060 00061 #endif