ftp.nice.ch/pub/next/unix/audio/cmix.s.tar.gz#/cmix/lpc/alpcplay.c

This is alpcplay.c in view mode; [Download] [Up]

#include "../H/ugens.h"
#define NPOLE        32 
#define FRAMSIZE     (NPOLE+4)
#define FPREC        22
#define RECSIZE      (FPREC*FRAMSIZE)
#define BPREC        (RECSIZE*FLOAT)
#define BPFRAME      (FRAMSIZE*FLOAT)

int anal;

play(p,n_args)
float *p;
{
	float buzzamp,ramp,xamp,amp,si,hn,phs,*f,out[4],srd2,magic;
	float c[FRAMSIZE],past[NPOLE*2],val,frames,frame1,frameno,ampmlt,errno;
	float *ballpole(),*bbuzz(),*brandf(),alpvals[2048],buzvals[2048];
	int jcount = 0;
	long seed,i,nsamps;
	int counter,flag;
	float thresh,randamp,randoff;
	float *cpoint;
	for(i=0; i<NPOLE*2; i++) past[i] = 0;

	anal = open("data/wasting13",0);
/* p0=start,p1=dur,p2=8ve.pch,p3=frame1,p4=frame2,p5=amp*/
	amp = p[5];
	si = cpspch(p[2])*512./SR;
	/* si just added now for counter */
	hn = (int)(SR * .5/cpspch(p[2]));	
	srd2 = SR/2.;
	magic = 512./SR;
	phs = 0;
	nsamps = setnote(p[0],p[1],0);
	frames = p[4] - p[3] + 1.;
	frame1 = p[3];
	randoff = 32767./2.;
	f = (float *)floc(1);
	randamp = .1/randoff;
	seed = 1;
	thresh = p[6];
	srand(1);  
	counter = 0; 
	cpoint = c + 4;
	i=nsamps;
	while(i--) {
		while(!counter--) {
			frameno = ((float)(nsamps -i-1)/nsamps)*frames + frame1;
			getfr(frameno,c);
			ampmlt = amp * c[0];
			errno = (c[2] > thresh) ? 0 : 1;  
			ramp = ampmlt * randamp;
			si = c[3] * magic;
			hn = (int)(srd2/c[3]);
			counter = (float)(SR/c[3]);
			counter = (counter > i) ? i : counter;
			if(!counter) break;
			/*
			if(errno)
			*bbuzz(ampmlt,si,hn,f,&phs,buzvals,counter);
			else
			*brandf(&seed,buzvals,counter);
			*ballpole(buzvals,&jcount,NPOLE,
					past,cpoint,alpvals,counter);
			bwipeout(alpvals,0,counter);   
		*/
		}
		if(errno)  
/*printf(" %f %f %f %f\n",ampmlt,si,hn,phs); */
		val = buzz(ampmlt,si,hn,f,&phs); 
		else
		val = (float)(rand()-randoff) * ramp;
		val = allpole(val,&jcount,NPOLE,past,cpoint);
		WIPEOUT(&val,0);   
	}
	endnote(0);
}
getfr(frameno,c)
float frameno,*c;
{
	int frame,i,j;
	static float array[RECSIZE];
	float fraction;
	static int oldframe = 0;
	static int endframe = 0;
	frame = (int)frameno;
	fraction = frameno - (float)frame;
	if(!((frame >= oldframe) && (frame < endframe))) {
		lseek(anal,((long)frame*(long)BPFRAME),0); 
		read(anal,(char *)array,BPREC);
		oldframe = frame;
		endframe = oldframe + FPREC - 1;
		}

	for(i=(frame-oldframe)*FRAMSIZE,j=0; j<FRAMSIZE; i++,j++)  
		*(c+j) = *(array+i) + fraction * (*(array+i+FRAMSIZE) 
						- *(array+i));
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.