Ardour  9.0-pre0-582-g084a23a80d
KaiserWindow.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  QM DSP library
5  Centre for Digital Music, Queen Mary, University of London.
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of the
10  License, or (at your option) any later version. See the file
11  COPYING included with this distribution for more information.
12 */
13 
14 #ifndef KAISER_WINDOW_H
15 #define KAISER_WINDOW_H
16 
17 #include <vector>
18 #include <cmath>
19 
26 {
27 public:
28  struct Parameters {
29  int length;
30  double beta;
31  };
32 
38 
43  static KaiserWindow byTransitionWidth(double attenuation,
44  double transition) {
45  return KaiserWindow
46  (parametersForTransitionWidth(attenuation, transition));
47  }
48 
53  static KaiserWindow byBandwidth(double attenuation,
54  double bandwidth,
55  double samplerate) {
56  return KaiserWindow
57  (parametersForBandwidth(attenuation, bandwidth, samplerate));
58  }
59 
64  static Parameters parametersForTransitionWidth(double attenuation,
65  double transition);
66 
72  static Parameters parametersForBandwidth(double attenuation,
73  double bandwidth,
74  double samplerate) {
76  (attenuation, (bandwidth * 2 * M_PI) / samplerate);
77  }
78 
79  int getLength() const {
80  return m_length;
81  }
82 
83  const double *getWindow() const {
84  return &m_window[0];
85  }
86 
87  void cut(double *src) const {
88  cut(src, src);
89  }
90 
91  void cut(const double *src, double *dst) const {
92  for (int i = 0; i < m_length; ++i) {
93  dst[i] = src[i] * m_window[i];
94  }
95  }
96 
97 private:
98  int m_length;
99  double m_beta;
100  std::vector<double> m_window;
101 
102  void init();
103 };
104 
105 #endif
static Parameters parametersForBandwidth(double attenuation, double bandwidth, double samplerate)
Definition: KaiserWindow.h:72
const double * getWindow() const
Definition: KaiserWindow.h:83
int getLength() const
Definition: KaiserWindow.h:79
static Parameters parametersForTransitionWidth(double attenuation, double transition)
std::vector< double > m_window
Definition: KaiserWindow.h:100
static KaiserWindow byTransitionWidth(double attenuation, double transition)
Definition: KaiserWindow.h:43
double m_beta
Definition: KaiserWindow.h:99
void cut(double *src) const
Definition: KaiserWindow.h:87
KaiserWindow(Parameters p)
Definition: KaiserWindow.h:37
static KaiserWindow byBandwidth(double attenuation, double bandwidth, double samplerate)
Definition: KaiserWindow.h:53
void cut(const double *src, double *dst) const
Definition: KaiserWindow.h:91
PBD::PropertyDescriptor< timecnt_t > length