1 /***************************************************************************
2  *  Copyright 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002               *
3  *    David R. Hill, Leonard Manzara, Craig Schock                         *
4  *                                                                         *
5  *  This program is free software: you can redistribute it and/or modify   *
6  *  it under the terms of the GNU General Public License as published by   *
7  *  the Free Software Foundation, either version 3 of the License, or      *
8  *  (at your option) any later version.                                    *
9  *                                                                         *
10  *  This program is distributed in the hope that it will be useful,        *
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13  *  GNU General Public License for more details.                           *
14  *                                                                         *
15  *  You should have received a copy of the GNU General Public License      *
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
17  ***************************************************************************/
18 // 2014-09
19 // This file was copied from Gnuspeech and modified by Marcelo Y. Matuda.
20 
21 #include "NoiseSource.h"
22 
23 #define FACTOR                    377.0
24 #define INITIAL_SEED              0.7892347
25 
26 
27 
28 namespace GS {
29 namespace TRM {
30 
NoiseSource()31 NoiseSource::NoiseSource() : seed_(INITIAL_SEED)
32 {
33 }
34 
~NoiseSource()35 NoiseSource::~NoiseSource()
36 {
37 }
38 
39 void
reset()40 NoiseSource::reset()
41 {
42 	seed_ = INITIAL_SEED;
43 }
44 
45 double
getSample()46 NoiseSource::getSample()
47 {
48 	double product = seed_ * FACTOR;
49 	seed_ = product - static_cast<int>(product);
50 	return seed_ - 0.5;
51 }
52 
53 } /* namespace TRM */
54 } /* namespace GS */
55