From 5c3670b6322b60b8bc5f60e22d891fe39b854e3e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Fri, 24 Dec 2004 23:20:22 +0000 Subject: more changes ... getting stable ... svn path=/trunk/externals/tb/; revision=2428 --- chaos/configure.ac | 5 ++++- chaos/src/Makefile.am | 2 +- chaos/src/chaos_dsp.hpp | 25 +++++++++++++++---------- chaos/src/logistic_map.hpp | 2 +- chaos/src/lorenz.hpp | 5 ++++- chaos/src/main.cpp | 2 +- chaos/src/map_base.hpp | 2 +- chaos/src/ode_base.hpp | 22 ++++++++++++++++++++++ 8 files changed, 49 insertions(+), 16 deletions(-) diff --git a/chaos/configure.ac b/chaos/configure.ac index c228f01..67bf056 100644 --- a/chaos/configure.ac +++ b/chaos/configure.ac @@ -49,7 +49,10 @@ AC_ARG_ENABLE(system, AC_ARG_WITH(sysdir, [ --with-sysdir path pd / max installation], - SYSDIR=$withval, + [ + SYSDIR=$withval + INCLUDEDIR="-I$withval $INCLUDEDIR" + ], [echo "path to pd / max installation required" && exit 1]) diff --git a/chaos/src/Makefile.am b/chaos/src/Makefile.am index 43ad73b..efbb7f1 100644 --- a/chaos/src/Makefile.am +++ b/chaos/src/Makefile.am @@ -1,7 +1,7 @@ NAME = chaos BUILT_SOURCES = main.cpp ode_base.cpp chaos_base.cpp chaos_dsp.cpp \ - lorenz_dsp.cpp + lorenz_dsp.cpp logistic_dsp.cpp CXXFLAGS = @CXXFLAGS@ \ diff --git a/chaos/src/chaos_dsp.hpp b/chaos/src/chaos_dsp.hpp index 65e6203..c340b88 100644 --- a/chaos/src/chaos_dsp.hpp +++ b/chaos/src/chaos_dsp.hpp @@ -60,12 +60,12 @@ public: int m_phase; /* phase counter */ float m_sr; /* sample rate */ - char m_method; /* interpolation method */ + int m_method; /* interpolation method */ }; -/* create constructor / destructor */ \ +/* create constructor / destructor */ #define CHAOS_DSP_INIT(SYSTEM, ATTRIBUTES) \ FLEXT_HEADER(SYSTEM##_dsp, chaos_dsp) \ \ @@ -87,7 +87,10 @@ SYSTEM##_dsp(int argc, t_atom* argv ) \ m_freq = GetAFloat(argv[0]); \ m_method = (char)GetAFloat(argv[1]); \ m_phase = 0; \ - \ + \ + FLEXT_ADDATTR_VAR1("frequency",m_freq); \ + FLEXT_ADDATTR_VAR1("method",m_method); \ + \ ATTRIBUTES; \ } \ \ @@ -99,21 +102,23 @@ SYSTEM##_dsp(int argc, t_atom* argv ) \ delete m_nextvalues; \ delete m_nextmidpts; \ delete m_curves; \ -} - +} \ + \ +FLEXT_ATTRVAR_F(m_freq); \ +FLEXT_ATTRVAR_I(m_method); template void chaos_dsp::m_signal(int n, t_sample *const *insigs, - t_sample *const *outsigs) + t_sample *const *outsigs) { if (m_freq >= m_sr * 0.5) { m_signal_(n, insigs, outsigs); return; } - + switch (m_method) { case 0: @@ -157,7 +162,7 @@ void chaos_dsp::m_signal_n(int n, t_sample *const *insigs, while (n) { - if (m_phase == 0) + if (phase == 0) { m_system->m_step(); phase = int (m_sr / m_freq); @@ -194,7 +199,7 @@ void chaos_dsp::m_signal_l(int n, t_sample *const *insigs, while (n) { - if (m_phase == 0) + if (phase == 0) { m_system->m_step(); phase = int (m_sr / m_freq); @@ -233,7 +238,7 @@ void chaos_dsp::m_signal_c(int n, t_sample *const *insigs, while (n) { - if (m_phase == 0) + if (phase == 0) { m_system->m_step(); phase = int (m_sr / m_freq); diff --git a/chaos/src/logistic_map.hpp b/chaos/src/logistic_map.hpp index 94b38d0..e72a3a7 100644 --- a/chaos/src/logistic_map.hpp +++ b/chaos/src/logistic_map.hpp @@ -25,7 +25,7 @@ // 0 <= alpha <= 4 class logistic: - protected map_base + public map_base { public: logistic() diff --git a/chaos/src/lorenz.hpp b/chaos/src/lorenz.hpp index 700e4a1..fdae428 100644 --- a/chaos/src/lorenz.hpp +++ b/chaos/src/lorenz.hpp @@ -32,7 +32,7 @@ public: lorenz() { m_num_eq = 3; - m_data = new data_t[3]; + m_data = new data_t[m_num_eq]; CHAOS_SYS_INIT(method,0); CHAOS_SYS_INIT(dt,1); @@ -43,11 +43,14 @@ public: CHAOS_SYS_INIT(b,4); CHAOS_SYS_INIT(r,40); + ode_base_alloc(); + set_method(0); } ~lorenz() { + ode_base_free(); delete m_data; } diff --git a/chaos/src/main.cpp b/chaos/src/main.cpp index b0f2ad0..3a322f0 100644 --- a/chaos/src/main.cpp +++ b/chaos/src/main.cpp @@ -19,13 +19,13 @@ // Boston, MA 02111-1307, USA. #include "chaos.hpp" -#include "logistic_map.hpp" void chaos_library_setup() { post("chaos~ version "PACKAGE_VERSION"\n"); FLEXT_DSP_SETUP(lorenz_dsp); + FLEXT_DSP_SETUP(logistic_dsp); } FLEXT_LIB_SETUP(chaos, chaos_library_setup); diff --git a/chaos/src/map_base.hpp b/chaos/src/map_base.hpp index 35c8460..c88f9ba 100644 --- a/chaos/src/map_base.hpp +++ b/chaos/src/map_base.hpp @@ -24,7 +24,7 @@ #include "chaos_base.hpp" class map_base - : protected chaos_base + : public chaos_base { }; diff --git a/chaos/src/ode_base.hpp b/chaos/src/ode_base.hpp index 6fa7e27..cc526ae 100644 --- a/chaos/src/ode_base.hpp +++ b/chaos/src/ode_base.hpp @@ -49,6 +49,28 @@ public: virtual void m_step(); + void ode_base_alloc() + { + int dimension = get_num_eq(); + + for (int i = 0; i != 3; ++i) + { + m_k[i] = new data_t[dimension]; + } + + m_tmp = new data_t[dimension]; + } + + void ode_base_free() + { + for (int i = 0; i != 3; ++i) + { + delete m_k[i]; + } + + delete m_tmp; + } + protected: unsigned char m_method; /* 0: rk1, 1: rk2, 3: rk4 */ -- cgit v1.2.1