/* genetic wavegenerator, pd external dna(at)basilar(dot)net 2006 */ #include #if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400) #error you need at least flext version 0.4.0 #endif class point { public: float x; float y; }; point* qb(const point* point1, const point* point2, const point* point3, const float t) { float x0 = point1->x; float y0 = point1->y; float x1 = point2->x; float y1 = point2->y; float x2 = point3->x; float y2 = point3->y; float cx = 2*(x1-x0); float bx = (x2-x0)-cx; float cy = 2*(y1-y0); float by = (y2-y0)-cy; float tSquared = t*t; float x = bx * tSquared + cx*t + x0; float y = by * tSquared + cy*t + y0; if(1x = x; p->y = y; return p; } const int no_of_guide_points = 30; point* guide_points[no_of_guide_points]; void cb(const point* start_point,const point* control_point,const point* end_point) { float dt = 1/((float)(no_of_guide_points-1)); for(int i=0; ix = 0; ps->y = start_pos; point* pc = new point(); pc->x = ((float)len)/2; pc->y = control_pos; point* ep = new point(); ep->x = ((float)len); ep->y = end_pos; cb(ps,pc,ep); point* p = guide_points[0]; float x = p->x; float y = p->y; int prev_idx = 0; float prev_x = x; float prev_y = y; final_points[0] = start_pos; for(int i=2; ix; float curr_y = guide_points[i]->y; int i_prevx = (int)prev_x; int i_currx = (int)curr_x; for(int j=i_prevx; j