#include "/musr/H/ugens.h" #include "/musr/H/sfheader.h" #include #define RESIDAMP 0 #define RMSAMP 1 #define THRESH 2 #define PITCH 3 /* values in locs 0-3 of frame*/ #define NPOLE 32 #define NPOLEM1 31 #define FRAMSIZE (NPOLE+4) #define FPREC 22 #define RECSIZE (FPREC*FRAMSIZE) #define BPREC (RECSIZE*FLOAT) #define BPFRAME (FRAMSIZE*FLOAT) int anal; float cq,outold; extern SFHEADER sfdesc[NFILES]; int anal; char dataset_name[80]; lpcplay(p,n_args) float *p; { float amp,si,hn,phs,*f,srd2,magic,d,warpset(); float c[FRAMSIZE],past[NPOLE*2],frames,frame1,frameno,ampmlt,errno; float ballpole(),alpvals[2048],buzvals[4096],pchval[2048]; float thresh,randamp,randoff; float *cpoint; float x,transposition,newpch; int jcount,seed,i,nsamps,counter; float cps,tblvals[2],weight(); int input, output, j,k; if(!n_args) { /* printf(" p[0]=starting time, p[1]=duration, p[2]=pitch,p[3]=frame1, p4=frame2 p[5]=amp, p[6]=thresh, p[7]=d,p[8]=inputskip\n"); */ return; } for(i=0; i0; i -=counter) { frameno = ((float)(nsamps - i)/nsamps)*frames + frame1; if(getfr(frameno,c) == -1) break; errno = (c[2] > thresh) ? 0 : 1; ampmlt = (errno) ? amp * c[0] : amp * c[0] * randamp; /* cps = tablei(nsamps-i,pchval,tblvals); newpch = cpsoct(octcps(cps)+transposition); if(newpch == 0) newpch=55; */ /* CRIPPLED THIS CODE SO NEVER USES PCH */ newpch=112; si = newpch * magic; hn = (int)(srd2/newpch); counter = (float)(SR/newpch); counter = (counter > i) ? i : counter; if(counter <= 0) break; bgetin(buzvals,input,counter*sfchans(&sfdesc[input])); if(sfchans(&sfdesc[input]) == 2) for(j=0,k=0; j=0; n--) { temp2 = past[n]; past[n] = d * (past[n+1] - past[n]) + temp1; temp1 = temp2; } for(n=0;n=0; n--) { temp2 = past[n]; past[n] = d * (past[n+1] - past[n]) + temp1; temp1 = temp2; } for(n=0;n= oldframe) && (frame < endframe))) { if(lseek(anal,((long)frame*(long)BPFRAME),0) == -1) { fprintf(stderr,"bad lseek on analysis file \n"); return(-1); } if(read(anal,(char *)array,BPREC) <= 0) { fprintf(stderr,"reached eof on analysis file \n"); return(-1); } oldframe = frame; endframe = oldframe + FPREC - 1; } for(i=(frame-oldframe)*FRAMSIZE,j=0; j= *(tab+1)) loc = *(tab+1); return(*(array + loc)); } float weight(newpch,frame1,frame2,thresh) float newpch,frame1,frame2; { float c[FRAMSIZE]; int i; float xweight,sum; xweight = sum = 0; for(i=(int)frame1; i<(int)frame2; i++) { getfr((float)i,c); if(c[THRESH] > thresh) continue; xweight += c[RMSAMP]; sum += (c[PITCH] * c[RMSAMP]); } return(sum/xweight); } dataset(p,n_args) /* p1=dataset name, p2=npoles */ float *p; { char *name; int i; i=(int)p[0]; name=(char *)i; if(strcmp(name,dataset_name)== 0) { printf("\n%s is already open.\n",name); return; } strcpy(dataset_name,name); if((anal = open(name,0)) <= 0) { printf("Can't open %s\n",name); closesf(); } printf("\nOpened dataset %s.\n",name); }