Mercurial > hg > qm-dsp
comparison base/KaiserWindow.h @ 483:fdaa63607c15
Untabify, indent, tidy
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Fri, 31 May 2019 11:54:32 +0100 |
parents | 59b151f13b3e |
children | 701233f8ed41 |
comparison
equal
deleted
inserted
replaced
482:cbe668c7d724 | 483:fdaa63607c15 |
---|---|
24 */ | 24 */ |
25 class KaiserWindow | 25 class KaiserWindow |
26 { | 26 { |
27 public: | 27 public: |
28 struct Parameters { | 28 struct Parameters { |
29 int length; | 29 int length; |
30 double beta; | 30 double beta; |
31 }; | 31 }; |
32 | 32 |
33 /** | 33 /** |
34 * Construct a Kaiser windower with the given length and beta | 34 * Construct a Kaiser windower with the given length and beta |
35 * parameter. | 35 * parameter. |
39 /** | 39 /** |
40 * Construct a Kaiser windower with the given attenuation in dB | 40 * Construct a Kaiser windower with the given attenuation in dB |
41 * and transition width in samples. | 41 * and transition width in samples. |
42 */ | 42 */ |
43 static KaiserWindow byTransitionWidth(double attenuation, | 43 static KaiserWindow byTransitionWidth(double attenuation, |
44 double transition) { | 44 double transition) { |
45 return KaiserWindow | 45 return KaiserWindow |
46 (parametersForTransitionWidth(attenuation, transition)); | 46 (parametersForTransitionWidth(attenuation, transition)); |
47 } | 47 } |
48 | 48 |
49 /** | 49 /** |
50 * Construct a Kaiser windower with the given attenuation in dB | 50 * Construct a Kaiser windower with the given attenuation in dB |
51 * and transition bandwidth in Hz for the given samplerate. | 51 * and transition bandwidth in Hz for the given samplerate. |
52 */ | 52 */ |
53 static KaiserWindow byBandwidth(double attenuation, | 53 static KaiserWindow byBandwidth(double attenuation, |
54 double bandwidth, | 54 double bandwidth, |
55 double samplerate) { | 55 double samplerate) { |
56 return KaiserWindow | 56 return KaiserWindow |
57 (parametersForBandwidth(attenuation, bandwidth, samplerate)); | 57 (parametersForBandwidth(attenuation, bandwidth, samplerate)); |
58 } | 58 } |
59 | 59 |
60 /** | 60 /** |
61 * Obtain the parameters necessary for a Kaiser window of the | 61 * Obtain the parameters necessary for a Kaiser window of the |
62 * given attenuation in dB and transition width in samples. | 62 * given attenuation in dB and transition width in samples. |
63 */ | 63 */ |
64 static Parameters parametersForTransitionWidth(double attenuation, | 64 static Parameters parametersForTransitionWidth(double attenuation, |
65 double transition); | 65 double transition); |
66 | 66 |
67 /** | 67 /** |
68 * Obtain the parameters necessary for a Kaiser window of the | 68 * Obtain the parameters necessary for a Kaiser window of the |
69 * given attenuation in dB and transition bandwidth in Hz for the | 69 * given attenuation in dB and transition bandwidth in Hz for the |
70 * given samplerate. | 70 * given samplerate. |
71 */ | 71 */ |
72 static Parameters parametersForBandwidth(double attenuation, | 72 static Parameters parametersForBandwidth(double attenuation, |
73 double bandwidth, | 73 double bandwidth, |
74 double samplerate) { | 74 double samplerate) { |
75 return parametersForTransitionWidth | 75 return parametersForTransitionWidth |
76 (attenuation, (bandwidth * 2 * M_PI) / samplerate); | 76 (attenuation, (bandwidth * 2 * M_PI) / samplerate); |
77 } | 77 } |
78 | 78 |
79 int getLength() const { | 79 int getLength() const { |
80 return m_length; | 80 return m_length; |
81 } | 81 } |
82 | 82 |
83 const double *getWindow() const { | 83 const double *getWindow() const { |
84 return m_window.data(); | 84 return m_window.data(); |
85 } | 85 } |
86 | 86 |
87 void cut(double *src) const { | 87 void cut(double *src) const { |
88 cut(src, src); | 88 cut(src, src); |
89 } | 89 } |
90 | 90 |
91 void cut(const double *src, double *dst) const { | 91 void cut(const double *src, double *dst) const { |
92 for (int i = 0; i < m_length; ++i) { | 92 for (int i = 0; i < m_length; ++i) { |
93 dst[i] = src[i] * m_window[i]; | 93 dst[i] = src[i] * m_window[i]; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 private: | 97 private: |
98 int m_length; | 98 int m_length; |
99 double m_beta; | 99 double m_beta; |