1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
5 Centre for Digital Music, Queen Mary, University of London.
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.
14 #ifndef KAISER_WINDOW_H
15 #define KAISER_WINDOW_H
21 * Kaiser window: A windower whose bandwidth and sidelobe height
22 * (signal-noise ratio) can be specified. These parameters are traded
23 * off against the window length.
34 * Construct a Kaiser windower with the given length and beta
37 KaiserWindow(Parameters p) : m_length(p.length), m_beta(p.beta) { init(); }
40 * Construct a Kaiser windower with the given attenuation in dB
41 * and transition width in samples.
43 static KaiserWindow byTransitionWidth(double attenuation,
46 (parametersForTransitionWidth(attenuation, transition));
50 * Construct a Kaiser windower with the given attenuation in dB
51 * and transition bandwidth in Hz for the given samplerate.
53 static KaiserWindow byBandwidth(double attenuation,
57 (parametersForBandwidth(attenuation, bandwidth, samplerate));
61 * Obtain the parameters necessary for a Kaiser window of the
62 * given attenuation in dB and transition width in samples.
64 static Parameters parametersForTransitionWidth(double attenuation,
68 * Obtain the parameters necessary for a Kaiser window of the
69 * given attenuation in dB and transition bandwidth in Hz for the
72 static Parameters parametersForBandwidth(double attenuation,
75 return parametersForTransitionWidth
76 (attenuation, (bandwidth * 2 * M_PI) / samplerate);
79 int getLength() const {
83 const double *getWindow() const {
87 void cut(double *src) const {
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];
100 std::vector<double> m_window;