eDSP  0.0.1
A cross-platform DSP library written in C++.
oscillator.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: make_oscillator.hpp
19  * Author Mohammed Boujemaoui Boulaghmoudi on 03/10/18.
20  */
21 
22 #ifndef EDSP_MAKE_OSCILLATOR_HPP
23 #define EDSP_MAKE_OSCILLATOR_HPP
24 
29 
30 namespace edsp { namespace oscillators {
31 
32  namespace internal {
33  template <OscillatorType Type, typename T>
34  struct _build_Generator;
35 
36  template <typename T>
37  struct _build_Generator<OscillatorType::Sinusoidal, T> {
38  template <typename... Args>
39  constexpr auto build(Args... arg) -> oscillators::sin_oscillator<T> {
40  return oscillators::sin_oscillator<T>(arg...);
41  }
42  };
43 
44  template <typename T>
45  struct _build_Generator<OscillatorType::Square, T> {
46  template <typename... Args>
47  constexpr auto build(Args... arg) -> oscillators::square_oscillator<T> {
48  return oscillators::square_oscillator<T>(arg...);
49  }
50  };
51 
52  template <typename T>
53  struct _build_Generator<OscillatorType::Triangular, T> {
54  template <typename... Args>
55  constexpr auto build(Args... arg) -> oscillators::triangular_oscillator<T> {
57  }
58  };
59 
60  template <typename T>
61  struct _build_Generator<OscillatorType::Sawtooth, T> {
62  template <typename... Args>
63  constexpr auto build(Args... arg) -> oscillators::sawtooth_oscillator<T> {
65  }
66  };
67 
68  } // namespace internal
69 
78  template <typename T, OscillatorType Type, typename... Args>
79  constexpr auto make_oscillator(Args... arg) noexcept
80  -> decltype(internal::_build_Generator<Type, T>{}.template build(std::declval<Args&&>()...)) {
81  return internal::_build_Generator<Type, T>{}.build(arg...);
82  }
83 
84 }} // namespace edsp::oscillators
85 
86 #endif //EDSP_MAKE_OSCILLATOR_HPP
The class sawtooth_oscillator generates a sawtooth signal.
Definition: sawtooth.hpp:41
The class triangular_oscillator generates a triangular signal.
Definition: triangular.hpp:41
template build(std::declval< Args &&>()...))
Definition: oscillator.hpp:80
The class square_oscillator generates a square signal.
Definition: square.hpp:49
constexpr auto make_oscillator(Args... arg) noexcept -> decltype(internal::_build_Generator< Type, T >
Creates an oscillator using args as the parameter list for the construction.
Definition: oscillator.hpp:79
The class sin_oscillator generates a sinusoidal signal.
Definition: sinusoidal.hpp:167
Definition: amplifier.hpp:29
OscillatorType
the OscillatorType enum represents the different waveforms generated by tha available oscillators...
Definition: sinusoidal.hpp:35