~ubuntu-branches/ubuntu/hardy/lmms/hardy

« back to all changes in this revision

Viewing changes to plugins/ladspa_effect/caps/dsp/Roessler.h

  • Committer: Bazaar Package Importer
  • Author(s): Tobias Doerffel
  • Date: 2007-09-17 15:00:24 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070917150024-mo0zk4ks81jawqii
Tags: 0.3.0-1ubuntu1
* Resynchronized with Debian (LP: #139759, LP: #90806, LP: #102639,
  LP: #113447, LP: #121172, LP: #124890)
* reverted changes from 0.2.1-1.1ubuntu1 as upstream merged/included them

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
        dsp/Roessler.h
 
3
        
 
4
        Copyright 2003-4 Tim Goetze <tim@quitte.de>
 
5
        
 
6
        http://quitte.de/dsp/
 
7
 
 
8
        Roessler 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_ROESSLER_H_
 
29
#define _DSP_ROESSLER_H_
 
30
 
 
31
namespace DSP {
 
32
 
 
33
class Roessler
 
34
{
 
35
        public:
 
36
                double x[2], y[2], z[2];        
 
37
                double h, a, b, c;
 
38
                int I;
 
39
 
 
40
        public:
 
41
                Roessler()
 
42
                        {
 
43
                                h = 0.001;
 
44
                                a = .2;
 
45
                                b = .2;
 
46
                                c = 5.7;
 
47
                        }
 
48
 
 
49
                /* rate is normalized (0 .. 1) */
 
50
                void set_rate (double r)
 
51
                        {
 
52
                                h = max (.000001, r * .096);
 
53
                        }
 
54
 
 
55
                void init (double _h = .001, double seed = .0)
 
56
                        {
 
57
                                h = _h;
 
58
 
 
59
                                I = 0;
 
60
 
 
61
                                x[0] = .0001 + .0001 * seed;
 
62
                                y[0] = .0001;
 
63
                                z[0] = .0001;
 
64
 
 
65
                                for (int i = 0; i < 5000; ++i)
 
66
                                        get();
 
67
                        }
 
68
 
 
69
                d_sample get()
 
70
                        {
 
71
                                int J = I ^ 1;
 
72
 
 
73
                                x[J] = x[I] + h * (- y[I] - z[I]);
 
74
                                y[J] = y[I] + h * (x[I] + a * y[I]);
 
75
                                z[J] = z[I] + h * (b + z[I] * (x[I] - c));
 
76
 
 
77
                                I = J;
 
78
 
 
79
                                return x[I] * .01725 + z[I] * .015;
 
80
                        }
 
81
 
 
82
                double get_x()
 
83
                        {
 
84
                                return x[I];
 
85
                        }
 
86
 
 
87
                double get_y()
 
88
                        {
 
89
                                return y[I];
 
90
                        }
 
91
 
 
92
                double get_z()
 
93
                        {
 
94
                                return z[I];
 
95
                        }
 
96
};
 
97
 
 
98
} /* namespace DSP */
 
99
 
 
100
#endif /* _DSP_ROESSLER_H_ */