mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
added Blackman window
This commit is contained in:
parent
37f98dcf1c
commit
24594f93bb
2 changed files with 18 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ Implemented are the follwing [Window functions](https://en.wikipedia.org/wiki/Wi
|
|||
* [Hann window](https://en.wikipedia.org/wiki/Window_function#Hann_window)
|
||||
* [Hamming window](https://en.wikipedia.org/wiki/Window_function#Hamming_window)
|
||||
* [Lanczos window](https://en.wikipedia.org/wiki/Window_function#Lanczos_window)
|
||||
* [Blackman window](https://en.wikipedia.org/wiki/Window_function#Blackman_window)
|
||||
* [Gaussian window](https://en.wikipedia.org/wiki/Window_function#Gaussian_window)
|
||||
* [Kaiser window](https://en.wikipedia.org/wiki/Window_function#Kaiser_window)
|
||||
|
||||
|
|
|
|||
17
window.hh
17
window.hh
|
|
@ -72,6 +72,23 @@ public:
|
|||
inline operator const TYPE * () const { return w; }
|
||||
};
|
||||
|
||||
template <int TAPS, typename TYPE>
|
||||
class Blackman
|
||||
{
|
||||
TYPE w[TAPS];
|
||||
public:
|
||||
Blackman(TYPE a0, TYPE a1, TYPE a2)
|
||||
{
|
||||
for (int n = 0; n < TAPS; ++n)
|
||||
w[n] = a0 - a1 * std::cos(Const<TYPE>::TwoPi() * TYPE(n) / TYPE(TAPS - 1)) + a2 * std::cos(Const<TYPE>::FourPi() * TYPE(n) / TYPE(TAPS - 1));
|
||||
}
|
||||
Blackman(TYPE a) : Blackman((TYPE(1) - a) / TYPE(2), TYPE(0.5), a / TYPE(2)) {}
|
||||
// "exact Blackman"
|
||||
Blackman() : Blackman(TYPE(7938) / TYPE(18608), TYPE(9240) / TYPE(18608), TYPE(1430) / TYPE(18608)) {}
|
||||
inline TYPE operator () (int n) { return n >= 0 && n < TAPS ? w[n] : 0; }
|
||||
inline operator const TYPE * () const { return w; }
|
||||
};
|
||||
|
||||
template <int TAPS, typename TYPE>
|
||||
class Gauss
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue