4
Copyright 2004 Tim Goetze <tim@quitte.de>
6
simple white noise generator, based on Jon Dattorro's 3/2002 JAES
7
paper. quite an elegant design; consumes next to no CPU on a processor
8
providing a decent binary shift operator. most of all, no random() calls.
12
This program is free software; you can redistribute it and/or
13
modify it under the terms of the GNU General Public License
14
as published by the Free Software Foundation; either version 2
15
of the License, or (at your option) any later version.
17
This program is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
GNU General Public License for more details.
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25
02111-1307, USA or point your web browser to http://www.gnu.org.
33
/* after initializing, call either get() or get_31() to get a sample, don't
34
* mix them. (get_31 output goes out of range if called after get()).
48
b = (uint32) (f * (float) 0x1fff7777);
59
# define BIT(y) ((b << (31 - y)) & 0x80000000)
61
b = ((BIT (28) ^ BIT (27) ^ BIT (1) ^ BIT (0))) | (b >> 1);
62
return (4.6566128730773926e-10 * (d_sample) b) - 1;
67
/* 31-bit version, at least 6 instructions less / sample. probably only
68
* pays off on a processor not providing a decent binary shift. */
71
# define BIT(y) ((b << (30 - y)) & 0x40000000)
73
b = ((BIT (3) ^ BIT (0))) | (b >> 1);
74
return (9.3132257461547852e-10 * (d_sample) b) - 1;
82
#endif /* _DSP_WHITE_H_ */