Update of /cvsroot/pure-data/externals/tbext/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7755
Modified Files: him.cpp Log Message: added crossfade
Index: him.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/tbext/source/him.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** him.cpp 13 Jul 2004 20:04:52 -0000 1.4 --- him.cpp 5 Sep 2004 21:28:52 -0000 1.5 *************** *** 63,66 **** --- 63,67 ---- protected: virtual void m_signal (int n, float *const *in, float *const *out); + virtual void m_dsp (int n, float *const *in, float *const *out);
void set_mu(t_float); *************** *** 79,83 ****
// 4th order Runge Kutta update of the dynamical variables ! void runge_kutta_4(t_float dt);
//these are our data --- 80,84 ----
// 4th order Runge Kutta update of the dynamical variables ! void runge_kutta_4(t_float dt);
//these are our data *************** *** 89,92 **** --- 90,101 ---- bool regtime; //if true "regularisierte zeit"
+ bool xfade; + t_float newE; + t_float newdt; + bool newsystem; + bool newregtime; + + t_float * m_fader; + //Callbacks FLEXT_CALLBACK_1(set_mu,t_float); *************** *** 210,214 ****
/* ! the system might become unstable ... in this case, we'll reset the system */
--- 219,223 ----
/* ! the system might become unstable ... in this case, we'll request a new system */
*************** *** 216,220 **** { if(data[i]>2) ! reset(); } } --- 225,237 ---- { if(data[i]>2) ! { ! xfade = newsystem = true; ! data[i] = 2; ! } ! if(data[i]<-2) ! { ! xfade = newsystem = true; ! data[i] = -2; ! } } } *************** *** 234,238 **** if (regtime) { ! for (int j=0;j!=n;++j) { runge_kutta_4(dt); --- 251,255 ---- if (regtime) { ! for (int i=0;i!=n;++i) { runge_kutta_4(dt); *************** *** 247,251 **** else { ! for (int j=0;j!=n;++j) { runge_kutta_4(dt/(2*sqrt(data[0]*data[0]+data[2]*data[2]))); --- 264,268 ---- else { ! for (int i=0;i!=n;++i) { runge_kutta_4(dt/(2*sqrt(data[0]*data[0]+data[2]*data[2]))); *************** *** 258,263 **** --- 275,369 ---- } } + + if (xfade) + { + /* fading */ + out0 = out[0]; + out1 = out[1]; + out2 = out[2]; + out3 = out[3]; + out4 = out[4]; + out5 = out[5]; + + t_float * fader = m_fader + n - 1; + for (int i=0;i!=n;++i) + { + (*(out0)++) *= *fader; + (*(out1)++) *= *fader; + (*(out2)++) *= *fader; + (*(out3)++) *= *fader; + (*(out4)++) *= *fader; + (*(out5)++) *= *fader--; + } + + if (newsystem) + { + reset(); + newsystem = false; + } + + E = newE; + dt = newdt; + regtime = newregtime; + + out0 = out[0]; + out1 = out[1]; + out2 = out[2]; + out3 = out[3]; + out4 = out[4]; + out5 = out[5]; + + fader = m_fader; + if (regtime) + { + for (int i=0;i!=n;++i) + { + runge_kutta_4(dt); + (*(out0)++)+= data[0]* *fader; + (*(out1)++)+= data[1]* *fader; + (*(out2)++)+= data[2]* *fader; + (*(out3)++)+= data[3]* *fader; + (*(out4)++)+= data[0]*data[2]* *fader; + (*(out5)++)+= (data[0]*data[0]-data[2]*data[2])*0.5* *fader++; + } + } + else + { + for (int i=0;i!=n;++i) + { + runge_kutta_4(dt/(2*sqrt(data[0]*data[0]+data[2]*data[2]))); + (*(out0)++)+= data[0]* *fader; + (*(out1)++)+= data[1]* *fader; + (*(out2)++)+= data[2]* *fader; + (*(out3)++)+= data[3]* *fader; + (*(out4)++)+= data[0]*data[2]* *fader; + (*(out5)++)+= (data[0]*data[0]-data[2]*data[2])*0.5* *fader++; + } + } + + xfade = false; + } + }
+ void him::m_dsp(int n, t_float *const *in, t_float *const *out) + { + m_fader = new t_float[n]; + t_float on = 1.f/(n-1); + + t_float value = 0; + + t_float* localfader = m_fader; + + while (n--) + { + *localfader = value; + value += on; + ++localfader; + } + xfade = false; + } + + void him::set_mu(t_float f) { *************** *** 282,302 **** data[3]=f; reset_muv(); - post("resetting muv!!!"); }
void him::set_etilde(t_float f) { ! E=f; ! reset_nuv(); }
void him::set_dt(t_float f) { ! dt=f; }
void him::set_regtime(bool b) { ! regtime=b; }
--- 388,410 ---- data[3]=f; reset_muv(); }
void him::set_etilde(t_float f) { ! newE=f; ! xfade = true; ! //reset_nuv(); }
void him::set_dt(t_float f) { ! newdt=f; ! xfade = true; }
void him::set_regtime(bool b) { ! newregtime=b; ! xfade = true; }
*************** *** 317,320 **** data[2]=float(rand())/float(RAND_MAX); reset_nuv(); - post("randomizing values"); } --- 425,427 ----