void tpeq_sinelist_points(tpeq_sinelist *x, Symbol *s, short argc, Atom *argv) { float prev; int i; if (argc%2 != 0) { post("¥ tpeq-sinelist: tpe_points: args must be a multiple of 2 floats"); return; } if (argc < 2) { post("¥ tpeq-sinelist: tpe_points: not enough arguments"); return; } if (argc/2 > NUM_KNOTS) { post("¥ warning: tpeq-sinelist max # points %d; ignoring extra args", NUM_KNOTS); argc = NUM_KNOTS * 2; } for (i = 0; i < argc; ++i) { if (argv[i].a_type == A_SYM) { post("¥ tpeq-sinelist: tpe_points: args must all be numbers"); return; } } /* Make sure findex are in increasing order */ prev = FLOATVAL(argv[0])-1.0f; for (i = 0; i < argc; i+= 2) { if (FLOATVAL(argv[i]) <= prev) { post("¥ tpeq-sinelist: tpe_points: partial indices must be increasing"); return; } prev = FLOATVAL(argv[i]); } /* Phew! */ for (i = 0; i < argc/2; i++) { x->findex[i] = FLOATVAL(argv[i*2]); x->gains[i] = FLOATVAL(argv[i*2 + 1]); } x->n = argc/2; x->validFactors = 0; }
void CCourse::FillGlArrays() { TVector3 *normals = nmls; glDisableClientState (GL_VERTEX_ARRAY); glDisableClientState (GL_NORMAL_ARRAY); glDisableClientState (GL_COLOR_ARRAY); if(vnc_array == NULL) vnc_array = new GLubyte[STRIDE_GL_ARRAY * nx * ny]; for (int x=0; x<nx; x++) { for (int y=0; y<ny; y++) { int idx = STRIDE_GL_ARRAY * (y * nx + x); FLOATVAL(0) = (GLfloat)x / (nx-1.0) * curr_course->size.x; FLOATVAL(1) = elevation[(x) + nx*(y)]; FLOATVAL(2) = -(GLfloat)y / (ny-1.0) * curr_course->size.y; const TVector3& nml = normals[ x + y * nx ]; FLOATVAL(4) = nml.x; FLOATVAL(5) = nml.y; FLOATVAL(6) = nml.z; FLOATVAL(7) = 1.0f; BYTEVAL(0) = 255; BYTEVAL(1) = 255; BYTEVAL(2) = 255; BYTEVAL(3) = 255; } } glEnableClientState (GL_VERTEX_ARRAY); glVertexPointer (3, GL_FLOAT, STRIDE_GL_ARRAY, vnc_array); glEnableClientState (GL_NORMAL_ARRAY); glNormalPointer (GL_FLOAT, STRIDE_GL_ARRAY, vnc_array + 4*sizeof(GLfloat)); glEnableClientState (GL_COLOR_ARRAY); glColorPointer (4, GL_UNSIGNED_BYTE, STRIDE_GL_ARRAY, vnc_array + 8*sizeof(GLfloat)); }
void tpeq_sinelist_list(tpeq_sinelist *x, Symbol *s, short argc, Atom *argv) { int i; for (i = 0; i < argc; ++i) { if (argv[i].a_type == A_SYM) { post("¥ tpeq-sinelist: freq/amp list must be all numbers"); return; } } if (argc/2 > x->maxpartials) { post("¥ tpeq-sinelist: warning: ignoring all but the first %ld partials in your list", x->maxpartials); argc = x->maxpartials * 2; } if (x->validFactors < argc/2) { RecomputeFunction(x, argc/2); } if ((x->n == 1) && (x->gains[0] == 0.0f)) { /* Pass all values unchanged. */ outlet_list(x->o_outlet, 0L, argc, argv); return; } for(i=0; i<argc/2; ++i) { // Freq x->outputlist[2*i] = argv[2*i]; // Amp x->outputlist[2*i+1].a_w.w_float = FLOATVAL(argv[2*i+1]) * x->partialFactors[i]; } outlet_list(x->o_outlet, 0L, argc, x->outputlist); }