LMMS
Loading...
Searching...
No Matches
plugins
LadspaEffect
caps
dsp
Lorenz.h
Go to the documentation of this file.
1
/*
2
dsp/Lorenz.h
3
4
Copyright 2001-4 Tim Goetze <tim@quitte.de>
5
6
http://quitte.de/dsp/
7
8
Lorenz fractal.
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_LORENZ_H_
29
#define _DSP_LORENZ_H_
30
31
namespace
DSP
{
32
33
class
Lorenz
34
{
35
public
:
36
double
x
[2],
y
[2],
z
[2];
37
double
h
,
a
,
b
,
c
;
38
int
I
;
39
40
public
:
41
Lorenz
()
42
{
43
h
= 0.001;
44
a
= 10.0;
45
b
= 28.0;
46
c
= 8.0 / 3.0;
47
}
48
49
/* rate is normalized (0 .. 1) */
50
void
set_rate
(
double
r
)
51
{
52
h
=
max
(.0000001,
r
* .015);
53
}
54
55
void
init
(
double
_h = .001,
double
seed = .0)
56
{
57
I
= 0;
58
59
x
[0] = .1 + seed -
frandom
() * .1;
60
y
[0] = 0;
61
z
[0] = 0;
62
63
/* progress quickly to get a 'stable' system */
64
h
= .001;
65
66
int
n
= 10000 +
min
((
int
) (10000 * seed), 10000);
67
for
(
int
i
= 0;
i
<
n
; ++
i
)
68
step
();
69
70
h
= _h;
71
}
72
73
sample_t
get
()
74
{
75
step
();
76
return
.5 *
get_y
() +
get_z
();
77
}
78
79
void
step
()
80
{
81
int
J =
I
^ 1;
82
83
x
[J] =
x
[
I
] +
h
*
a
* (
y
[
I
] -
x
[
I
]);
84
y
[J] =
y
[
I
] +
h
* (
x
[
I
] * (
b
-
z
[
I
]) -
y
[
I
]);
85
z
[J] =
z
[
I
] +
h
* (
x
[
I
] *
y
[
I
] -
c
*
z
[
I
]);
86
87
I
= J;
88
}
89
90
double
get_x
()
91
{
92
return
.024 * (
x
[
I
] - .172);
93
}
94
95
double
get_y
()
96
{
97
return
.018 * (
y
[
I
] - .172);
98
}
99
100
double
get_z
()
101
{
102
return
.019 * (
z
[
I
] - 25.43);
103
}
104
};
105
106
}
/* namespace DSP */
107
108
#endif
/* _DSP_LORENZ_H_ */
sample_t
LADSPA_Data sample_t
Definition
basics.h:100
frandom
static float frandom()
Definition
basics.h:143
DSP::Lorenz::Lorenz
Lorenz()
Definition
Lorenz.h:41
DSP::Lorenz::c
double c
Definition
Lorenz.h:37
DSP::Lorenz::set_rate
void set_rate(double r)
Definition
Lorenz.h:50
DSP::Lorenz::I
int I
Definition
Lorenz.h:38
DSP::Lorenz::y
double y[2]
Definition
Lorenz.h:36
DSP::Lorenz::step
void step()
Definition
Lorenz.h:79
DSP::Lorenz::get_x
double get_x()
Definition
Lorenz.h:90
DSP::Lorenz::b
double b
Definition
Lorenz.h:37
DSP::Lorenz::get
sample_t get()
Definition
Lorenz.h:73
DSP::Lorenz::z
double z[2]
Definition
Lorenz.h:36
DSP::Lorenz::get_z
double get_z()
Definition
Lorenz.h:100
DSP::Lorenz::a
double a
Definition
Lorenz.h:37
DSP::Lorenz::x
double x[2]
Definition
Lorenz.h:36
DSP::Lorenz::h
double h
Definition
Lorenz.h:37
DSP::Lorenz::init
void init(double _h=.001, double seed=.0)
Definition
Lorenz.h:55
DSP::Lorenz::get_y
double get_y()
Definition
Lorenz.h:95
i
register unsigned i
Definition
inflate.c:1575
DSP
Definition
BiQuad.h:31
min
#define min(x, y)
Definition
os.h:74
max
#define max(x, y)
Definition
os.h:78
n
int n
Definition
crypt.c:458
r
int r
Definition
crypt.c:458
Generated on
for LMMS by
1.16.1