annotate base/SincWindow.h @ 515:08bcc06c38ec tip master

Remove fast-math
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 28 Jan 2020 15:27:37 +0000
parents 701233f8ed41
children
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
cannam@489 14 #ifndef QM_DSP_SINC_WINDOW_H
cannam@489 15 #define QM_DSP_SINC_WINDOW_H
c@351 16
c@351 17 #include <vector>
c@351 18
c@377 19 /**
c@377 20 * A window containing values of the sinc function, i.e. sin(x)/x with
c@377 21 * sinc(0) == 1, with x == 0 at the centre.
c@377 22 */
c@351 23 class SincWindow
c@351 24 {
c@351 25 public:
c@351 26 /**
c@351 27 * Construct a windower of the given length, containing the values
c@351 28 * of sinc(x) with x=0 in the middle, i.e. at sample (length-1)/2
c@351 29 * for odd or (length/2)+1 for even length, such that the distance
c@351 30 * from -pi to pi (the nearest zero crossings either side of the
c@351 31 * peak) is p samples.
c@351 32 */
c@351 33 SincWindow(int length, double p) : m_length(length), m_p(p) { init(); }
c@351 34
c@351 35 int getLength() const {
cannam@483 36 return m_length;
c@351 37 }
c@351 38
c@351 39 const double *getWindow() const {
cannam@483 40 return m_window.data();
c@351 41 }
c@351 42
c@351 43 void cut(double *src) const {
cannam@483 44 cut(src, src);
c@351 45 }
c@351 46
c@351 47 void cut(const double *src, double *dst) const {
cannam@483 48 for (int i = 0; i < m_length; ++i) {
cannam@483 49 dst[i] = src[i] * m_window[i];
cannam@483 50 }
c@351 51 }
c@351 52
c@351 53 private:
c@351 54 int m_length;
c@351 55 double m_p;
c@351 56 std::vector<double> m_window;
c@351 57
c@351 58 void init();
c@351 59 };
c@351 60
c@351 61 #endif