This is pmfilt.c in view mode; [Download] [Up]
double coef[128],past[512]; int jcount,npoles,npolest2,odd,nco,npolesm1,ncom1,xxx; pmload(p,ncoefs) float *p; int ncoefs; { int i; xxx=0; nco = ncoefs; ncom1 = ncoefs-1; for(i=0; i<ncoefs; i++) coef[i] = p[i]; for(i=0; i<(ncoefs*4); i++) past[i]=0; odd = ncoefs % 2; npoles= odd + ncoefs/2; npolesm1 = npoles - 1; jcount=0; npolest2=npoles*2; //for(i=0; i<ncoefs; i++) printf("%f\n",coef[i]); } float pmfilt(sig) float sig; { int tail,j; float out; /* uses double array of past inputs to avoid reshuffling */ tail = jcount + npolest2 -1 - odd; for(out=0,j=0; j<npoles-odd; j++) out += (past[jcount+j] + past[tail-j]) * coef[j]; if(odd) out += past[jcount+j] * coef[j]; past[jcount] = past[jcount+npolest2] = sig; jcount = (jcount + 1) % npolest2; return(out); } double pmfilt2(sig) float sig; { int j,pos1,pos2; double out; past[jcount] = sig; if(!odd) { for(out=j=0; j<npoles; j++) { pos1 = jcount-j; pos2 = jcount+j+1; if(pos1 < 0) pos1 += nco; if(pos2 >= npolest2) pos2 -= nco; out += coef[j] * (past[pos1] + past[pos2]); } } else { for(out=j=0; j<npolesm1; j++) { pos1 = jcount-j; pos2 = jcount+j+1; if(pos1 < 0) pos1 += nco; if(pos2 >= npolest2) pos2 -= nco; out += coef[j] * (past[pos1] + past[pos2]); } pos1 = jcount - npolesm1; if(pos1 < 0) pos1 += nco; out += coef[npolesm1] * past[pos1]; } jcount++; jcount = jcount % nco; return(out); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.