LMMS
Loading...
Searching...
No Matches
plugins
LadspaEffect
caps
dsp
White.h
Go to the documentation of this file.
1
/*
2
dsp/White.h
3
4
Copyright 2004 Tim Goetze <tim@quitte.de>
5
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.
9
10
*/
11
/*
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.
16
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.
21
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.
26
*/
27
28
#ifndef _DSP_WHITE_H_
29
#define _DSP_WHITE_H_
30
31
namespace
DSP
{
32
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()).
35
*/
36
class
White
37
{
38
public
:
39
uint32
b
;
40
41
White
()
42
{
43
b
= 0x1fff7777;
44
}
45
46
void
init
(
float
f
)
47
{
48
b
= (
uint32
) (
f
* (
float
) 0x1fff7777);
49
}
50
51
sample_t
abs
()
52
{
53
return
fabs (
get
());
54
}
55
56
/* 32-bit version */
57
sample_t
get
()
58
{
59
# define BIT(y) ((b << (31 - y)) & 0x80000000)
60
61
b
= ((
BIT
(28) ^
BIT
(27) ^
BIT
(1) ^
BIT
(0))) | (
b
>> 1);
62
return
(4.6566128730773926e-10 * (
sample_t
)
b
) - 1;
63
64
# undef BIT
65
}
66
67
/* 31-bit version, at least 6 instructions less / sample. probably only
68
* pays off on a processor not providing a decent binary shift. */
69
sample_t
get_31
()
70
{
71
# define BIT(y) ((b << (30 - y)) & 0x40000000)
72
73
b
= ((
BIT
(3) ^
BIT
(0))) | (
b
>> 1);
74
return
(9.3132257461547852e-10 * (
sample_t
)
b
) - 1;
75
76
# undef BIT
77
}
78
};
79
80
}
/* namespace DSP */
81
82
#endif
/* _DSP_WHITE_H_ */
sample_t
LADSPA_Data sample_t
Definition
basics.h:100
uint32
uint32_t uint32
Definition
basics.h:90
DSP::White::init
void init(float f)
Definition
White.h:46
DSP::White::White
White()
Definition
White.h:41
DSP::White::abs
sample_t abs()
Definition
White.h:51
DSP::White::b
uint32 b
Definition
White.h:39
DSP::White::get
sample_t get()
Definition
White.h:57
DSP::White::get_31
sample_t get_31()
Definition
White.h:69
f
unsigned f
Definition
inflate.c:1572
BIT
#define BIT(y)
DSP
Definition
BiQuad.h:31
Generated on
for LMMS by
1.16.1