annotate base/SincWindow.h @ 374:3e5f13ac984f

Add bandwidth, snr parameters
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 18 Oct 2013 14:57:48 +0100
parents 5d9489187abd
children 0d3b3c66652b
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 #ifndef SINC_WINDOW_H
c@351 15 #define SINC_WINDOW_H
c@351 16
c@351 17 #include <vector>
c@351 18
c@351 19 class SincWindow
c@351 20 {
c@351 21 public:
c@351 22 /**
c@351 23 * Construct a windower of the given length, containing the values
c@351 24 * of sinc(x) with x=0 in the middle, i.e. at sample (length-1)/2
c@351 25 * for odd or (length/2)+1 for even length, such that the distance
c@351 26 * from -pi to pi (the nearest zero crossings either side of the
c@351 27 * peak) is p samples.
c@351 28 */
c@351 29 SincWindow(int length, double p) : m_length(length), m_p(p) { init(); }
c@351 30
c@351 31 int getLength() const {
c@351 32 return m_length;
c@351 33 }
c@351 34
c@351 35 const double *getWindow() const {
c@351 36 return m_window.data();
c@351 37 }
c@351 38
c@351 39 void cut(double *src) const {
c@351 40 cut(src, src);
c@351 41 }
c@351 42
c@351 43 void cut(const double *src, double *dst) const {
c@351 44 for (int i = 0; i < m_length; ++i) {
c@351 45 dst[i] = src[i] * m_window[i];
c@351 46 }
c@351 47 }
c@351 48
c@351 49 private:
c@351 50 int m_length;
c@351 51 double m_p;
c@351 52 std::vector<double> m_window;
c@351 53
c@351 54 void init();
c@351 55 };
c@351 56
c@351 57 #endif