From 29520a2b958bcefe3dd774bd71a7b9e0fd2fa18e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 13 Jan 2005 13:39:57 +0000 Subject: smooth interpolation changing svn path=/trunk/externals/tb/; revision=2500 --- chaos/src/chaos_dsp.hpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'chaos') diff --git a/chaos/src/chaos_dsp.hpp b/chaos/src/chaos_dsp.hpp index 9704432..879eb49 100644 --- a/chaos/src/chaos_dsp.hpp +++ b/chaos/src/chaos_dsp.hpp @@ -74,6 +74,7 @@ public: void set_imethod(int i) { + int imethod = m_imethod; if( (i >= 0) && (i <= 2) ) { m_imethod = i; @@ -95,13 +96,21 @@ public: post("interpolation method out of range"); return; } - if( i != 2) + + if (imethod == 0) + for (int j = 0; j != m_system->get_num_eq(); ++j) + { + m_values[j] = m_system->get_data(j); + m_slopes[j] = 0; + } + + if( i == 2) { for (int j = 0; j != m_system->get_num_eq(); ++j) { - m_nextvalues[i] = 0; - m_nextmidpts[i] = 0; - m_curves[i] = 0; + m_phase = 0; /* reschedule to avoid click, find a better way later*/ + m_nextvalues[j] = m_values[j]; + m_nextmidpts[j] = m_values[j]; } } @@ -221,9 +230,8 @@ void chaos_dsp::m_signal_n(int n, t_sample *const *insigs, int outlets = m_system->get_num_eq(); int phase = m_phase; - - int i = 0; - + + int offset = 0; while (n) { if (phase == 0) @@ -236,19 +244,15 @@ void chaos_dsp::m_signal_n(int n, t_sample *const *insigs, n -= next; phase -=next; - while (next--) + for (int i = 0; i != outlets; ++i) { - for (int j = 0; j != outlets; ++j) - { - outsigs[j][i] = m_system->get_data(j); - } - ++i; + SetSamples(outsigs[i]+offset, next, m_system->get_data(i)); } + offset += next; } m_phase = phase; } - /* linear and cubic interpolation adapted from supercollider by James McCartney */ template void chaos_dsp::m_signal_l(int n, t_sample *const *insigs, -- cgit v1.2.1