ftp.nice.ch/pub/next/unix/audio/Cmix.N.s.tar.gz#/cmix/filters/ellipse.c

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

#include "../H/ugens.h"
#define MAXSECTS 20
float ps[4][MAXSECTS],c[4][MAXSECTS],xnorm;
int   nsects;

ell(p,n_args)
float *p;
int n_args;
{
/* p0 = starting time, p1=duration, p2=inputfile skip, p3=number of input channel, p4=number of output channel, p5= number of sections in filter */
	long i,nsamps,nchin,nchout;
	float ellipse(),x[4],y[4];
	nsamps=setnote(p[0],p[1],1);
	       setnote(p[2],p[1],0);
	nchin = p[3];
	nchout = p[4];
	ellpset(&p[5]);
	for(i=0; i<4; i++) x[i] = y[i] = 0.;
	for(i=0;i<nsamps;i++) {
		if(!GETIN(y,0)) {
			printf("reached eof on input\n");
			break;
		}
		x[nchout] = ellipse(y[nchin]); 
		ADDOUT(x,1); 
		}
	endnote(1);
}

float ellipse(x)
float x;
{
	register int m;
	float op;

	for(m=0;m<nsects;m++) {
		op = x + c[0][m] * ps[0][m] + c[2][m] * ps[1][m]
		       - c[1][m] * ps[2][m] - c[3][m] * ps[3][m];
		ps[1][m] = ps[0][m];
		ps[0][m] = x;
		ps[3][m] = ps[2][m];
		ps[2][m] = op;
		x = op;
		}
	return(x*xnorm);
}

ellpset(list)
float *list;
{
/* the first argument in the list is the number of sections */
	int m,i,j;
	nsects = (int)list[0];
	if(nsects > MAXSECTS) { 
		printf("sorry, only configured for %d sections\n",MAXSECTS); 
		exit(-4);
	}
		i=1;
	for(m=0;m<nsects;m++) {
		for(j=0;j<4;j++)  {    
	        	 c[j][m] = list[i++];
			 ps[j][m] = 0; }
		}
	xnorm = list[i];
}

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