eDSP  0.0.1
A cross-platform DSP library written in C++.
brown_noise_generator.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: brown_noise.hpp
19  * Author: Mohammed Boujemaoui
20  * Date: 31/7/2018
21  */
22 #ifndef EDSP_BROWN_NOISE_HPP
23 #define EDSP_BROWN_NOISE_HPP
24 
26 
27 namespace edsp { namespace random {
28 
33  template <typename T, typename Engine = std::mt19937>
35  using value_type = T;
36 
41  generator_(white_noise_generator<value_type>(min, max)) {}
42 
48  value_type white = generator_();
49  last_output_ += (0.02 * white);
50  last_output_ /= 1.02;
51  return 3.5 * last_output_;
52  }
53 
54  private:
55  value_type last_output_{0};
57  };
58 
59 }} // namespace edsp::random
60 
61 #endif // EDSP_BROWN_NOISE_HPP
brown_noise_generator(value_type min, value_type max)
Creates a brown noise sequence generator.
Definition: brown_noise_generator.hpp:40
value_type operator()()
Generates a random number following the noise distribution.
Definition: brown_noise_generator.hpp:47
constexpr meta::value_type_t< ForwardIt > max(ForwardIt first, ForwardIt last)
Computes the maximum value of the range [first, last)
Definition: max.hpp:38
This class implements a white noise generator.
Definition: white_noise_generator.hpp:35
This class implements a brown noise generator.
Definition: brown_noise_generator.hpp:34
logger & white(logger &stream)
Updates the logger output color to white.
Definition: logger.hpp:362
T value_type
Definition: brown_noise_generator.hpp:35
constexpr meta::value_type_t< ForwardIt > min(ForwardIt first, ForwardIt last)
Computes the minimum value of the range [first, last)
Definition: min.hpp:38
Definition: amplifier.hpp:29