aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Blechmann <timblech@users.sourceforge.net>2004-12-21 09:22:10 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:11:57 +0200
commit5233c01a26329306c9f1d08c1a39733aee2cc518 (patch)
tree27ea384742c0ebeed4439ab0874ea1af79f1bccf
parentcde59e47632b062410739af9064d906be182e589 (diff)
This commit was generated by cvs2svn to compensate for changes in r2423,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/tb/; revision=2424
-rw-r--r--chaos/AUTHORS3
-rw-r--r--chaos/ChangeLog0
-rw-r--r--chaos/Makefile.am2
-rw-r--r--chaos/NEWS0
-rw-r--r--chaos/README0
-rwxr-xr-xchaos/bootstrap.sh5
-rw-r--r--chaos/configure.ac142
-rw-r--r--chaos/src/Makefile.am44
-rw-r--r--chaos/src/bernoulli_map.hpp75
-rw-r--r--chaos/src/bungalow_tent_map.hpp121
-rw-r--r--chaos/src/chaos.hpp35
-rw-r--r--chaos/src/chaos_base.cpp21
-rw-r--r--chaos/src/chaos_base.hpp55
-rw-r--r--chaos/src/chaos_dsp.cpp193
-rw-r--r--chaos/src/chaos_dsp.hpp61
-rw-r--r--chaos/src/circle_map.hpp106
-rw-r--r--chaos/src/gauss_map.hpp77
-rw-r--r--chaos/src/henon_map.hpp121
-rw-r--r--chaos/src/ikeda_laser_map.hpp153
-rw-r--r--chaos/src/logistic_map.hpp91
-rw-r--r--chaos/src/lorenz.hpp150
-rw-r--r--chaos/src/lozi_map.hpp126
-rw-r--r--chaos/src/main.cpp29
-rw-r--r--chaos/src/map_base.hpp40
-rw-r--r--chaos/src/ode_base.cpp90
-rw-r--r--chaos/src/ode_base.hpp83
-rw-r--r--chaos/src/sine_map.hpp72
-rw-r--r--chaos/src/standard_map.hpp130
-rw-r--r--chaos/src/tent_map.hpp63
29 files changed, 2088 insertions, 0 deletions
diff --git a/chaos/AUTHORS b/chaos/AUTHORS
new file mode 100644
index 0000000..022e6c0
--- /dev/null
+++ b/chaos/AUTHORS
@@ -0,0 +1,3 @@
+Tim Blechmann <TimBlechmann@gmx.net>
+Mike McGonagle <mjmogo@gmail.com>
+B. Bogart <ben@ekran.org> \ No newline at end of file
diff --git a/chaos/ChangeLog b/chaos/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/chaos/ChangeLog
diff --git a/chaos/Makefile.am b/chaos/Makefile.am
new file mode 100644
index 0000000..5db2166
--- /dev/null
+++ b/chaos/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS = src
+EXTRA_DIST = src \ No newline at end of file
diff --git a/chaos/NEWS b/chaos/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/chaos/NEWS
diff --git a/chaos/README b/chaos/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/chaos/README
diff --git a/chaos/bootstrap.sh b/chaos/bootstrap.sh
new file mode 100755
index 0000000..695f2bd
--- /dev/null
+++ b/chaos/bootstrap.sh
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+aclocal \
+&& automake-1.8 --gnu --add-missing \
+&& autoconf \ No newline at end of file
diff --git a/chaos/configure.ac b/chaos/configure.ac
new file mode 100644
index 0000000..c228f01
--- /dev/null
+++ b/chaos/configure.ac
@@ -0,0 +1,142 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(chaos~, 0.01, TimBlechmann@gmx.de, chaos~)
+AM_INIT_AUTOMAKE
+
+dnl Checks for programs.
+AC_PROG_MAKE_SET
+AC_PROG_CC
+AC_PROG_CXX
+
+dnl Checks for libraries.
+AC_CHECK_LIB(m, sin)
+
+dnl Checks for header files.
+AC_HEADER_STDC
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_C_INLINE
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+
+
+dnl Checks for command line arguments
+AC_ARG_WITH(flextdir,
+ [ --with-flextdir path to flext headers],
+ [
+ flextdir=$withval
+ INCLUDEDIR="-I$withval $INCLUDEDIR"
+ ],
+ [echo "path to flext headers required" && exit 1])
+
+AC_CHECK_FILE("$flextdir/flext.h",,
+ [echo "$flextdir/flext.h not found" && exit 1])
+
+
+AC_ARG_ENABLE(system,
+ [ --enable-system system (default: pd)],
+ [
+ if test "enableval" == "max"; then
+ AC_DEFINE(FLEXT_SYS,1)
+ else
+ AC_DEFINE(FLEXT_SYS,2)
+ fi
+ system = $enabeval
+ ],
+ AC_DEFINE(FLEXT_SYS,2)
+ )
+
+
+AC_ARG_WITH(sysdir,
+ [ --with-sysdir path pd / max installation],
+ SYSDIR=$withval,
+ [echo "path to pd / max installation required" && exit 1])
+
+
+AC_ARG_ENABLE(static,
+ [ --enable-static static linking with libflext],
+ LDFLAGS="-Bstatic $LDFLAGS"
+ ,
+ [
+ AC_DEFINE(FLEXT_SHARED)
+ AC_DEFINE(FLEXT_THREADS)
+ LDFLAGS="-Bdynamic $LDFLAGS"
+ ]
+ )
+
+AC_ARG_ENABLE(debug,
+ [ --enable-debug link with libflext_d library for debugging],
+ [
+ LDFLAGS="-lflext_d $LDFLAGS"
+ CXXFLAGS="-g"
+ ],
+ [
+ LDFLAGS="-lflext $LDFLAGS"
+ CXXFLAGS="-O3"
+ ])
+
+dnl mtune will break gcc 3.3.x
+AC_ARG_ENABLE(optimize, [ --enable-optimize enables optimized builds for: pentium4, pentium3, G4, G5],
+ [
+ case $enableval in
+ pentium3 | pentium3m)
+ OPT_FLAGS = "-mtune=$enableval -march=$enableval -mmmx -msse -mfpmath=sse";;
+ pentium2 | athlon | pentium-mmx)
+ OPT_FLAGS="-mtune=$enableval -march=$enableval -mmmx";;
+ pentium)
+ OPT_FLAGS="-mtune=$enableval -march=$enableval";;
+ pentium4 | pentium4m | pentium-m | prescott | nocona | athlon-xp | athlon-mp | athlon64 | opteron)
+ OPT_FLAGS="-mtune=$enableval -march=$enableval -mmmx -msse -msse2 -mfpmath=sse";;
+ G5 | G4)
+ OPT_FLAGS="-mtune=$enableval -march=$enableval -maltivec -faltivec -malign-natural";;
+ G3)
+ OPT_FLAGS="-mtune=$enableval -march=$enableval -malign-natural";;
+ *)
+ ;;
+ esac
+ ])
+
+dnl select build
+if test `uname -s` == "Linux"; then
+ dnl no max/msp for linux
+ OBJEXT=o
+ EXTENSION=pd_linux
+fi
+
+if test `uname -s` == "Darwin"; then
+ dnl just a guess
+ if test "$system" = "max"; then
+ echo "build system doesn't support max, yet" && exit 1;
+ else
+ LDFLAGS="-bundle -bundle_loader $LDFLAGS"
+ FRAMEWORKS=
+ EXTENSION=pd_darwin
+ LIBS="gcc $LIBS"
+ fi
+ OBJEXT=o
+fi
+
+if test `uname -s` == "Cygwin"; then
+ dnl just a guess
+ if test "$system" = "max"; then
+ echo "build system doesn't support max, yet" && exit 1;
+ else
+ EXTENSION=dll
+ LIBS="gcc $LIBS bin/pd bin/pthreadVC.dll"
+ LDFLAGS="-L$SYSDIR"
+ fi
+fi
+
+
+AC_SUBST(EXTENSION)
+AC_SUBST(INCLUDEDIR)
+AC_SUBST(CXXFLAGS)
+AC_SUBST(OPT_FLAGS)
+AC_SUBST(LDFLAGS)
+AC_SUBST(DEFS)
+AC_SUBST(LIBS)
+AC_SUBST(OBJEXT)
+AC_SUBST(FRAMEWORKS)
+AC_SUBST(SYSDIR)
+AC_OUTPUT([Makefile
+ src/Makefile])
diff --git a/chaos/src/Makefile.am b/chaos/src/Makefile.am
new file mode 100644
index 0000000..9f99c3f
--- /dev/null
+++ b/chaos/src/Makefile.am
@@ -0,0 +1,44 @@
+NAME = chaos~
+
+BUILT_SOURCES = main.cpp ode_base.cpp chaos_base.cpp chaos_dsp.cpp
+
+
+CXXFLAGS = @CXXFLAGS@ \
+ @OPT_FLAGS@ \
+ @INCLUDEDIR@ \
+ $(DEFS)
+
+LDFLAGS = @LDFLAGS@ \
+ $(patsubst %,-framework %,$(FRAMEWORKS))
+
+LIBS = @LIBS@
+
+FRAMEWORKS = @FRAMEWORKS@
+
+TARGET =$(NAME).@EXTENSION@
+
+OBJECTS = $(patsubst %.cpp,./%.@OBJEXT@,$(BUILT_SOURCES))
+
+SYSDIR = @SYSDIR@
+
+
+# ----------------------------- targets --------------------------------
+
+
+all-local: $(OBJECTS)
+ $(CXX) $(LDFLAGS) -shared ./*.@OBJEXT@ $(LIBS) -o ../$(TARGET)
+ strip --strip-unneeded ../$(TARGET)
+
+./%.@OBJEXT@ : %.cpp
+ $(CXX) -c $(CXXFLAGS) $< -o $@
+
+dist-hook:
+ rm -f ./*~
+ rm -f ./*.@OBJEXT@
+
+clean-local:
+ rm -f ../$(TARGET)
+ rm -f ../obj/*
+
+install-exec-local:
+ install ../$(TARGET) $(SYSDIR)extra \ No newline at end of file
diff --git a/chaos/src/bernoulli_map.hpp b/chaos/src/bernoulli_map.hpp
new file mode 100644
index 0000000..b006c92
--- /dev/null
+++ b/chaos/src/bernoulli_map.hpp
@@ -0,0 +1,75 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+
+// bernoulli map: x[n+1] = 2 * x[n] mod 1
+// 0 <= x[n] < 1
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class bernoulli:
+ protected map_base
+{
+public:
+ bernoulli()
+ {
+ m_num_eq = 1:
+ m_data = new data_t[1];
+ set_x(0.5f);
+ }
+
+ ~bernoulli()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t x = m_data[0];
+
+ if (x < 0.5f)
+ m_data[0] = 2.f * x;
+ else
+ m_data[0] = 2.f * x - 1.f;
+ }
+
+ void set_x(t_float f)
+ {
+ if ( (f >= 0) && (f < 1))
+ m_data[0] = (data_t) f;
+ else
+ post("value for x %f out of range", f);
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+};
+
+
+#define BERNOULLI_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+
+#define BERNOULLI_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+
diff --git a/chaos/src/bungalow_tent_map.hpp b/chaos/src/bungalow_tent_map.hpp
new file mode 100644
index 0000000..6708eae
--- /dev/null
+++ b/chaos/src/bungalow_tent_map.hpp
@@ -0,0 +1,121 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+
+// bungalow_tent map: x[n+1] = 1 + 2 * r + 2 * (r + 1) * x[n]
+// (for -1 <= x[n] < -0.5f)
+// 1 + 2 * (1 - r) * (x[n])
+// (for -0.5 <= x[n] < 0)
+// 1 + 2 * (r - 1) * (x[n])
+// (for 0 <= x[n] < 0.5)
+// 1 + 2 * r - 2 * (r + 1) * (x[n])
+// (for 0.5 <= x[n] < 1)
+// -1 <= x[n] < 1
+// -0.5 <= r < 1
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class bungalow_tent:
+ protected map_base
+{
+public:
+ bungalow_tent()
+ : m_r(0.5)
+ {
+ m_num_eq = 1;
+ m_data = new data_t[1];
+ set_x(0.5f);
+ }
+
+ ~bungalow_tent()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t x = m_data[0];
+ data_t r = m_r;
+
+ if ( x < - 0.5)
+ {
+ m_data[0] = 1 + 2 * r + 2 * (r + 1) * x;
+ return;
+ }
+ if ( x < 0)
+ {
+ m_data[0] = 1 + 2 * (1 - r) * x;
+ return;
+ }
+ if ( x < 0.5)
+ {
+ m_data[0] = 1 + 2 * (r - 1) * x;
+ return;
+ }
+ else
+ {
+ m_data[0] = 1 + 2 * r - 2 * (r + 1) * x;
+ return;
+ }
+
+ }
+
+ void set_x(t_float f)
+ {
+ if ( (f > -1) && (f < 1))
+ m_data[0] = (data_t) f;
+ else
+ post("value for x %f out of range", f);
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+
+ void set_r(t_float f)
+ {
+ if ( (f > -.5) && (f < 1))
+ m_data[0] = (data_t) f;
+ else
+ post("value for r %f out of range", f);
+ }
+
+ t_float get_r()
+ {
+ return (t_float)m_data[0];
+ }
+
+private:
+ data_t m_r;
+
+};
+
+
+#define BUNGALOW_TENT_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \
+
+
+#define BUNGALOW_TENT_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
diff --git a/chaos/src/chaos.hpp b/chaos/src/chaos.hpp
new file mode 100644
index 0000000..d65ba5c
--- /dev/null
+++ b/chaos/src/chaos.hpp
@@ -0,0 +1,35 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#ifndef __chaos_hpp
+
+#define FLEXT_ATTRIBUTES 1
+
+#include "flext.h"
+
+/* internal we can work with a higher precision than pd */
+#ifdef DOUBLE_PRECISION
+typedef double data_t;
+#else
+typedef t_float data_t;
+#endif
+
+#define __chaos_hpp
+#endif /* __chaos_hpp */
diff --git a/chaos/src/chaos_base.cpp b/chaos/src/chaos_base.cpp
new file mode 100644
index 0000000..9f8cad3
--- /dev/null
+++ b/chaos/src/chaos_base.cpp
@@ -0,0 +1,21 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+
diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp
new file mode 100644
index 0000000..231580b
--- /dev/null
+++ b/chaos/src/chaos_base.hpp
@@ -0,0 +1,55 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#ifndef __chaos_base_hpp
+
+#include "chaos.hpp"
+
+class chaos_base
+{
+
+public:
+ t_sample get_data(unsigned int i)
+ {
+ return (t_sample)m_data[i]; /* this is not save, but fast */
+ }
+
+ int get_num_eq()
+ {
+ return m_num_eq;
+ }
+
+ /* prototype for system function */
+ virtual void m_step();
+
+ data_t * m_data; // state of the system
+
+protected:
+ int m_num_eq; // number of equations of the system
+};
+
+#define CHAOS_CALLBACKS \
+FLEXT_CALLGET_F(m_system->get_num_eq);
+
+#define CHAOS_ATTRIBUTES \
+FLEXT_ADDATTR_GET("dimension",m_system->get_num_eq);
+
+#define __chaos_base_hpp
+#endif /* __chaos_base_hpp */
diff --git a/chaos/src/chaos_dsp.cpp b/chaos/src/chaos_dsp.cpp
new file mode 100644
index 0000000..790be06
--- /dev/null
+++ b/chaos/src/chaos_dsp.cpp
@@ -0,0 +1,193 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+
+#include "chaos_dsp.hpp"
+
+void chaos_dsp::m_signal(int n, t_sample *const *insigs,
+ t_sample *const *outsigs)
+{
+ if (m_freq >= m_sr * 0.5)
+ {
+ m_signal_(n, insigs, outsigs);
+ return;
+ }
+
+ switch (m_method)
+ {
+ case 0:
+ m_signal_n(n, insigs, outsigs);
+ return;
+ case 1:
+ m_signal_l(n, insigs, outsigs);
+ return;
+ case 2:
+ m_signal_c(n, insigs, outsigs);
+ return;
+ }
+}
+
+void chaos_dsp::m_signal_(int n, t_sample *const *insigs,
+ t_sample *const *outsigs)
+{
+ int outlets = m_system->get_num_eq();
+
+ for (int i = 0; i!=n; ++i)
+ {
+ m_system->m_step();
+ for (int j = 0; j != outlets; ++j)
+ {
+ outsigs[j][i] = m_system->get_data(j);
+ }
+ }
+
+}
+
+void chaos_dsp::m_signal_n(int n, t_sample *const *insigs,
+ t_sample *const *outsigs)
+{
+ int outlets = m_system->get_num_eq();
+
+ int phase = m_phase;
+
+ int i = 0;
+
+ while (n)
+ {
+ if (m_phase == 0)
+ {
+ m_system->m_step();
+ phase = int (m_sr / m_freq);
+ }
+
+ int next = (phase < n) ? phase : n;
+ n -= next;
+ phase -=next;
+
+ while (next--)
+ {
+ for (int j = 0; j != outlets; ++j)
+ {
+ outsigs[j][i] = m_system->get_data(j);
+ }
+ ++i;
+ }
+ }
+ m_phase = phase;
+}
+
+
+/* linear and cubic interpolation adapted from supercollider by James McCartney */
+
+void chaos_dsp::m_signal_l(int n, t_sample *const *insigs,
+ t_sample *const *outsigs)
+{
+ int outlets = m_system->get_num_eq();
+
+ int phase = m_phase;
+
+ int i = 0;
+
+ while (n)
+ {
+ if (m_phase == 0)
+ {
+ m_system->m_step();
+ phase = int (m_sr / m_freq);
+
+ for (int j = 0; j != outlets; ++j)
+ m_slopes[j] = (m_system->get_data(j) - m_values[j]) / phase;
+ }
+
+ int next = (phase < n) ? phase : n;
+ n -= next;
+ phase -=next;
+
+ while (next--)
+ {
+ for (int j = 0; j != outlets; ++j)
+ {
+ outsigs[j][i] = m_values[j];
+ m_values[j]+=m_slopes[j];
+ }
+ ++i;
+ }
+ }
+ m_phase = phase;
+}
+
+
+void chaos_dsp::m_signal_c(int n, t_sample *const *insigs,
+ t_sample *const *outsigs)
+{
+ int outlets = m_system->get_num_eq();
+
+ int phase = m_phase;
+
+ int i = 0;
+
+ while (n)
+ {
+ if (m_phase == 0)
+ {
+ m_system->m_step();
+ phase = int (m_sr / m_freq);
+ phase = (phase > 2) ? phase : 2;
+
+ for (int j = 0; j != outlets; ++j)
+ {
+ t_sample value = m_nextvalues[j];
+ m_nextvalues[j]= m_system->get_data(j);
+
+ m_values[j] = m_nextmidpts[j];
+ m_nextmidpts[j] = (m_values[j] + value) * 0.5f;
+
+ float fseglen = (float)phase;
+ m_curves[j] = 2.f * (m_nextmidpts[j] - m_values[j] - fseglen * m_slopes[j])
+ / (fseglen * fseglen + fseglen);
+
+ m_values[j] = value;
+ }
+ }
+
+ int next = (phase < n) ? phase : n;
+ n -= next;
+ phase -=next;
+
+ while (next--)
+ {
+ for (int j = 0; j != outlets; ++j)
+ {
+ outsigs[j][i] = m_values[j];
+ m_slopes[j]+=m_curves[j];
+ m_values[j]+=m_slopes[j];
+ }
+ ++i;
+ }
+ }
+ m_phase = phase;
+}
+
+
+void chaos_dsp::m_dsp(int n, t_sample *const *insigs,
+ t_sample *const *outsigs)
+{
+ m_sr = Samplerate();
+}
diff --git a/chaos/src/chaos_dsp.hpp b/chaos/src/chaos_dsp.hpp
new file mode 100644
index 0000000..12efaa8
--- /dev/null
+++ b/chaos/src/chaos_dsp.hpp
@@ -0,0 +1,61 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "chaos_base.hpp"
+
+class chaos_dsp
+ : public flext_dsp
+{
+ FLEXT_HEADER(chaos_dsp, flext_dsp);
+
+protected:
+
+ /* signal functions: */
+ /* for frequency = sr/2 */
+ void m_signal_(int n, t_sample *const *insigs,t_sample *const *outsigs);
+ /* sample & hold */
+ void m_signal_n(int n, t_sample *const *insigs,t_sample *const *outsigs);
+ /* linear interpolation */
+ void m_signal_l(int n, t_sample *const *insigs,t_sample *const *outsigs);
+ /* cubic interpolatio */
+ void m_signal_c(int n, t_sample *const *insigs,t_sample *const *outsigs);
+
+ virtual void m_signal(int n, t_sample *const *insigs,t_sample *const *outsigs);
+ virtual void m_dsp(int n, t_sample *const *insigs,t_sample *const *outsigs);
+
+
+ /* local data for system, output and interpolation */
+ chaos_base * m_system; /* the system */
+
+ t_sample * m_values; /* actual value */
+ t_sample * m_slopes; /* actual slope for cubic interpolation */
+
+ t_sample * m_nextvalues;
+ t_sample * m_nextmidpts;
+ t_sample * m_curves;
+
+ /* local data for signal functions */
+ float m_freq; /* frequency of oscillations */
+ int m_phase; /* phase counter */
+ float m_sr; /* sample rate */
+
+ char m_method; /* interpolation method */
+
+};
diff --git a/chaos/src/circle_map.hpp b/chaos/src/circle_map.hpp
new file mode 100644
index 0000000..f1ef406
--- /dev/null
+++ b/chaos/src/circle_map.hpp
@@ -0,0 +1,106 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+
+// circle_map map: x[n+1] = x[n] * omega - r / (2*pi) * sin (2 * pi * x [n])
+//
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class circle_map:
+ protected map_base
+{
+public:
+ circle_map()
+ : m_omega(0.4), m_r(1)
+ {
+ m_num_eq = 1;
+ m_data = new data_t[1];
+ set_x(0.5);
+ }
+
+ ~circle_map()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t x = m_data[0];
+ data_t omega = m_omega;
+ data_t r = m_r;
+
+ m_data[0] = x + omega - r / (2.f * M_PI) * sin (2.f * M_PI * x);
+ }
+
+ void set_x(t_float f)
+ {
+ m_data[0] = (data_t) f;
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+
+ void set_r(t_float f)
+ {
+ m_r = (data_t) f;
+ }
+
+
+ t_float get_r()
+ {
+ return (t_float)m_r;
+ }
+
+
+ void set_omega (t_float f)
+ {
+ m_omega = (data_t) f;
+ }
+
+ t_float get_omega()
+ {
+ return (t_float)m_omega;
+ }
+
+
+private:
+ data_t m_omega;
+ data_t m_r;
+};
+
+#define CIRCLE_MAP_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_ATTRVAR_F(m_system->m_omega); \
+FLEXT_ATTRVAR_F(m_system->m_r); \
+FLEXT_CALLVAR_F(m_system->get_omega, m_system->set_omega); \
+FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+
+#define CIRCLE_MAP_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR1("omega",m_system->m_omega); \
+FLEXT_ADDATTR_VAR1("r",m_system->m_r); \
+FLEXT_ADDATTR_VAR("omega",m_system->get_omega, m_system->set_omega); \
+FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+
diff --git a/chaos/src/gauss_map.hpp b/chaos/src/gauss_map.hpp
new file mode 100644
index 0000000..e2316ec
--- /dev/null
+++ b/chaos/src/gauss_map.hpp
@@ -0,0 +1,77 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+
+// gauss map: x[n+1] = 0 (for x[n] = 0)
+// fmod(1 / x[n]) (else)
+// 0 <= x[n] < 1
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class gauss:
+ protected map_base
+{
+public:
+ gauss()
+ {
+ m_num_eq = 1;
+ m_data = new data_t[1];
+ set_x(0.5);
+ }
+
+ ~gauss()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t data = m_data[0];
+
+ if (data == 0)
+ m_data[0] = 0;
+ else
+ m_data[0] = fmod(1.f / data);
+ }
+
+ void set_x(t_float f)
+ {
+ if ( (f >= 0) && (f < 1))
+ m_data[0] = (data_t) f;
+ else
+ post("value for x %f out of range", f);
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+
+};
+
+#define GAUSS_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+
+#define GAUSS_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+
+
diff --git a/chaos/src/henon_map.hpp b/chaos/src/henon_map.hpp
new file mode 100644
index 0000000..d29e8a7
--- /dev/null
+++ b/chaos/src/henon_map.hpp
@@ -0,0 +1,121 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+
+// henon map: x[n+1] = y[n] + 1 - a * x[n] * x[n]
+// y[n+1] = b * x[n]
+// b != 0
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class henon:
+ protected map_base
+{
+public:
+ henon()
+ : m_a(1.4), m_b(0.3)
+ {
+ m_num_eq = 2;
+ m_data = new data_t[1];
+ set_x(0.f);
+ set_y(0.f);
+ }
+
+ ~henon()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t x = m_data[0];
+ data_t y = m_data[1];
+
+ m_data[0] = 1 + y - m_a * x * x;
+ m_data[1] = m_b * x;
+
+ }
+
+
+ void set_x(t_float f)
+ {
+ m_data[0] = (data_t) f;
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+
+
+ void set_y(t_float f)
+ {
+ m_data[1] = (data_t) f;
+ }
+
+ t_float get_y()
+ {
+ return (t_float)m_data[1];
+ }
+
+
+ void set_a(t_float f)
+ {
+ m_a = (data_t) f;
+ }
+
+ t_float get_a()
+ {
+ return (t_float)m_a;
+ }
+
+
+ void set_b(t_float f)
+ {
+ if (f != 0)
+ m_b = (data_t) f;
+ else
+ post("value for b %f out of range", f);
+ }
+
+ t_float get_b()
+ {
+ return (t_float)m_b;
+ }
+
+private:
+ data_t m_a;
+ data_t m_b;
+};
+
+
+#define HENON_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_a, m_system->set_a); \
+FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \
+FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y);
+
+#define HENON_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("a",m_system->get_a, m_system->set_a); \
+FLEXT_ADDATTR_VAR("b",m_system->get_b, m_system->set_b); \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \
+FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y);
diff --git a/chaos/src/ikeda_laser_map.hpp b/chaos/src/ikeda_laser_map.hpp
new file mode 100644
index 0000000..39d75c4
--- /dev/null
+++ b/chaos/src/ikeda_laser_map.hpp
@@ -0,0 +1,153 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+#include <cmath>
+
+// ikeda laser map: z[n+1] = roh + c2 * z[n] *
+// exp (j * (c1 - c3 / (1 + abs(z) * abs(z))))
+// z is complex
+//
+// equal: x[n+1] = roh + c2 * (x[n] * cos(tau) - y[n] * sin (tau))
+// y[n+1] = c2 * (x[n] * sin(tau) + y[n] * cos(tau))
+// tau = c1 - (c2 / (1 + x*x + y*y))
+//
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class ikeda:
+ protected map_base
+{
+public:
+ ikeda()
+ : m_c1(0.4), m_c2(0.9), m_c3(9), m_roh(0.85)
+ {
+ m_num_eq = 2;
+ m_data = new data_t[2];
+ set_x(0.5);
+ set_y(0.5);
+ }
+
+ ~ikeda()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t x = m_data[0];
+ data_t y = m_data[1];
+
+ data_t tau = m_c1 - m_c3 / (1 + x*x + y*y);
+ data_t cos_tau = cos(tau);
+ data_t sin_tau = sin(tau);
+
+ m_data[0] = m_roh + m_c2 * (x * cos_tau - y * sin_tau);
+ m_data[1] = m_c2 * (x * sin_tau + y * cos_tau);
+ }
+
+
+ void set_x(t_float f)
+ {
+ m_data[0] = (data_t) f;
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+
+ void set_y(t_float f)
+ {
+ m_data[1] = (data_t) f;
+ }
+
+ t_float get_y()
+ {
+ return (t_float)m_data[1];
+ }
+
+
+ void set_c1(t_float f)
+ {
+ m_c1 = (data_t) f;
+ }
+
+ t_float get_c1()
+ {
+ return (t_float)m_c1;
+ }
+
+
+ void set_c2(t_float f)
+ {
+ m_c2[1] = (data_t) f;
+ }
+
+ t_float get_c2()
+ {
+ return (t_float)m_c2;
+ }
+
+
+ void set_c3(t_float f)
+ {
+ m_c3 = (data_t) f;
+ }
+
+ t_float get_c3()
+ {
+ return (t_float)m_c3;
+ }
+
+
+ void set_roh(t_float f)
+ {
+ m_roh = (data_t) f;
+ }
+
+ t_float get_roh()
+ {
+ return (t_float)m_roh;
+ }
+
+
+private:
+ data_t m_c1, m_c2, m_c3, m_roh;
+};
+
+
+#define IKEDA_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_c1, m_system->set_c1); \
+FLEXT_CALLVAR_F(m_system->get_c2, m_system->set_c2); \
+FLEXT_CALLVAR_F(m_system->get_c3, m_system->set_c3); \
+FLEXT_CALLVAR_F(m_system->get_roh, m_system->set_roh); \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \
+FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y); \
+
+
+#define IKEDA_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("c1",m_system->get_c1, m_system->set_c1); \
+FLEXT_ADDATTR_VAR("c2",m_system->get_c2, m_system->set_c2); \
+FLEXT_ADDATTR_VAR("c3",m_system->get_c3, m_system->set_c3); \
+FLEXT_ADDATTR_VAR("roh",m_system->get_roh, m_system->set_roh); \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \
+FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y);
diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp
new file mode 100644
index 0000000..c443f45
--- /dev/null
+++ b/chaos/src/logistic_map.hpp
@@ -0,0 +1,91 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+
+// logistic map: x[n+1] = alpha * x[n] * (1 - x[n])
+// 0 <= x[n] < 1
+// 0 <= alpha <= 4
+
+class logistic:
+ protected map_base
+{
+public:
+ logistic()
+ : m_alpha(3.8)
+ {
+ m_num_eq = 1;
+ m_data = new data_t[1];
+ set_x(0.5f);
+ }
+
+ ~logistic()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t data = m_data[0];
+ data_t alpha = m_alpha;
+ m_data[0] = alpha * data * (1.f - data);
+ }
+
+ void set_alpha(t_float f)
+ {
+ if ( (f > 0) && (f < 4))
+ m_alpha = (data_t) f;
+ else
+ post("value for alpha %f out of range", f);
+ }
+
+ t_float get_alpha()
+ {
+ return (t_float)m_alpha;
+ }
+
+ void set_x(t_float f)
+ {
+ if ( (f > 0) && (f < 1))
+ m_data[0] = (data_t) f;
+ else
+ post("value for x %f out of range", f);
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+
+private:
+ data_t m_alpha;
+};
+
+#define LOGISTIC_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_alpha, m_system->set_alpha); \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+
+#define LOGISTIC_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("alpha",m_system->get_alpha, m_system->set_alpha); \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+
+
diff --git a/chaos/src/lorenz.hpp b/chaos/src/lorenz.hpp
new file mode 100644
index 0000000..70dad4d
--- /dev/null
+++ b/chaos/src/lorenz.hpp
@@ -0,0 +1,150 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "ode_base.hpp"
+
+// lorenz model: dx1/dt = sigma * (x2 - x1)
+// dx2/dt = - x1 * x3 + r * x1 - x2
+// dx3/dt = x1 * x2 - b * x3
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class lorenz
+ : protected ode_base
+{
+public:
+ logistic()
+ : m_sigma(16), m_b(4), m_r(40)
+ {
+ m_num_eq = 3;
+ m_data = new data_t[3];
+ set_x1(0.8f);
+ set_x2(0.8f);
+ set_x3(0.8f);
+ set_method(0);
+ }
+
+ ~logistic()
+ {
+ delete m_data;
+ }
+
+ virtual void m_system(data_t* deriv, data_t* data)
+ {
+ data_t x1 = data[0], x2 = data[1], x3 = data[2];
+
+ deriv[0] = m_sigma * (x2 - x1);
+ deriv[1] = - x1 * x3 + m_r * x1 - x2;
+ deriv[3] = x1 * x2 - m_b * x3;
+ }
+
+ void set_x1(t_float f)
+ {
+ m_data[0] = (data_t) f;
+ }
+
+ t_float get_x1()
+ {
+ return (t_float)m_data[0];
+ }
+
+ void set_x2(t_float f)
+ {
+ m_data[1] = (data_t) f;
+ }
+
+ t_float get_x2()
+ {
+ return (t_float)m_data[1];
+ }
+
+ void set_x3(t_float f)
+ {
+ m_data[2] = (data_t) f;
+ }
+
+ t_float get_x3()
+ {
+ return (t_float)m_data[2];
+ }
+
+
+ void set_sigma(t_float f)
+ {
+ if (f > 0)
+ m_sigma = (data_t) f;
+ else
+ post("value for sigma %f out of range", f);
+ }
+
+ t_float get_sigma()
+ {
+ return (t_float)m_sigma;
+ }
+
+
+ void set_r(t_float f)
+ {
+ if (f > 0)
+ m_r = (data_t) f;
+ else
+ post("value for r %f out of range", f);
+ }
+
+ t_float get_r()
+ {
+ return (t_float)m_r;
+ }
+
+ void set_b(t_float f)
+ {
+ if (f > 0)
+ m_b = (data_t) f;
+ else
+ post("value for b %f out of range", f);
+ }
+
+ t_float get_b()
+ {
+ return (t_float)m_b;
+ }
+
+
+private:
+ data_t m_sigma, m_r, m_b;
+};
+
+
+#define LORENZ_CALLBACKS \
+ODE_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_sigma, m_system->set_sigma); \
+FLEXT_CALLVAR_F(m_system->get_r, m_system->set_r); \
+FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \
+FLEXT_CALLVAR_F(m_system->get_x1, m_system->set_x1); \
+FLEXT_CALLVAR_F(m_system->get_x2, m_system->set_x2); \
+FLEXT_CALLVAR_F(m_system->get_x3, m_system->set_x3);
+
+#define LORENZ_ATTRIBUTES \
+ODE_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("sigma",m_system->get_sigma, m_system->set_sigma); \
+FLEXT_ADDATTR_VAR("r",m_system->get_r, m_system->set_r); \
+FLEXT_ADDATTR_VAR("b",m_system->get_g, m_system->set_g); \
+FLEXT_ADDATTR_VAR("x1",m_system->get_x1, m_system->set_x1); \
+FLEXT_ADDATTR_VAR("x2",m_system->get_x2, m_system->set_x2); \
+FLEXT_ADDATTR_VAR("x3",m_system->get_x3, m_system->set_x3);
diff --git a/chaos/src/lozi_map.hpp b/chaos/src/lozi_map.hpp
new file mode 100644
index 0000000..50192c4
--- /dev/null
+++ b/chaos/src/lozi_map.hpp
@@ -0,0 +1,126 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+
+// lozi map: x[n+1] = y[n] + 1 - a * abs(x[n])
+// y[n+1] = b * x[n]
+// b != 0
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class lozi:
+ protected map_base
+{
+public:
+ lozi()
+ : m_a(1.4), m_b(0.3)
+ {
+ m_num_eq = 2;
+ m_data = new data_t[1];
+ set_x(0.5);
+ set_y(0.5);
+ }
+
+ ~lozi()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t x = m_data[0];
+ data_t y = m_data[1];
+
+ if (x > 0)
+ m_data[0] = 1 + y - m_a * x;
+ else
+ m_data[0] = 1 + y + m_a * x;
+
+ m_data[1] = m_b * x;
+
+ }
+
+
+ void set_x(t_float f)
+ {
+ m_data[0] = (data_t) f;
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+
+
+ void set_y(t_float f)
+ {
+ m_data[1] = (data_t) f;
+ }
+
+ t_float get_y()
+ {
+ return (t_float)m_data[1];
+ }
+
+
+ void set_a(t_float f)
+ {
+ m_a = (data_t) f;
+ }
+
+ t_float get_a()
+ {
+ return (t_float)m_a;
+ }
+
+
+ void set_b(t_float f)
+ {
+ if (f != 0)
+ m_b = (data_t) f;
+ else
+ post("value for b %f out of range", f);
+ }
+
+ t_float get_b()
+ {
+ return (t_float)m_b;
+ }
+
+
+private:
+ data_t m_a;
+ data_t m_b;
+};
+
+
+#define LOZI_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_a, m_system->set_a); \
+FLEXT_CALLVAR_F(m_system->get_b, m_system->set_b); \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x); \
+FLEXT_CALLVAR_F(m_system->get_y, m_system->set_y);
+
+#define LOZI_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("a",m_system->get_a, m_system->set_a); \
+FLEXT_ADDATTR_VAR("b",m_system->get_b, m_system->set_b); \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x); \
+FLEXT_ADDATTR_VAR("y",m_system->get_y, m_system->set_y);
diff --git a/chaos/src/main.cpp b/chaos/src/main.cpp
new file mode 100644
index 0000000..df25010
--- /dev/null
+++ b/chaos/src/main.cpp
@@ -0,0 +1,29 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "chaos.hpp"
+#include "logistic_map.hpp"
+
+void chaos_library_setup()
+{
+ post("chaos~ version"PACKAGE_VERSION"\n");
+}
+
+FLEXT_LIB_SETUP(chaos, chaos_library_setup);
diff --git a/chaos/src/map_base.hpp b/chaos/src/map_base.hpp
new file mode 100644
index 0000000..35c8460
--- /dev/null
+++ b/chaos/src/map_base.hpp
@@ -0,0 +1,40 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+
+#ifndef __map_base_hpp
+
+#include "chaos_base.hpp"
+
+class map_base
+ : protected chaos_base
+{
+
+};
+
+#define MAP_CALLBACKS \
+CHAOS_CALLBACKS
+
+
+#define MAP_ATTRIBUTES \
+CHAOS_ATTRIBUTES;
+
+#define __map_base_hpp
+#endif /* __map_base_hpp */
diff --git a/chaos/src/ode_base.cpp b/chaos/src/ode_base.cpp
new file mode 100644
index 0000000..cfedeee
--- /dev/null
+++ b/chaos/src/ode_base.cpp
@@ -0,0 +1,90 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "ode_base.hpp"
+
+void ode_base::rk1()
+{
+ m_system (m_k[0], m_data);
+ for (int i = 0; i != m_num_eq; ++i)
+ m_data[i] += m_dt * m_k[0][i];
+}
+
+
+void ode_base::rk2()
+{
+ m_system (m_k[0], m_data);
+ for (int i = 0; i != m_num_eq; ++i)
+ m_k[0][i] = m_k[0][i] * 0.5 * m_dt + m_data[i];
+
+ m_system (m_k[1], m_k[0]);
+ for (int i = 0; i != m_num_eq; ++i)
+ m_data[i] += m_dt * m_k[1][i];
+}
+
+
+void ode_base::rk4()
+{
+ m_system (m_k[0], m_data);
+ for (int i = 0; i != m_num_eq; ++i)
+ {
+ m_k[0][i] *= m_dt;
+ m_tmp[i] = m_data[i] + 0.5 * m_k[0][i];
+ }
+
+ m_system (m_k[1], m_tmp);
+ for (int i = 0; i != m_num_eq; ++i)
+ {
+ m_k[1][i] *= m_dt;
+ m_tmp[i] = m_data[i] + 0.5 * m_k[1][i];
+ }
+
+ m_system (m_k[2], m_tmp);
+ for (int i = 0; i != m_num_eq; ++i)
+ {
+ m_k[2][i] *= m_dt;
+ m_tmp[i] = m_data[i] + m_k[2][i];
+ }
+
+ m_system (m_k[3], m_tmp);
+ for (int i = 0; i != m_num_eq; ++i)
+ m_k[3][i] *= m_dt;
+
+ for (int i = 0; i != m_num_eq; ++i)
+ m_data[i] += (m_k[0][i] + 2. * (m_k[1][i] + m_k[2][i]) + m_k[3][i])
+ / 6.;
+}
+
+void ode_base::m_step()
+{
+ switch (m_method)
+ {
+ case 0:
+ rk1();
+ break;
+ case 1:
+ rk2();
+ break;
+ case 2:
+ rk3();
+ break;
+ }
+
+}
diff --git a/chaos/src/ode_base.hpp b/chaos/src/ode_base.hpp
new file mode 100644
index 0000000..5fdd6d1
--- /dev/null
+++ b/chaos/src/ode_base.hpp
@@ -0,0 +1,83 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+
+#ifndef __ode_base_hpp
+
+#include "chaos_base.hpp"
+
+class ode_base
+ : protected chaos_base
+{
+public:
+ void set_method(int i)
+ {
+ if (i >=0 && i <4)
+ m_method = (unsigned char) i;
+ post("no such method");
+ }
+
+ t_int get_method()
+ {
+ return (int) m_method;
+ }
+
+ void set_dt(t_float f)
+ {
+ if (f >= 0)
+ m_dt = (data_t)f;
+ else
+ post("invalid value for dt: %f", f);
+ }
+
+ t_float get_dt()
+ {
+ return (t_float) m_dt;
+ }
+
+ void m_step();
+
+protected:
+ unsigned char m_method; /* 0: rk1, 1: rk2, 3: rk4 */
+ data_t m_dt; /* step width */
+
+ data_t* m_k[3]; /* temporary arrays for runge kutta */
+ data_t* m_tmp;
+
+ virtual void m_system (data_t* deriv, data_t* data);
+
+ void rk1 ();
+ void rk2 ();
+ void rk4 ();
+};
+
+#define ODE_CALLBACKS \
+CHAOS_CALLBACKS; \
+FLEXT_CALLVAR_I(m_system->get_method, m_system->set_method); \
+FLEXT_CALLVAR_F(m_system->get_dt, m_system->set_dt);
+
+#define ODE_ATTRIBUTES \
+CHAOS_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("method", m_system->get_method, m_system->set_method); \
+FLEXT_ADDATTR_VAR("dt",m_system->get_dt, m_system->set_dt);
+
+
+#define __ode_base_hpp
+#endif /* __ode_base_hpp */
diff --git a/chaos/src/sine_map.hpp b/chaos/src/sine_map.hpp
new file mode 100644
index 0000000..dd62458
--- /dev/null
+++ b/chaos/src/sine_map.hpp
@@ -0,0 +1,72 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+#include <cmath>
+
+// sine map: x[n+1] = sin(pi * x)
+// 0 <= x[n] <= 1
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class sine:
+ protected map_base
+{
+
+public:
+ sine()
+ {
+ m_num_eq = 1;
+ m_data = new data_t[1];
+ set_x(0.5);
+ }
+
+ ~sine()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ m_data[0] = sin (M_PI * m_data[0]);
+ }
+
+ void set_x(t_float f)
+ {
+ if ( (f >= 0) && (f <= 1))
+ m_data[0] = (data_t) f;
+ else
+ post("value for x %f out of range", f);
+ }
+
+ t_float get_x()
+ {
+ return (t_float)m_data[0];
+ }
+
+};
+
+#define SINE_CALLBACKS \
+MAP_CALLBACKS \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+
+#define SINE_ATTRIBUTES \
+MAP_ATTRIBUTES \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+
diff --git a/chaos/src/standard_map.hpp b/chaos/src/standard_map.hpp
new file mode 100644
index 0000000..5f77af9
--- /dev/null
+++ b/chaos/src/standard_map.hpp
@@ -0,0 +1,130 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+#include <cmath>
+
+// standard map: I[n+1] = I[n] + k * sin(theta[n])
+// theta[n+1] = theta[n] + I[n] + k * sin(theta[n])
+// 0 <= theta <= 2*pi
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class standard:
+ protected map_base
+{
+public:
+ standard()
+ : m_k(0.8)
+ {
+ m_num_eq = 2;
+ m_data = new data_t[2];
+ set_I(0.1);
+ set_theta(0.2);
+ }
+
+ ~standard()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t I = m_data[0];
+ data_t theta = m_data[1];
+
+ m_data[0] = I + m_k * sin(theta);
+ theta = theta + I + k * sin(theta);
+
+ if (y > 2 * M_PI)
+ {
+ do
+ {
+ y -= 2*M_PI;
+ }
+ while (y > 2 * M_PI);
+ goto put_data;
+ }
+
+ if (y < 0)
+ {
+ do
+ {
+ y += 2*M_PI;
+ }
+ while (y < 0);
+ }
+
+ put_data:
+ m_data[1] = theta;
+ }
+
+
+ void set_I(t_float f)
+ {
+ m_data[0] = (data_t) f;
+ }
+
+ t_float get_I()
+ {
+ return (t_float)m_data[0];
+ }
+
+
+ void set_theta(t_float f)
+ {
+ if ( (f >= 0) && (f < 2*M_PI))
+ m_data[1] = (data_t) f;
+ else
+ post("value for theta %f out of range", f);
+ }
+
+ t_float get_theta()
+ {
+ return (t_float)m_data[1];
+ }
+
+
+ void set_k(t_float f)
+ {
+ m_k = (data_t) f;
+ }
+
+ t_float get_k()
+ {
+ return (t_float)m_k;
+ }
+
+private:
+ data_t m_k;
+};
+
+
+#define STANDARD_CALLBACKS \
+MAP_CALLBACKS; \
+FLEXT_CALLVAR_F(m_system->get_I, m_system->set_I); \
+FLEXT_CALLVAR_F(m_system->get_theta, m_system->set_theta); \
+FLEXT_CALLVAR_F(m_system->get_k, m_system->set_k);
+
+
+#define STANDARD_ATTRIBUTES \
+MAP_ATTRIBUTES; \
+FLEXT_ADDATTR_VAR("I",m_system->get_I, m_system->set_I); \
+FLEXT_ADDATTR_VAR("theta",m_system->get_theta, m_system->set_theta); \
+FLEXT_ADDATTR_VAR("k",m_system->get_k, m_system->set_k);
diff --git a/chaos/src/tent_map.hpp b/chaos/src/tent_map.hpp
new file mode 100644
index 0000000..16de333
--- /dev/null
+++ b/chaos/src/tent_map.hpp
@@ -0,0 +1,63 @@
+//
+//
+// chaos~
+// Copyright (C) 2004 Tim Blechmann
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#include "map_base.hpp"
+
+// tent map: x[n+1] = 2 * x[n] (for 0 < x <= 0.5)
+// 2 * (1 - x[n]) (else)
+// 0 <= x[n] < 1
+// taken from Willi-Hans Steeb: Chaos and Fractals
+
+class tent:
+ protected map_base
+{
+public:
+ tent()
+ {
+ m_num_eq = 1;
+ m_data = new data_t[1];
+ set_x(0.5);
+ }
+
+ ~tent()
+ {
+ delete m_data;
+ }
+
+ virtual void m_step()
+ {
+ data_t data = m_data[0];
+
+ if (data < 0.5f)
+ m_data[0] = 2.f * data;
+ else
+ m_data[0] = 2.f * (1.f - data);
+ }
+};
+
+
+#define LOGISTIC_CALLBACKS \
+MAP_CALLBACKS \
+FLEXT_CALLVAR_F(m_system->get_x, m_system->set_x);
+
+#define LOGISTIC_ATTRIBUTES \
+MAP_ATTRIBUTES \
+FLEXT_ADDATTR_VAR("x",m_system->get_x, m_system->set_x);
+