LMMS
Loading...
Searching...
No Matches
plugins
LadspaEffect
caps
dsp
RMS.h
Go to the documentation of this file.
1
/*
2
dsp/RMS.h
3
4
Copyright 2004 Tim Goetze <tim@quitte.de>
5
6
http://quitte.de/dsp/
7
8
root-mean-square accumulator.
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_RMS_H_
29
#define _DSP_RMS_H_
30
31
namespace
DSP
{
32
33
class
RMS
34
{
35
protected
:
36
sample_t
buffer
[64];
37
int
write
;
38
39
public
:
40
double
sum
;
41
42
RMS
()
43
{
44
write
= 0;
45
reset
();
46
}
47
48
void
reset
()
49
{
50
sum
= 0.;
51
memset (
buffer
, 0,
sizeof
(
buffer
));
52
}
53
54
/* caution: pass in the *squared* sample value */
55
void
store
(
sample_t
x
)
56
{
57
sum
-=
buffer
[
write
];
58
sum
+= (
buffer
[
write
] =
x
);
59
write
= (
write
+ 1) & 63;
60
}
61
62
sample_t
process
(
sample_t
x
)
63
{
64
store
(
x
);
65
return
rms
();
66
}
67
68
sample_t
rms
()
69
{
70
/* fabs it before sqrt, just in case ... */
71
return
sqrt (fabs (
sum
) / 64);
72
}
73
};
74
75
}
/* namespace DSP */
76
77
#endif
/* _DSP_RMS_H_ */
sample_t
LADSPA_Data sample_t
Definition
basics.h:100
DSP::RMS::RMS
RMS()
Definition
RMS.h:42
DSP::RMS::rms
sample_t rms()
Definition
RMS.h:68
DSP::RMS::reset
void reset()
Definition
RMS.h:48
DSP::RMS::write
int write
Definition
RMS.h:37
DSP::RMS::store
void store(sample_t x)
Definition
RMS.h:55
DSP::RMS::buffer
sample_t buffer[64]
Definition
RMS.h:36
DSP::RMS::process
sample_t process(sample_t x)
Definition
RMS.h:62
DSP::RMS::sum
double sum
Definition
RMS.h:40
x
unsigned x[BMAX+1]
Definition
inflate.c:1586
DSP
Definition
BiQuad.h:31
Generated on
for LMMS by
1.16.1