void Camera::gluLookAt() { GLfloat forward[3], side[3], up[3]; GLfloat m[4][4]; forward[0] = m_centerx - m_eyex; forward[1] = m_centery - m_eyey; forward[2] = m_centerz - m_eyez; normalizef(forward); up[0] = m_upx; up[1] = m_upy; up[2] = m_upz; crossf(forward, up, side); normalizef(side); crossf(side, forward, up); identf(&m[0][0]); m[0][0] = side[0]; m[1][0] = side[1]; m[2][0] = side[2]; m[0][1] = up[0]; m[1][1] = up[1]; m[2][1] = up[2]; m[0][2] = -forward[0]; m[1][2] = -forward[1]; m[2][2] = -forward[2]; glMultMatrixf(&m[0][0]); glTranslatef(-m_eyex, -m_eyey, -m_eyez); }
/* ----------------------------------------------------------------------- */ void get_fast_cands(float *fdata, float *fdsdata, int ind, int step, int size, int dec, int start, int nlags, float *engref, int *maxloc, float *maxval, Cross *cp, float *peaks, int *locs, int *ncand, F0_params *par) { int decind, decstart, decnlags, decsize, i, j, *lp; float *corp, xp, yp, lag_wt; register float *pe; lag_wt = par->lag_weight/nlags; decnlags = 1 + (nlags/dec); if((decstart = start/dec) < 1) decstart = 1; decind = (ind * step)/dec; decsize = 1 + (size/dec); corp = cp->correl; crossf(fdsdata + decind, decsize, decstart, decnlags, engref, maxloc, maxval, corp); cp->maxloc = *maxloc; /* location of maximum in correlation */ cp->maxval = *maxval; /* max. correlation value (found at maxloc) */ cp->rms = (float) sqrt(*engref/size); /* rms in reference window */ cp->firstlag = decstart; get_cand(cp,peaks,locs,decnlags,ncand,par->cand_thresh); /* return high peaks in xcorr */ /* Interpolate to estimate peak locations and values at high sample rate. */ for(i = *ncand, lp = locs, pe = peaks; i--; pe++, lp++) { j = *lp - decstart - 1; peak(&corp[j],&xp,&yp); *lp = (*lp * dec) + (int)(0.5+(xp*dec)); /* refined lag */ *pe = yp*(1.0f - (lag_wt* *lp)); /* refined amplitude */ } if(*ncand >= par->n_cands) { /* need to prune candidates? */ register int *loc, *locm, lt; register float smaxval, *pem; register int outer, inner, lim; for(outer=0, lim = par->n_cands-1; outer < lim; outer++) for(inner = *ncand - 1 - outer, pe = peaks + (*ncand) -1, pem = pe-1, loc = locs + (*ncand) - 1, locm = loc-1; inner--; pe--,pem--,loc--,locm--) if((smaxval = *pe) > *pem) { *pe = *pem; *pem = smaxval; lt = *loc; *loc = *locm; *locm = lt; } *ncand = par->n_cands-1; /* leave room for the unvoiced hypothesis */ } crossfi(fdata + (ind * step), size, start, nlags, 7, engref, maxloc, maxval, corp, locs, *ncand); cp->maxloc = *maxloc; /* location of maximum in correlation */ cp->maxval = *maxval; /* max. correlation value (found at maxloc) */ cp->rms = (float) sqrt(*engref/size); /* rms in reference window */ cp->firstlag = start; get_cand(cp,peaks,locs,nlags,ncand,par->cand_thresh); /* return high peaks in xcorr */ if(*ncand >= par->n_cands) { /* need to prune candidates again? */ register int *loc, *locm, lt; register float smaxval, *pe, *pem; register int outer, inner, lim; for(outer=0, lim = par->n_cands-1; outer < lim; outer++) for(inner = *ncand - 1 - outer, pe = peaks + (*ncand) -1, pem = pe-1, loc = locs + (*ncand) - 1, locm = loc-1; inner--; pe--,pem--,loc--,locm--) if((smaxval = *pe) > *pem) { *pe = *pem; *pem = smaxval; lt = *loc; *loc = *locm; *locm = lt; } *ncand = par->n_cands - 1; /* leave room for the unvoiced hypothesis */ } }