Update of /cvsroot/pure-data/externals/sc4pd/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5454/source
Modified Files: DelayN.cpp DelayUnit.cpp DelayUnit.hpp main.cpp support.hpp Log Message: small changes
Index: main.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/sc4pd/source/main.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** main.cpp 3 Aug 2004 09:56:19 -0000 1.16 --- main.cpp 3 Aug 2004 17:51:51 -0000 1.17 *************** *** 59,64 **** "sqrdif(~),\n" " sqrsum(~), absdif(~), LFSaw(~), LFPulse(~), Impulse(~),\n" ! " Integrator(~), Decay~, Decay2~, Lag~, Lag2~, LinExp(~)" ! "DelayN~\n" );
--- 59,65 ---- "sqrdif(~),\n" " sqrsum(~), absdif(~), LFSaw(~), LFPulse(~), Impulse(~),\n" ! " Integrator(~), Decay~, Decay2~, Lag~, Lag2~, LinExp(~), " ! "DelayN~,\n" ! " DelayL~, DelayC~" );
*************** *** 209,212 **** --- 210,217 ----
FLEXT_DSP_SETUP(DelayN_ar); + + FLEXT_DSP_SETUP(DelayL_ar); + + FLEXT_DSP_SETUP(DelayC_ar); }
Index: support.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/sc4pd/source/support.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** support.hpp 2 Aug 2004 19:18:22 -0000 1.6 --- support.hpp 3 Aug 2004 17:51:51 -0000 1.7 *************** *** 35,48 **** */
#include <flext.h> - //#include <flsupport.h> #include "SC_PlugIn.h"
- //#include <strings.h> #if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 406) #error You need at least FLEXT version 0.4.6 #endif
/* for argument parsing */ bool sc_add (flext::AtomList a); --- 35,50 ---- */
+ #ifndef _SUPPORT_HPP + #define _SUPPORT_HPP + #include <flext.h> #include "SC_PlugIn.h"
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 406) #error You need at least FLEXT version 0.4.6 #endif
+ /* for argument parsing */ bool sc_add (flext::AtomList a); *************** *** 66,69 **** --- 68,97 ---- int32 timeseed();
+ /* cubic interpolation from DelayUGens.cpp */ + inline float cubicinterp(float x, float y0, float y1, float y2, float y3) + { + // 4-point, 3rd-order Hermite (x-form) + float c0 = y1; + float c1 = 0.5f * (y2 - y0); + float c2 = y0 - 2.5f * y1 + 2.f * y2 - 0.5f * y3; + float c3 = 0.5f * (y3 - y0) + 1.5f * (y1 - y2); + + return ((c3 * x + c2) * x + c1) * x + c0; + } + + /* feedback calculation from DelayUGens.cpp */ + inline float CalcFeedback(float delaytime, float decaytime) + { + if (delaytime == 0.f) { + return 0.f; + } else if (decaytime > 0.f) { + return exp(log001 * delaytime / decaytime); + } else if (decaytime < 0.f) { + return -exp(log001 * delaytime / -decaytime); + } else { + return 0.f; + } + } +
/* this is copied from thomas grill's xsample: *************** *** 96,97 **** --- 124,126 ----
+ #endif
Index: DelayUnit.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/sc4pd/source/DelayUnit.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DelayUnit.cpp 3 Aug 2004 09:56:19 -0000 1.1 --- DelayUnit.cpp 3 Aug 2004 17:51:51 -0000 1.2 *************** *** 47,51 **** m_fdelaylen = m_idelaylen = delaybufsize;
! delete m_dlybuf; m_dlybuf = new float[delaybufsize] ; m_mask = delaybufsize - 1; --- 47,51 ---- m_fdelaylen = m_idelaylen = delaybufsize;
! delete[] m_dlybuf; m_dlybuf = new float[delaybufsize] ; m_mask = delaybufsize - 1; *************** *** 54,70 **** void DelayUnit_ar::DelayUnit_Dtor() { ! delete m_dlybuf; }
float DelayUnit_ar::CalcDelay(float delaytime) { ! float next_dsamp = delaytime * Samplerate(); ! return sc_clip(next_dsamp, 1.f, m_fdelaylen); }
! void DelayUnit_ar::DelayUnit_Reset(float f, float g) { - m_maxdelaytime = f; - m_delaytime = g; m_dlybuf = 0;
--- 54,68 ---- void DelayUnit_ar::DelayUnit_Dtor() { ! delete[] m_dlybuf; }
float DelayUnit_ar::CalcDelay(float delaytime) { ! float next_dsamp = delaytime * Samplerate(); ! return sc_clip(next_dsamp, 1.f, m_fdelaylen); }
! void DelayUnit_ar::DelayUnit_Reset() { m_dlybuf = 0;
*************** *** 76,77 **** --- 74,82 ---- m_iwrphase = 0; } + + void FeedbackDelay_ar::FeedbackDelay_Reset() + { + DelayUnit_Reset(); + + m_feedbk = CalcFeedback(m_delaytime, m_decaytime); + }
Index: DelayN.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/sc4pd/source/DelayN.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DelayN.cpp 3 Aug 2004 09:56:19 -0000 1.1 --- DelayN.cpp 3 Aug 2004 17:51:50 -0000 1.2 *************** *** 33,37 ****
Coded while listening to: ! */
--- 33,37 ----
Coded while listening to: ! */
*************** *** 55,60 **** { changed = false; ! DelayUnit_Reset(m_maxdelaytime, m_delaytime); ! post("start"); }
--- 55,59 ---- { changed = false; ! DelayUnit_Reset(); }
Index: DelayUnit.hpp =================================================================== RCS file: /cvsroot/pure-data/externals/sc4pd/source/DelayUnit.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DelayUnit.hpp 3 Aug 2004 09:56:19 -0000 1.1 --- DelayUnit.hpp 3 Aug 2004 17:51:51 -0000 1.2 *************** *** 44,48 **** /* functions */ void DelayUnit_AllocDelayLine(); ! void DelayUnit_Reset(float maxdelaytime, float delaytime); float CalcDelay(float delaytime); void DelayUnit_Dtor(); --- 44,48 ---- /* functions */ void DelayUnit_AllocDelayLine(); ! void DelayUnit_Reset(); float CalcDelay(float delaytime); void DelayUnit_Dtor(); *************** *** 57,58 **** --- 57,65 ----
/* todo: a delay for control messages? */ + + class FeedbackDelay_ar : public DelayUnit_ar + { + FLEXT_HEADER(FeedbackDelay_ar,DelayUnit_ar); + float m_feedbk, m_decaytime; + void FeedbackDelay_Reset(); + };