
#import "/musr/H/ugens.h"
#import <objc/objc.h>
#import "/musr/objc/Delay.h"
#import "/musr/H/sfheader.h"

#define SIZE 1024
#define MAXDEL 32768 
int NBYTES = 32768;

extern SFHEADER sfdesc[NFILES];
	
float array[SIZE];	
double flange(p,n_args)
float *p;
{
	id delaySig;
	int k,j,count,input,output,nsamps,i;
	int nchans;
	float wait,atten,tabs[2],xin[2],out[2];
	float outx,sig,old,gain;
	double pow();
	float left,right;

	delaySig = [Delay create];


	input = 0; output = 1;
	nsamps = setnote(p[0],p[1],output);
	setnote(p[2],p[1],input);

	[delaySig size:.1 sRate:SR];

	nchans = sfchans(&sfdesc[0]);
	left = right = .5;

	gain = p[4];

	tableset(p[1],SIZE,tabs);
	count = SR/200;
	j=0;
	for(i=0; i<nsamps; i++) {
		if(!j--) {
			wait = table(i,array,tabs);
			j=count;
		}

		GETIN(xin,input);

		old = [delaySig get:wait];

		out[0] = old + xin[0];

		[delaySig put:xin[0]];
		
		WIPEOUT(out,output);
	}
	endnote(output);
}
double sl(p,n_args)
float *p;
{
	int i;
	setline(p,n_args,SIZE,array);
}
profile()
{
	UG_INTRO("flange",flange);
	UG_INTRO("setline",sl);
}
