eDSP  0.0.1
A cross-platform DSP library written in C++.
windowing.hpp
Go to the documentation of this file.
1 /*
2  * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3  * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4  *
5  * This program is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation, either version 3 of the License, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along width
16  * this program. If not, see <http://www.gnu.org/licenses/>
17  *
18  * File: windowing.hpp
19  * Author: Mohammed Boujemaoui
20  * Date: 27/7/2018
21  */
22 #ifndef EDSP_WINDOWING_HPP
23 #define EDSP_WINDOWING_HPP
24 
35 #include <edsp/windowing/welch.hpp>
36 
37 namespace edsp { namespace windowing {
38 
42  enum class WindowType {
43  Bartlett = 0,
44  Blackman,
47  Boxcar,
48  FlatTop,
49  Hamming,
50  Hanning,
51  Rectangular,
52  Triangular,
53  Welch
54  };
55 
56  namespace internal {
57 
58  template <WindowType Type>
59  struct _build_window {};
60 
61  template <>
62  struct _build_window<WindowType::Bartlett> {
63  template <typename OutputIt>
64  constexpr void operator()(OutputIt first, OutputIt last) {
65  bartlett(first, last);
66  }
67  };
68 
69  template <>
70  struct _build_window<WindowType::Blackman> {
71  template <typename OutputIt>
72  constexpr void operator()(OutputIt first, OutputIt last) {
73  blackman(first, last);
74  }
75  };
76 
77  template <>
78  struct _build_window<WindowType::BlackmanHarris> {
79  template <typename OutputIt>
80  constexpr void operator()(OutputIt first, OutputIt last) {
81  blackman_harris(first, last);
82  }
83  };
84 
85  template <>
86  struct _build_window<WindowType::BlackmanNuttall> {
87  template <typename OutputIt>
88  constexpr void operator()(OutputIt first, OutputIt last) {
89  blackman_nutall(first, last);
90  }
91  };
92 
93  template <>
94  struct _build_window<WindowType::Boxcar> {
95  template <typename OutputIt>
96  constexpr void operator()(OutputIt first, OutputIt last) {
97  boxcar(first, last);
98  }
99  };
100 
101  template <>
102  struct _build_window<WindowType::FlatTop> {
103  template <typename OutputIt>
104  constexpr void operator()(OutputIt first, OutputIt last) {
105  flattop(first, last);
106  }
107  };
108 
109  template <>
110  struct _build_window<WindowType::Hamming> {
111  template <typename OutputIt>
112  constexpr void operator()(OutputIt first, OutputIt last) {
113  hamming(first, last);
114  }
115  };
116 
117  template <>
118  struct _build_window<WindowType::Hanning> {
119  template <typename OutputIt>
120  constexpr void operator()(OutputIt first, OutputIt last) {
121  hanning(first, last);
122  }
123  };
124 
125  template <>
126  struct _build_window<WindowType::Rectangular> {
127  template <typename OutputIt>
128  constexpr void operator()(OutputIt first, OutputIt last) {
129  rectangular(first, last);
130  }
131  };
132 
133  template <>
134  struct _build_window<WindowType::Triangular> {
135  template <typename OutputIt>
136  constexpr void operator()(OutputIt first, OutputIt last) {
137  triangular(first, last);
138  }
139  };
140 
141  template <>
142  struct _build_window<WindowType::Welch> {
143  template <typename OutputIt>
144  constexpr void operator()(OutputIt first, OutputIt last) {
145  welch(first, last);
146  }
147  };
148  } // namespace internal
149 
156  template <WindowType Type, typename OutputIt>
157  constexpr void make_window(OutputIt first, OutputIt last) {
158  return internal::_build_window<Type>{}(first, last);
159  }
160 
161 }} // namespace edsp::windowing
162 
163 #endif // EDSP_WINDOWING_HPP
constexpr void blackman_harris(OutputIt first, OutputIt last)
Computes a Blackman-Harris window of length N and stores the result in the range, beginning at d_firs...
Definition: blackman_harris.hpp:46
constexpr void flattop(OutputIt first, OutputIt last)
Computes a Flat top window of length N and stores the result in the range, beginning at d_first...
Definition: flat_top.hpp:46
constexpr void hanning(OutputIt first, OutputIt last)
Computes a Hann window of length N and stores the result in the range, beginning at d_first...
Definition: hanning.hpp:46
constexpr void boxcar(OutputIt first, OutputIt last)
Computes a boxcar (rectangular) window of length N and stores the result in the range, beginning at d_first.
Definition: boxcar.hpp:43
constexpr void blackman_nutall(OutputIt first, OutputIt last)
Computes a Blackman-Nuttall window of length N and stores the result in the range, beginning at d_first.
Definition: blackman_nuttall.hpp:45
constexpr void triangular(OutputIt first, OutputIt last)
Computes a triangular window of length N and stores the result in the range, beginning at d_first...
Definition: triangular.hpp:44
constexpr void rectangular(OutputIt first, OutputIt last)
Computes a rectangular window of length N and stores the result in the range, beginning at d_first...
Definition: rectangular.hpp:44
constexpr void make_window(OutputIt first, OutputIt last)
Computes a window of the given type and length N and stores the result in the range, beginning at d_first.
Definition: windowing.hpp:157
constexpr void welch(OutputIt first, OutputIt last)
Computes a Welch window of length N and stores the result in the range, beginning at d_first...
Definition: welch.hpp:44
WindowType
The WindowType enum represents the type of availables windows.
Definition: windowing.hpp:42
constexpr void hamming(OutputIt first, OutputIt last)
Computes a Hamming window of length N and stores the result in the range, beginning at d_first...
Definition: hamming.hpp:47
constexpr void bartlett(OutputIt first, OutputIt last)
Computes a Bartlett window of length N and stores the result in the range, beginning at d_first...
Definition: bartlett.hpp:36
constexpr void blackman(OutputIt first, OutputIt last)
Computes a Blackman window of length N and stores the result in the range, beginning at d_first...
Definition: blackman.hpp:47
Definition: amplifier.hpp:29