ian@0: // Copyright 2011, Ian Hobson. ian@0: // ian@0: // This file is part of gpsynth. ian@0: // ian@0: // gpsynth is free software: you can redistribute it and/or modify ian@0: // it under the terms of the GNU General Public License as published by ian@0: // the Free Software Foundation, either version 3 of the License, or ian@0: // (at your option) any later version. ian@0: // ian@0: // gpsynth is distributed in the hope that it will be useful, ian@0: // but WITHOUT ANY WARRANTY; without even the implied warranty of ian@0: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ian@0: // GNU General Public License for more details. ian@0: // ian@0: // You should have received a copy of the GNU General Public License ian@0: // along with gpsynth in the file COPYING. ian@0: // If not, see http://www.gnu.org/licenses/. ian@0: ian@0: #pragma once ian@0: ian@0: #include ian@0: #include ian@0: ian@0: namespace dsp { ian@0: ian@0: template ian@0: void BlackmanWindow(int size, OutputIterator output) { ian@0: typedef typename std::iterator_traits::value_type T; ian@0: T m1 = (M_PI * 2.0) / (size - 1.0); ian@0: T m2 = (M_PI * 4.0) / (size - 1.0); ian@0: for (T i = 0; i < size; i++) { ian@0: *output++ = 0.42 - 0.5 * std::cos(i * m1) + 0.08 * std::cos(i * m2); ian@0: } ian@0: } ian@0: ian@0: template ian@0: void HannWindow(int size, OutputIterator output) { ian@0: typedef typename std::iterator_traits::value_type T; ian@0: T m = (M_PI * 2.0) / (size - 1.0); ian@0: for (T i = 0; i < size; i++) { ian@0: *output++ = 0.5 - 0.5 * std::cos(i * m); ian@0: } ian@0: } ian@0: ian@0: template ian@0: void HammingWindow(int size, OutputIterator output) { ian@0: typedef typename std::iterator_traits::value_type T; ian@0: T m = (M_PI * 2.0) / (size - 1.0); ian@0: for (T i = 0; i < size; i++) { ian@0: *output++ = 0.54 - 0.46 * std::cos(i * m); ian@0: } ian@0: } ian@0: ian@0: };