diff --git a/window.hh b/window.hh index 26120df..396bf46 100644 --- a/window.hh +++ b/window.hh @@ -53,6 +53,24 @@ public: inline operator const TYPE * () const { return w; } }; +template +class Lanczos +{ + TYPE w[TAPS]; + TYPE sinc(TYPE x) + { + return TYPE(0) == x ? TYPE(1) : std::sin(TYPE(M_PI) * x) / (TYPE(M_PI) * x); + } +public: + Lanczos() + { + for (int n = 0; n < TAPS; ++n) + w[n] = sinc(TYPE(2 * n) / TYPE(TAPS - 1) - TYPE(1)); + } + inline TYPE operator () (int n) { return n >= 0 && n < TAPS ? w[n] : 0; } + inline operator const TYPE * () const { return w; } +}; + template class Gauss {